Uploaded image for project: 'Bamboo Data Center'
  1. Bamboo Data Center
  2. BAM-19974

Concurrent Builds override can be lost when publishing Bamboo Specs

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Low
    • 6.6.1
    • 6.5.0
    • Bamboo Specs
    • None

    Description

      Summary

      The Concurrent Builds override setting on a plan can be lost when publishing a Spec that contains it.

      Steps to Reproduce

      1. Set global concurrent builds to 1 (Optional: There’s still a problem without this step but this causes maximumNumberOfConcurrentBuilds to be absent from any subsequent export, without doing this maximumNumberOfConcurrentBuilds will match the default global value)
      2. Create a plan:
        1. Override Concurrent Builds to 10 on the Miscellaneous tab
        2. Override Artifact Handlers >> Enable to Agent Local for shared and non-shared
      3. Export to Spec
      4. Publish that exact exported Spec back to the server
      5. Refresh the Miscellaneous tab > It’s now unchecked
      6. Export to Spec >> it’s now missing maximumNumberOfConcurrentBuilds

      Sample Spec:

      import com.atlassian.bamboo.specs.api.BambooSpec;
      import com.atlassian.bamboo.specs.api.builders.BambooKey;
      import com.atlassian.bamboo.specs.api.builders.BambooOid;
      import com.atlassian.bamboo.specs.api.builders.permission.PermissionType;
      import com.atlassian.bamboo.specs.api.builders.permission.Permissions;
      import com.atlassian.bamboo.specs.api.builders.permission.PlanPermissions;
      import com.atlassian.bamboo.specs.api.builders.plan.Job;
      import com.atlassian.bamboo.specs.api.builders.plan.Plan;
      import com.atlassian.bamboo.specs.api.builders.plan.PlanIdentifier;
      import com.atlassian.bamboo.specs.api.builders.plan.Stage;
      import com.atlassian.bamboo.specs.api.builders.plan.branches.BranchCleanup;
      import com.atlassian.bamboo.specs.api.builders.plan.branches.PlanBranchManagement;
      import com.atlassian.bamboo.specs.api.builders.plan.configuration.AllOtherPluginsConfiguration;
      import com.atlassian.bamboo.specs.api.builders.plan.configuration.ConcurrentBuilds;
      import com.atlassian.bamboo.specs.api.builders.project.Project;
      import com.atlassian.bamboo.specs.builders.task.ScriptTask;
      import com.atlassian.bamboo.specs.util.BambooServer;
      import com.atlassian.bamboo.specs.util.MapBuilder;
      
      @BambooSpec
      public class PlanSpec {
          
          public Plan plan() {
              final Plan plan = new Plan(new Project()
                      .key(new BambooKey("PROJ"))
                      .name("PROJ"),
                  "PLAN",
                  new BambooKey("PLAN"))
                  .pluginConfigurations(new ConcurrentBuilds()
                          .useSystemWideDefault(false)
                          .maximumNumberOfConcurrentBuilds(10),
                      new AllOtherPluginsConfiguration()
                          .configuration(new MapBuilder()
                                  .put("custom", new MapBuilder()
                                      .put("artifactHandlers", new MapBuilder()
                                          .put("useCustomArtifactHandlers", "true")
                                          .put("comAtlassianBambooPluginArtifactHandlerRemote:AgentLocalArtifactHandler:enabledForShared", "true")
                                          .put("comAtlassianBambooPluginArtifactHandlerRemote:AgentLocalArtifactHandler:enabledForNonShared", "true")
                                          .build())
                                      .put("buildExpiryConfig.enabled", "false")
                                      .build())
                                  .build()))
                  .stages(new Stage("Default Stage")
                          .jobs(new Job("Default Job",
                                  new BambooKey("JOB1"))
                                  .tasks(new ScriptTask()
                                          .inlineBody("pwd;"))))
                  .planBranchManagement(new PlanBranchManagement()
                          .delete(new BranchCleanup())
                          .notificationForCommitters())
                  .ignoreHungBuilds();
              return plan;
          }
          
          public PlanPermissions planPermission() {
              final PlanPermissions planPermission = new PlanPermissions(new PlanIdentifier("PROJ", "PLAN"))
                  .permissions(new Permissions()
                          .userPermissions("admin", PermissionType.EDIT, PermissionType.VIEW, PermissionType.ADMIN, PermissionType.CLONE, PermissionType.BUILD));
              return planPermission;
          }
          
          public static void main(String... argv) {
              //By default credentials are read from the '.credentials' file.
              BambooServer bambooServer = new BambooServer("http://bamboo:8085");
              final PlanSpec planSpec = new PlanSpec();
              
              final Plan plan = planSpec.plan();
              bambooServer.publish(plan);
              
              final PlanPermissions planPermission = planSpec.planPermission();
              bambooServer.publish(planPermission);
          }
      }
      

      Expected Results

      Concurrent Builds override is retained

      Actual Results

      Concurrent Builds override is unchecked
      Exported Spec looks like this:

                  .pluginConfigurations(new ConcurrentBuilds()
                          .useSystemWideDefault(false),
                      new AllOtherPluginsConfiguration()
                          .configuration(new MapBuilder()
                                  .put("custom", new MapBuilder()
                                      .put("artifactHandlers", new MapBuilder()
                                          .put("useCustomArtifactHandlers", "true")
                                          .put("comAtlassianBambooPluginArtifactHandlerRemote:AgentLocalArtifactHandler:enabledForShared", "true")
                                          .put("comAtlassianBambooPluginArtifactHandlerRemote:AgentLocalArtifactHandler:enabledForNonShared", "true")
                                          .build())
                                      .put("buildExpiryConfig.enabled", "false")
                                      .build())
                                  .build()))
      

      Workaround

      While not ideal, the only workaround at this point seems to be to remove the Artifact Handler override from the Spec.

      Attachments

        Activity

          People

            mgardias Marcin Gardias
            jowen@atlassian.com Jeremy Owen
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: