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
Hi @Jozef Vandenmooter ,
we can achieve the above requirement in the following way.
Please let me know if you need any other help :)
Thanks,
Poorna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I wrote the message above without seeing your last response... I guess it still applies to it =]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you, @Steffen Opel _Utoolity_, for adding an option to securely store the credentials.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
Update. My mistake. It doesn't work. Branch is created, but first build is not executed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.