Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to obtain status execution from Bitbucket trigger pipeline?

MHelena L_ Chaves
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 30, 2024

Hi! 

I'm trying to use Bitbucket trigger pipeline to implement GitOps and I need to verify status execution after a call to pipe atlassian/trigger-pipeline:5.8.1. 
I set WAIT parameter to 'true' hoping that it would break my script but not!
Do you have some suggestions?
Thank you in advance!
My script:
    - step: &update-environment
        script:
          - |
              export ENVIRONMENT="$BITBUCKET_DEPLOYMENT_ENVIRONMENT"
              export IMAGE_TAG=$(git tag --points-at HEAD --sort=-creatordate | head -n 1)
              [[ -z "$IMAGE_TAG" ]] && IMAGE_TAG=${BITBUCKET_COMMIT:0:5}
              echo "IMAGE_TAG=$IMAGE_TAG"
          - pipe: atlassian/trigger-pipeline:5.8.1
            variables:
              BITBUCKET_ACCESS_TOKEN: $GIT_ADMIN_TOKEN
              REPOSITORY: 'sbx-gitops'
              REF_NAME: 'main'
              DEBUG: 'true'
              WAIT: 'true'
              CUSTOM_PIPELINE_NAME: 'update-gitops'
              PIPELINE_VARIABLES: >
                [
                  {"key": "ENVIRONMENT", "value": "${BITBUCKET_DEPLOYMENT_ENVIRONMENT}"},
                  {"key": "COMPONENT", "value": "${BITBUCKET_REPO_SLUG}"},
                  {"key": "IMAGE_TAG", "value": "${IMAGE_TAG}"}

1 answer

0 votes
iub fun
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 30, 2024

Hi

To retrieve the status execution from Bitbucket's trigger-pipeline, add a polling mechanism to check the pipeline status using the Bitbucket API. Set WAIT: 'true' initiates the wait, but it does not update your script status. Use the following API endpoint to check pipeline status:

curl -u "username:$BITBUCKET_ACCESS_TOKEN" \
"https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/pipelines/{pipeline_uuid}"

Poll this endpoint in your script after triggering the pipeline to get the status details, and set conditional actions based on the response. This will help automate the GitOps pipeline status check.

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events