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

How to skip bamboo stage based on inject variable

Shanmuga Sundaram
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!
June 11, 2024

Hi,

We have bamboo plan with multiple stages and we would like to skip package stage is there is no pull request. Pipeline is running for every commit now and we would like to create package only when we have PR. i can put a condition in every task to skip, but is there a way we can do it at stage level?

 

Bamboo Version: 8.0.3 build 80011 - 08 Oct 21

1 answer

1 vote
Khushboo Gupta
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 11, 2024

Hello @Shanmuga Sundaram ,

Welcome to the Atlassian community!

You can have your task run based on a condition that checks for a variable. You need to add an Inject Variables Task to your plan that would consume a properties file. Hence, once the variable(s) are set, you can enable the condition on the task so it knows if it should run or not.

This is the workflow:

  1. Modify the "PREVIOUS_TASK" and have it create a properties file with a set of key=value lines
  2. The "PREVIOUS_TASK" should always succeed (return 0), even if it had failed. For that you'd have to wrap it in a script to force it to succeed, otherwise Bamboo will not advance to the next task
  3. Add an Inject Variables Task to the Plan that would consume the properties file from step #1 and set them as variables
  4. On Tasks "DO A" and "DO B" check the "Add condition to task" box. That would evaluate the injected variables from step #3 and make the decision to execute that task or skip it.

Additionally there in our marketplace, we have a plugin offering conditional tasks: Conditional tasks for Bamboo you can find more information on its usage and limitation in this community post: How we can configure job with conditional tasks for bamboo Plug-in.

Kind regards,

Khushboo Gupta
Atlassian Support

--please don't forget to Accept the answer if the reply is helpful-- 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events