10

I has the two repositories in bitbucket pipelines, both with pipelines enable.

How to execute the pipeline after the other pipeline complete?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Afonso Rodrigues
  • 123
  • 1
  • 2
  • 9

4 Answers4

22

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.

5

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)

jvleminc
  • 71
  • 1
  • 3
3

As a final step of your almost completed pipeline, you could just trigger the other one by using BitBucket REST API.

Trigger a Pipeline for a branch

Recoba20
  • 314
  • 1
  • 13
  • I feel that using the above mentioned pipe is more in the spirit of a pipeline. Yes, that pipe will probably do this internally. – Mark Jun 28 '23 at 11:12
0

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.

marisa79
  • 23
  • 1
  • 8