Loading capif/templates/ci_dev.gitlab-ci.yml +15 −15 Original line number Diff line number Diff line Loading @@ -28,21 +28,21 @@ dev_cancel_previous_action: script: - | echo "### cancel previous actions in dev branchc ###" if [[ -n "$CI_JOB_TOKEN" ]]; then echo "Checking for running jobs in the same pipeline..." jobs=$(curl --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" "$GITLAB_API/projects/$CI_PROJECT_ID/pipelines/$CI_PIPELINE_ID/jobs") for job in $(echo "$jobs" | jq -r '.[] | @base64'); do _jq() { echo ${job} | base64 --decode | jq -r ${1} } status=$(_jq '.status') id=$(_jq '.id') if [[ "$status" == "running" ]] && [[ "$id" != "$CI_JOB_ID" ]]; then echo "Cancelling job $id" curl --request POST --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" "$GITLAB_API/projects/$CI_PROJECT_ID/jobs/$id/cancel" fi done fi # if [[ -n "$CI_JOB_TOKEN" ]]; then # echo "Checking for running jobs in the same pipeline..." # jobs=$(curl --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" "$GITLAB_API/projects/$CI_PROJECT_ID/pipelines/$CI_PIPELINE_ID/jobs") # for job in $(echo "$jobs" | jq -r '.[] | @base64'); do # _jq() { # echo ${job} | base64 --decode | jq -r ${1} # } # status=$(_jq '.status') # id=$(_jq '.id') # if [[ "$status" == "running" ]] && [[ "$id" != "$CI_JOB_ID" ]]; then # echo "Cancelling job $id" # curl --request POST --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" "$GITLAB_API/projects/$CI_PROJECT_ID/jobs/$id/cancel" # fi # done # fi rules: - if: $CI_COMMIT_BRANCH <<: *dev_common Loading capif/templates/ci_staging.gitlab-ci.yml +16 −15 Original line number Diff line number Diff line Loading @@ -45,21 +45,22 @@ staging_cancel_previous_action: stage: staging_pre_pipeline script: - | if [[ -n "$CI_JOB_TOKEN" ]]; then echo "Checking for running jobs in the same pipeline..." jobs=$(curl --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" "$GITLAB_API/projects/$CI_PROJECT_ID/pipelines/$CI_PIPELINE_ID/jobs") for job in $(echo "$jobs" | jq -r '.[] | @base64'); do _jq() { echo ${job} | base64 --decode | jq -r ${1} } status=$(_jq '.status') id=$(_jq '.id') if [[ "$status" == "running" ]] && [[ "$id" != "$CI_JOB_ID" ]]; then echo "Cancelling job $id" curl --request POST --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" "$GITLAB_API/projects/$CI_PROJECT_ID/jobs/$id/cancel" fi done fi echo "### cancel previous actions in dev branchc ###" # if [[ -n "$CI_JOB_TOKEN" ]]; then # echo "Checking for running jobs in the same pipeline..." # jobs=$(curl --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" "$GITLAB_API/projects/$CI_PROJECT_ID/pipelines/$CI_PIPELINE_ID/jobs") # for job in $(echo "$jobs" | jq -r '.[] | @base64'); do # _jq() { # echo ${job} | base64 --decode | jq -r ${1} # } # status=$(_jq '.status') # id=$(_jq '.id') # if [[ "$status" == "running" ]] && [[ "$id" != "$CI_JOB_ID" ]]; then # echo "Cancelling job $id" # curl --request POST --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" "$GITLAB_API/projects/$CI_PROJECT_ID/jobs/$id/cancel" # fi # done # fi <<: *staging_common staging_secrets_in_repo: Loading Loading
capif/templates/ci_dev.gitlab-ci.yml +15 −15 Original line number Diff line number Diff line Loading @@ -28,21 +28,21 @@ dev_cancel_previous_action: script: - | echo "### cancel previous actions in dev branchc ###" if [[ -n "$CI_JOB_TOKEN" ]]; then echo "Checking for running jobs in the same pipeline..." jobs=$(curl --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" "$GITLAB_API/projects/$CI_PROJECT_ID/pipelines/$CI_PIPELINE_ID/jobs") for job in $(echo "$jobs" | jq -r '.[] | @base64'); do _jq() { echo ${job} | base64 --decode | jq -r ${1} } status=$(_jq '.status') id=$(_jq '.id') if [[ "$status" == "running" ]] && [[ "$id" != "$CI_JOB_ID" ]]; then echo "Cancelling job $id" curl --request POST --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" "$GITLAB_API/projects/$CI_PROJECT_ID/jobs/$id/cancel" fi done fi # if [[ -n "$CI_JOB_TOKEN" ]]; then # echo "Checking for running jobs in the same pipeline..." # jobs=$(curl --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" "$GITLAB_API/projects/$CI_PROJECT_ID/pipelines/$CI_PIPELINE_ID/jobs") # for job in $(echo "$jobs" | jq -r '.[] | @base64'); do # _jq() { # echo ${job} | base64 --decode | jq -r ${1} # } # status=$(_jq '.status') # id=$(_jq '.id') # if [[ "$status" == "running" ]] && [[ "$id" != "$CI_JOB_ID" ]]; then # echo "Cancelling job $id" # curl --request POST --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" "$GITLAB_API/projects/$CI_PROJECT_ID/jobs/$id/cancel" # fi # done # fi rules: - if: $CI_COMMIT_BRANCH <<: *dev_common Loading
capif/templates/ci_staging.gitlab-ci.yml +16 −15 Original line number Diff line number Diff line Loading @@ -45,21 +45,22 @@ staging_cancel_previous_action: stage: staging_pre_pipeline script: - | if [[ -n "$CI_JOB_TOKEN" ]]; then echo "Checking for running jobs in the same pipeline..." jobs=$(curl --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" "$GITLAB_API/projects/$CI_PROJECT_ID/pipelines/$CI_PIPELINE_ID/jobs") for job in $(echo "$jobs" | jq -r '.[] | @base64'); do _jq() { echo ${job} | base64 --decode | jq -r ${1} } status=$(_jq '.status') id=$(_jq '.id') if [[ "$status" == "running" ]] && [[ "$id" != "$CI_JOB_ID" ]]; then echo "Cancelling job $id" curl --request POST --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" "$GITLAB_API/projects/$CI_PROJECT_ID/jobs/$id/cancel" fi done fi echo "### cancel previous actions in dev branchc ###" # if [[ -n "$CI_JOB_TOKEN" ]]; then # echo "Checking for running jobs in the same pipeline..." # jobs=$(curl --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" "$GITLAB_API/projects/$CI_PROJECT_ID/pipelines/$CI_PIPELINE_ID/jobs") # for job in $(echo "$jobs" | jq -r '.[] | @base64'); do # _jq() { # echo ${job} | base64 --decode | jq -r ${1} # } # status=$(_jq '.status') # id=$(_jq '.id') # if [[ "$status" == "running" ]] && [[ "$id" != "$CI_JOB_ID" ]]; then # echo "Cancelling job $id" # curl --request POST --header "PRIVATE-TOKEN: $CI_JOB_TOKEN" "$GITLAB_API/projects/$CI_PROJECT_ID/jobs/$id/cancel" # fi # done # fi <<: *staging_common staging_secrets_in_repo: Loading