I has the two repositories in bitbucket pipelines, both with pipelines enable.
How to execute the pipeline after the other pipeline complete?
I has the two repositories in bitbucket pipelines, both with pipelines enable.
How to execute the pipeline after the other pipeline complete?
Use "Bitbucket trigger pipeline" pipe in your pipeline's final step. You can easily setup this pipe:
script:
- pipe: atlassian/trigger-pipeline:4.1.5
variables:
BITBUCKET_USERNAME: $BITBUCKET_USERNAME
BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
REPOSITORY: 'your-awesome-repo'
Where variables:
$BITBUCKET_USERNAME - Bitbucket user that will trigger the pipeline. Note, that this should be an account name, not the email.
$BITBUCKET_APP_PASSWORD - Bitbucket app password of the user that will trigger the pipeline. Remember to check the Pipelines Write and Repositories Read permissions when generating the app password.
This pipe will trigger the branch pipeline for master in your-awesome-repo. This pipeline will continue, without waiting for the triggered pipeline to complete.
Just confirming that the above answers work, but we found out (after a lot of trial and error) that the user executing the pipeline must have WRITE permissions on the repo where the pipeline is invoked (even though his app password permissions were set to "WRITE").
Also, this works for executing pipelines in Bitbucket's cloud or on-premise, through local runners.
(Answering as I am lacking reputation for commenting)
As a final step of your almost completed pipeline, you could just trigger the other one by using BitBucket REST API.
I don't have enough reputation to reply to @Ali Mert Çakar so needs to go from a reply.
If you go to the link at least of today you can also use a BITBUCKET_ACCESS_TOKEN - The access token for the repository which is required unless BITBUCKET_USERNAME and BITBUCKET_APP_PASSWORD are used. This would solve your question.
Edit: sorry I misread the question - this approach only works with pipelines in the same repo. I have not tested this, but it should be possible to make this work if you are able to set up your build environment as follows:
Alternatively, you could to use YAML anchors to copy the steps from the other pipeline.
The anchor '&' defines a chunk of configuration
The alias '*' refers to that chunk elsewhere
You can use overrides with the characters '<<:' to add more values, or override existing ones.
Example with build-test
and deploy
anchors (note that the separate definitions
key is optional, for readability only - anchors may also be defined directly on a step under the pipelines
key):
definitions:
steps:
- step: &build-test
name: Build and test
script:
- mvn package
artifacts:
- target/**
- step: &deploy
name: Deploy
deployment: test
script:
- ./deploy.sh target/my-app.jar
pipelines:
branches:
develop:
- step: *build-test
- step: *deploy
main:
- step: *build-test
- step:
<<: *deploy
deployment: production
trigger: manual
© 2022 - 2024 — McMap. All rights reserved.