summaryrefslogtreecommitdiff
path: root/spec/contracts/publish-contracts.sh
blob: f20cc43e258b8b088274f81a3bf94d91f3a95325 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
LATEST_SHA=$(git rev-parse HEAD)
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
BROKER_BASE_URL="http://localhost:9292"

CONTRACTS=$(find ./contracts -name "*.json")
ERROR=0

trap 'catch' ERR

function catch() {
    printf "\e[31mAn error occured while trying to publish the pact.\033[0m\n"
    ERROR=1
}

for contract in $CONTRACTS
do
    printf "\e[32mPublishing ${contract}...\033[0m\n"
    pact-broker publish $contract --consumer-app-version $LATEST_SHA --branch $GIT_BRANCH --broker-base-url $BROKER_BASE_URL --output json
done

if [ ${ERROR} = 1 ]; then
    exit 1;
fi