How to determine what triggered pipeline?

John Alberts July 18, 2024

I need to pass information from a merged PR to the pipeline that merged PR triggered.  I don't see any available environment variables that would pass that info. 

How can I get it?  Specifically, I'd like to know the build number of the pipeline for the PR that triggered the branch pipeline for the branch the PR merged into.

 

Thanks

 

1 answer

1 vote
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 21, 2024

Hi John,

Just to make sure I understand:

  • You have a PR that is merged, this triggers a pipeline build because of pull-request YML tag
  • That subsequently triggers a branch pipeline for the destination branch because of branches YML tag

The only way I could think of doing this would be to write a script that would make an API call to grep the previous Pipeline build # and set this as an environment variable in the branch pipeline:


The reason for this is that there is no way of sharing environment variables between builds, only steps within the same build (by using artifacts):
https://jira.atlassian.com/browse/BCLOUD-20294

Cheers!

- Ben (Bitbucket Cloud Support)

John Alberts October 22, 2024

Sorry for the late reply.  I ended up depending on the git log. I scrape the top of the commit log for the PR#.  This works for the use case I had when I asked this in July.

Today, I have a different use case, but still need to know what PR merge triggered the current build.
I don't think the solution you offered would work because getting the most recent pipeline build would not necessarily be the PR that was just merged.  The PR pipeline for the PR that was merged could have been run 2 days before someone clicked the button to merge it.

 

Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 22, 2024

Hi @John Alberts 

We'll need to look at your YML config/build environment to assist you further on this.

To do so - we'll need a support ticket. I can see you have access to a Premium workspace, and therefore qualify for support directly with our support team - please raise a ticket so we can assist further:

If you have issues raising a ticket, please let us know your timezone so we can raise one on your behalf with the appropriate team.

Cheers!

- Ben (Bitbucket Cloud Support)

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events