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

Enable/ disable jobs in stage dynamically?

Pawan Shrestha July 9, 2021

Is there a way to enable or disable job dynamically in runtime in Bamboo just like conditional tasks?

3 answers

0 votes
Pawan Shrestha July 9, 2021

One of the dirty solutions I am thinking is to create a wrapper build plan that would read the parameters/variables and based on the variables (e.g enableJob1, enableJob2... enableJob3 - these would be true or false), do followings:

1) create java spec in run time

2) push the spec and create (or update) the plan itself 

3) run the updated plan 

Not sure I am overthinking or is there any other good way to solve this.

Suvradip Paul
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 9, 2021

Yes, I understand Plan within Plan to tackle it. Your purpose would be solved but this solution would not be a good practice to follow.

0 votes
Pawan Shrestha July 9, 2021

@Suvradip Paul ,

Thank you for the reply. I am using Bamboo 7.2.3 deployed in a local vm. Unfortunately the link you have shared is not what I am looking for. 

Let me try to explain it more. I have a bamboo plan that has a number of jobs within a stage and each job has a number of tasks. The reason to have a number of jobs is to run them in parallel when required. Based on our need, we manually enable / disable the jobs before we execute the plan. 

I want to move away from this behaviour and provide conditional execution of jobs. My thought was to use java spec and do one of the following:

i) either populate job (.Stage.jobs(job1, job2, ... jobN)

or

ii) enable/disable job (job1.enable(false), job2.enable(true).. and so on)

I am almost reaching to a conclusion that this is not possible as I cannot read variable outside task.

Not sure if there is another way to do it. I dont want to use conditional tasks as this will require to run stage even if i have to skip all the tasks (assuming i wanted to disable the sage).

Hope this makes it clear.

-Pawan

0 votes
Suvradip Paul
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 9, 2021

Hi @Pawan Shrestha ,

Thanks for posting this in community.

I am not sure which version you are using, but I think this would solve your query (i.e. stopping an active job build) - https://confluence.atlassian.com/bamboo/stopping-an-active-build-289276913.html

Please  accept the answer if it solves your query else  please respond an allow others to share input.

Stay safe and healthy.

Cheers

Suvradip

Pawan Shrestha July 18, 2022

@Suvradip Paul ,

Sorry for super late reply but this is not what i am looking for. I dont want the build to be stopped but to selectively run jobs within a build.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events