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

Run Bamboo Plan branch just once

Jozef Vandenmooter
Contributor
June 19, 2019

We have a Bamboo plan set up to create plan branches that is triggered whenever is new feature branch is created in Bitbucket (it is set up to monitor Bitbucket). We only want that plan to be executed once (when a feature branch is created) because it is used to create an sfdx scratch org.

However, the problem is that Bamboo kicks off the branch plan whenever a change is committed to the feature branch. How do we turn that off?

Thanks,

Jozef 

 

3 answers

1 accepted

2 votes
Answer accepted
Poorna Ramchand Pemmasani
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 26, 2019

Hi @Jozef Vandenmooter , 

we can achieve the above requirement in the following way.

  • Add the Bitbucket Server repository triggered trigger in the plan configuration and disable it in the Plan Configuration
  • In the Branches under plan configuration, select the option same as defined in the parent plan for Branch triggers option.
  • Configuring the plan configuration with the above steps will meet the requirements.

Please let me know if you need any other help :)

Thanks, 

Poorna

Jozef Vandenmooter
Contributor
June 26, 2019

Works great - thanks Poorna! 

Jozef  

2 votes
Steffen Opel _Utoolity_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 20, 2019

I haven't actually verified this myself, but am confident that you can achieve this with the Conditional tasks for Bamboo app, which allows you to Control task execution by variables and as a use case specifically references that you can Skip build steps in plan branches.

Given that each branch starts with build number 1, you should be able to use the resp. Bamboo variable ${bamboo.buildNumber} and skip the task if it doesn't match.

You can find more details about this app in @Daniel Santos' excellent answer to How we can configure job with conditional tasks for bamboo Plug-in?

As Daniel emphasizes, the app is currently listed as unsupported under Atlassian Labs, but given its importance and success, and how this has been handled in the past, I'm fairly optimistic that Atlassian will at least maintain it, and maybe even promote it to a built-in Bamboo feature down the road. Please watch and vote for the following issue to further increase Atlassian's priority for an official solution regarding this highly voted feature request:

Jozef Vandenmooter
Contributor
June 20, 2019

Hi Steffen,

Thanks for the reply. That looks like an awesome plugin indeed.

 

However, wouldn't the plan still kick off and create a log even if the Tasks are not executed? As I said, we don't want the plan to be kicked off at all anymore once the initial run created the sfdx scratch org.

Jozef  

Like Steffen Opel _Utoolity_ likes this
Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 20, 2019

Hey @Jozef Vandenmooter
I just want to add another idea as a second option.

You could configure the plan branch to disable itself when it runs for the first time. For this, you would need to create a script task at the end of your build with a bash script like:

# If this is not the main plan branch
if [ ${bamboo.planRepository.1.branch} != '<DEFULT_SOURCE_REPOSITORY_BRANCH>' ]
then
# Disable this plan branch
curl -k -u <USER>:<PASSWORD> -H "Content-type: application/json" -X DELETE <BAMBOO_URL>/rest/api/latest/plan/${bamboo.planKey}/enable
fi

The problem with this approach is that you will need to have credentials in your build in order to run the rest API to disable the plan. You can add them as password variables, but they would still be available in your build.

I would stick with @Steffen Opel _Utoolity_'s option if you want to avoid some of the build tasks but still want to run the build for the plan branch.

Like # people like this
Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 20, 2019

I wrote the message above without seeing your last response... I guess it still applies to it =]

Like Jozef Vandenmooter likes this
Jozef Vandenmooter
Contributor
June 20, 2019

I believe you :)

Thanks a bunch! 

Jozef 

Like Daniel Santos likes this
Steffen Opel _Utoolity_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 20, 2019

Hi Jozef,

Your question about a skipped task still being logged has been implicitly answered by @Daniel Santos I guess, that's indeed the case - his clever solution is spot on accordingly (see PS for an alternative that avoids the credentials issue)!

Out of curiosity, may I ask why the logs are an issue? Incidentally the resp. extension point for a Build Trigger Condition module actually fulfills your requirement, i.e. "A build which fails the trigger condition will not be executed, there will be no trace of the existence of this build".

However, we (Utoolity) have a backlog story for our Automation with AWS (Bamboo) app to implement such a build trigger condition that will call out to AWS Lambda, but the users we have talked about this so far always want to have some trace regardless, which renders the story considerably more complex for us because we'd need an audit log.

Thanks,
Steffen

PS: Btw., if you happen to use AWS and do not want to make the credentials available to your build, you could use our (commercial) Invoke Lambda Function action to interact with the Bamboo REST API remotely, which means you can securely store the required Bamboo credentials in the Systems Manager Parameter Store.

Like Daniel Santos likes this
Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 21, 2019

Thank you, @Steffen Opel _Utoolity_, for adding an option to securely store the credentials.

0 votes
Alexey Chystoprudov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 24, 2019

Hello. There's much simpler solution to run only first build of new branch. It's possible to configure triggers for new plan branches. Go to Plan configuration -> Branches. Then choose None trigger. Bamboo will create new branch, run initial build and then do nothing.

Screenshot 2019-06-24 at 12.17.17.png

Update. My mistake. It doesn't work. Branch is created, but first build is not executed.

Jozef Vandenmooter
Contributor
June 24, 2019

Right - that was the first thing I tried  :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events