Skip to content

Commit bf145a1

Browse files
authored
fix: add 'wait' stage to gitlab CI, to ensure github CI builds complete before triggering jenkins (#2089)
2 parents 434c62e + 6de5957 commit bf145a1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

.gitlab-ci.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,34 @@ trigger-jenkins-nspect-on-tag:
99
tags:
1010
- os/linux
1111
- type/docker
12+
timeout: 1h # network-operator CI usually takes ~30 minutes, after the git tag is pushed
1213
variables: # additional variables defined at the gitlab group scope
1314
JENKINS_JOB_NAME: nspect-automation
15+
SLEEP_INTERVAL: 120s
1416
script:
17+
# init
18+
- apk add --no-cache jq yq
19+
- retry_counter=0
20+
- gh_workflow_name=$(yq ".name" .github/workflows/ci.yaml)
21+
# await github actions CI completion
22+
- |
23+
echo "Waiting for $gh_workflow_name to complete... "
24+
until curl \
25+
-fsSL \
26+
-H "Accept: application/vnd.github.v3+json" \
27+
https://api.github.com/repos/Mellanox/network-operator/actions/runs \
28+
| jq \
29+
-r \
30+
--arg GH_WORKFLOW_NAME "$gh_workflow_name" \
31+
'.workflow_runs[] | select(.name == $GH_WORKFLOW_NAME) | .status' \
32+
| head -n 1 \
33+
| grep "completed";
34+
do
35+
retry_counter=$((retry_counter + 1))
36+
echo " attempt $retry_counter "
37+
sleep $SLEEP_INTERVAL
38+
done
39+
echo " Workflow $gh_workflow_name complete!"
40+
# trigger jenkins job
41+
- echo "Triggering Jenkins job $JENKINS_JOB_NAME for tag $CI_COMMIT_TAG ..."
1542
- curl -fsSLX POST -u "$SVC_CLOUD_ORCH_CI_USERNAME:$SVC_CLOUD_ORCH_CI_JENKINS_TOKEN" "$BLOSSOM_JENKINS_URL/job/$JENKINS_JOB_NAME/buildWithParameters?GIT_TAG=$CI_COMMIT_TAG"

0 commit comments

Comments
 (0)