Welcome to mirror list, hosted at ThFree Co, Russian Federation.

publish-contracts.sh « contracts « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b50ba9afae8989bf707624a294dc62c918c5d77e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
LATEST_SHA=$(git rev-parse HEAD)
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)

cd "${0%/*}" || exit 1

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

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

    trap 'catch' ERR

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

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

function publish_ce_contracts () {
    publish_contract
}

function publish_ee_contracts () {
    cd "../../ee/spec/contracts" || exit 1
    publish_contract
}

if [ $1 = "ce" ]; then
    printf "\e[32mPublishing CE contracts...\033[0m\n"
    publish_ce_contracts
elif [ $1 = "ee" ]; then
    printf "\e[32mPublishing EE contracts...\033[0m\n"
    publish_ee_contracts
elif [ $1 = "all" ]; then
    printf "\e[32mPublishing all contracts...\033[0m\n"
    publish_ce_contracts
    publish_ee_contracts
else
    printf "\e[31mInvalid argument. Please choose either \"ce\", \"ee\", or \"all\".\033[0m\n"
    exit 1;
fi