Commit 373cb2ba authored by Andres Anaya Amariels's avatar Andres Anaya Amariels 🚀
Browse files

dev_cancel_previous_action

parent 80a7717a
Loading
Loading
Loading
Loading
+23 −23
Original line number Diff line number Diff line
@@ -144,29 +144,29 @@ staging_cancel_previous_action:
     fi
  <<: *staging_common

dev_cancel_previous_action:
  stage: dev_pre_pipeline
  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
  rules:
    - if: $CI_COMMIT_BRANCH
  <<: *dev_common
#dev_cancel_previous_action:
#  stage: dev_pre_pipeline
#  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
#  rules:
#    - if: $CI_COMMIT_BRANCH
#  <<: *dev_common

include:
 - template: 'Jobs/SAST.gitlab-ci.yml'
+24 −0
Original line number Diff line number Diff line
@@ -23,6 +23,30 @@ variables:
#    - git clone https://oauth2:${CI_JOB_TOKEN}@labs.etsi.org/rep/ocf/capif.git
#  <<: *dev_common

dev_cancel_previous_action:
  stage: dev_pre_pipeline
  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
  rules:
    - if: $CI_COMMIT_BRANCH
  <<: *dev_common

dev_secrets_in_repo:
  needs:
    - dev_pre_pipeline