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

Adding a variable before merging pull request

Jan Pozivil February 6, 2023

Is it possible to add a custom dropdown with predefined values to the screen just before merging a pull request, so I can then access the value selected by user from within the pipeline launched by the merge?

I want be able to tell the pipeline, if the merge is `major | minor | patch | prerelease | alpha` type and then adjust the new version of the package accordingly using `yarn version --<value>`.

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 8, 2023

Hi Jan,

I'm afraid that this is not possible, only custom pipelines (that are triggered manually by a user) accept run-time variables. For this type of pipeline, the variables can be set by the user when the user triggers it:

If you don't mind triggering the pipeline manually, you could use a custom pipeline with a variable that you can set when you trigger the build.

Otherwise, the only other way I can think of is by changing the bitbucket-pipelines.yml file in the source branch and adjusting the version, before you merge a pull request.

Kind regards,
Theodora

Jan Pozivil February 9, 2023

Hi Theodora, when you say _trigger manually_ – how do I trigger a pipeline manually? Is that not the same as creating a pull request and then clicking merge?

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 10, 2023

Hi Jan,

There are several ways to trigger a custom pipeline manually:

1) On Bitbucket Cloud website, go to the Pipelines page of the repo. On this page, where all the pipelines builds are listed, you will see an option Run pipeline at the top of the page (next to the Schedules option):

Screenshot 2023-02-10 at 11.22.04.png

If you select the Run pipeline option you will see the following dialog where you can select a branch and one of the pipelines available for this branch. If you select a custom pipeline with variables, you'll be able to select a value for the variables:

Screenshot 2023-02-10 at 11.06.35.png

 


2) If you go to the Branches page of the repo, and select the 3 dots under Actions for a branch, you will see the option Run pipeline for a branch:

Screenshot 2023-02-10 at 11.06.53.png

 

3) If you open a commit (from the Commits page of the repo), on the right side of the page you will also see an option Run pipeline:

Screenshot 2023-02-10 at 11.08.56.png


4) You can use our API to trigger a custom pipeline in a script on your local environment:

5) You can create a schedule to run a custom pipeline at hourly, daily, or weekly intervals. However, schedules don't provide the option to set a variable's value, so I don't think that would be a suitable option.


Is that not the same as creating a pull request and then clicking merge?

No, this is not the same. If you have in your bitbucket-pipelines.yml file a definition for

branches:
main:

this pipeline will run automatically every time you push commits to the main branch or if you merge a PR to the main branch.

Custom pipelines do not get triggered automatically when there are new commits to a branch, they need to get triggered with one of the ways I listed above.

If you have any other questions, please feel free to let me know.

Kind regards,
Theodora

Like Jan Pozivil likes this
Jan Pozivil February 10, 2023

Thank you, that sounds promising, especially the option 4 via API. Do I imagine it correctly that this could be triggered via some other task orchestration tool like Jenkins?

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 10, 2023

You are very welcome Jan, and yes, this is also possible.

Suggest an answer

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

Atlassian Community Events