-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnullplatform-build-create.yml
34 lines (32 loc) · 1.73 KB
/
nullplatform-build-create.yml
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
stages:
- nullplatform-build-create
variables:
RUNNER_TAG: $RUNNER_TAG
NULLPLATFORM_API_KEY: $NULLPLATFORM_API_KEY
NULLPLATFORM_ENCRIPTION_KEY: $NULLPLATFORM_ENCRIPTION_KEY
NULLPLATFORM_BUILD_URL: "https://ci.nullplatform.com/build"
NULLPLATFORM_BUILD_HEADERS: "Content-Type: application/json"
nullplatform-build-create:
stage: nullplatform-build-create
image: alpine:latest
before_script:
- apk add --no-cache openssl curl jq
- openssl enc -d -iter 1000 -aes-256-cbc -in nullplatform_login.response.json.enc -out nullplatform_login.response.json -k "$NULLPLATFORM_ENCRIPTION_KEY"
- ACCESS_TOKEN=$(cat nullplatform_login.response.json | jq -r '.access_token')
script:
- |+
application_metadata=$(cat nullplatform_application_metadata.json)
for application in $(printf "%s" $application_metadata | jq -c '.[]'); do
application_id=$(printf "%s" "$application" | jq -r '.id')
code_repository_url=$(printf "%s" "$application" | jq -r '.code_repository.url')
permalink="$code_repository_url/-/commit/$CI_COMMIT_SHA"
NULLPLATFORM_BUILD_CREATE_BODY="{\"application_id\":$application_id, \"commit\":{\"id\":\"$CI_COMMIT_SHA\", \"permalink\":\"$permalink\"},\"description\":\"$CI_COMMIT_TITLE\",\"branch\":\"$CI_COMMIT_BRANCH\"}"
NULLPLATFORM_BUILD_CREATE_RESPONSE=$(curl --fail --http1.1 --retry 3 --retry-connrefused --retry-all-errors -X POST -H "$NULLPLATFORM_BUILD_HEADERS" -H "Authorization:Bearer $ACCESS_TOKEN" -d "$NULLPLATFORM_BUILD_CREATE_BODY" $NULLPLATFORM_BUILD_URL)
printf "%s\n" $NULLPLATFORM_BUILD_CREATE_RESPONSE >> nullplatform-build-create.json
done
artifacts:
paths:
- nullplatform-build-create.json
expire_in: 30 min
except:
- tags