Details
-
Suggestion
-
Resolution: Fixed
-
None
-
1
-
Description
Problem
Bamboo UI allows to create a deployment project which uses a branch of a plan:
This is not possible via Bamboo Specs.
Steps to reproduce
1. Create a plan and deployment project for it.
@BambooSpec public class PlanSpec { public static void main(final String[] args) throws Exception { BambooServer bambooServer = new BambooServer("http://localhost:8085/bamboo"); bambooServer.publish( new Plan(new Project().name("PROJ").key("PROJ"), "PLAN", "PLAN") .stages( new Stage("Stage 1").jobs( new Job("Job", "JOB") .tasks(new ScriptTask().inlineBody("echo 'hello world'")) ) )); bambooServer.publish( new Deployment(new PlanIdentifier("PROJ", "PLAN"), "DEV") .environments(new Environment("ENV")) .releaseNaming(new ReleaseNaming("release-0"))); } }
2. Execute PlanSpec. Go to Bamboo and create a branch manually via UI. The PROJ-PLAN0 branch plan will be created.
3. Try to create another deployment project using PROJ-PLAN0 key:
// for manual branch bambooServer.publish( new Deployment(new PlanIdentifier("PROJ", "PLAN0"), "DEV") .environments(new Environment("ENV")) .releaseNaming(new ReleaseNaming("release-1")));
Execution fails:
2017-10-11 15:12:33,348 INFO [BambooServer] An error occurred while publishing deployment DEV: Plan cannot be found by key 'PROJ-PLAN0' with type 'interface com.atlassian.bamboo.plan.TopLevelPlan' Exception in thread "main" com.atlassian.bamboo.specs.api.exceptions.BambooSpecsPublishingException: An error occurred while publishing deployment DEV: Plan cannot be found by key 'PROJ-PLAN0' with type 'interface com.atlassian.bamboo.plan.TopLevelPlan' 2017-10-11 15:12:33,349 INFO [BambooServer] (for more information, enable more detailed logging with system property -Dbamboo.specs.log.level=DEBUG) at com.atlassian.bamboo.specs.util.BambooServer.translateRestException(BambooServer.java:178) at com.atlassian.bamboo.specs.util.BambooServer.translateException(BambooServer.java:148) at com.atlassian.bamboo.specs.util.BambooServer.publish(BambooServer.java:101) at bamboo.PlanSpec.main(PlanSpec.java:40) Caused by: com.atlassian.bamboo.specs.exceptions.BambooSpecsRestRequestException: Plan cannot be found by key 'PROJ-PLAN0' with type 'interface com.atlassian.bamboo.plan.TopLevelPlan' at com.atlassian.bamboo.specs.util.RestHelper.lambda$sendRequest$2(RestHelper.java:89) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:222) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:164) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:139) at com.atlassian.bamboo.specs.util.RestHelper.sendRequest(RestHelper.java:92) at com.atlassian.bamboo.specs.util.RestHelper.post(RestHelper.java:201) at com.atlassian.bamboo.specs.util.SendQueue$1.run(SendQueue.java:23)
Proposed fix
1. Allow to use branch plan key as identifier, e.g. new PlanIdentifier("PROJ", "PLAN0") or
2. Add branch("branch-name") method for Deployment class.