Skip to content

Commit

Permalink
[ci] improve cancel-pipeline job (#1532)
Browse files Browse the repository at this point in the history
* [ci] improve cancel-pipeline job

* fix trigger

* fix trigger

* add file to trigger

* test job fail

* fix trigger

* fix indent

* fix before_script

* add comment

* remove debuag fail from test-linux-stable
  • Loading branch information
alvicsam authored Aug 11, 2022
1 parent 66a370b commit 7ee1955
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ variables:
- cargo +nightly --version
- bash --version

# collecting vars for pipeline stopper
# they will be used if the job fails
.pipeline-stopper-vars: &pipeline-stopper-vars
- echo "FAILED_JOB_URL=${CI_JOB_URL}" > pipeline-stopper.env
- echo "FAILED_JOB_NAME=${CI_JOB_NAME}" >> pipeline-stopper.env
- echo "FAILED_JOB_NAME=${CI_JOB_NAME}" >> pipeline-stopper.env
- echo "PR_NUM=${CI_COMMIT_REF_NAME}" >> pipeline-stopper.env

.pipeline-stopper-artifacts: &pipeline-stopper-artifacts
artifacts:
reports:
dotenv: pipeline-stopper.env

.common-refs: &common-refs
# these jobs run always*
rules:
Expand Down Expand Up @@ -88,6 +101,10 @@ test-linux-stable:
stage: test
<<: *docker-env
<<: *common-refs
<<: *pipeline-stopper-artifacts
before_script:
- *rust-info-script
- *pipeline-stopper-vars
variables:
# Enable debug assertions since we are running optimized builds for testing
# but still want to have debug assertions.
Expand Down Expand Up @@ -355,11 +372,17 @@ cancel-pipeline:
stage: .post
needs:
- job: test-linux-stable
artifacts: false
rules:
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
when: on_failure
variables:
PROJECT_ID: "${CI_PROJECT_ID}"
PROJECT_NAME: "${CI_PROJECT_NAME}"
PIPELINE_ID: "${CI_PIPELINE_ID}"
trigger: "parity/infrastructure/ci_cd/pipeline-stopper"
FAILED_JOB_URL: "${FAILED_JOB_URL}"
FAILED_JOB_NAME: "${FAILED_JOB_NAME}"
PR_NUM: "${PR_NUM}"
trigger:
project: "parity/infrastructure/ci_cd/pipeline-stopper"
# remove branch, when pipeline-stopper for substrate and polakdot is updated to the same branch
branch: "as-improve"

0 comments on commit 7ee1955

Please sign in to comment.