Programmatically triggered Bamboo plans

1.6k views Asked by At

I am currently attempting to automate a release process using bamboo. In a release there are 5 projects, each of which is an optional candidate. So a release may just be 1/5 projects, so I wouldn't want to release all 5 projects every time.

I am able, using bamboo variables to select which of the 5 projects are to be released, however I am struggling to find a non-flakey way of only building and deploying the desired candidates.

The process needs to work as follows:

  1. Release is triggered in parent plan

    Various Git tagging and branching happens using a script task.

  2. The child builds of the selected projects (?/5) are built using a Maven build step, producing artefacts.

  3. Child build plans trigger Deployment plans and candidate artefacts are deployed.

I am struggling at point 2 to define some sort of logic that selectively builds child plans.

I have looked at creating Blockers for the un-needed candidates so that the do not run and programmatically inserting requirements via bamboo variables on plans so that no agents are capable of running the unwanted plans. However these approaches are somewhat hacky and horrible.

1

There are 1 answers

0
Alex On

So, how you do it is:

1 Project
6 Build plans
5 Deployment plans

1 Build plan contains a script that consumes a config, set when a build is triggered a simple script evaluates which projects are to be released.

You can create a remote branch in each project repository and force each plan to search for new repositories using:

curl -s -X POST --user BAMBOOUSER:BAMBOOUSERPASSWORD 'https://bamboo.aws.co.uk/chain/admin/detectBranches.action?planKey=#{planKey}'  

You then need to get the Branch plan key for the newly created branch. So this will get you a list of keys that you can parse:

curl -s -X GET --user BAMMBOOUSER:BAMBOOUSERPASSWORD 'https://bamboo.aws.co.uk/rest/api/latest/plan/#{planKey}/branch.json'

Build each candidate repository and set up a deployment project for each.

Not ideal, wish I could just use Jenkins to be honest.