Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
Teams
, (opens new window)

One Appfire Support Knowledge Base
Results will update as you type.
  • Update on Transition for JIRA (CW)
  • UPM Command Line Interface (CLI) (UPMCLI)
  • Service Desk Command Line Interface (CLI)
  • Tempo Command Line Interface (CLI)
  • Bitbucket Command Line Interface (CLI)
  • Create on Transition for JIRA (CSOT)
  • Confluence Command Line Interface
  • Run CLI Actions in Confluence (CCLI)
  • Bamboo Command Line Interface (CLI) (BCLI)
    • How to get the list of deployment projects in a file using Bamboo Command Line Interface (CLI)
    • How to remove plan from favourite list using Bamboo CLI
    • How to update stage of the plan using Bamboo Command Line Interface
    • How to remove all stages in Bamboo plan using Bamboo Command Line Interface (CLI)
    • How to add a requirement to a deployment environment using Bamboo Command Line Interface (CLI)
    • How to remove all capabilities in Bamboo using Bamboo Command Line Interface (CLI)
    • How to add environment variables to a deployment project using Bamboo CLI
    • How to bulk delete deployment projects in Bamboo using CLI
    • How to add a trigger to Bamboo plan using Bamboo Command Line Interface (CLI)
    • How to add a job to a stage of a plan using Bamboo Command Line Interface (CLI)
    • How to disable the all jobs in Bamboo plan using Bamboo Command Line Interface (CLI)
    • How to create bulk users in Bitbucket using Bitbucket Command Line Interface (CLI)
    • Examples for AddNotification Action
    • Examples for AddRepository Action
    • Examples for AddTask Action
    • Handling errors while updating more than 8 Bamboo build parameters
    • How to get where used information for tasks
    • How to queue all unsuccessful plans for a project
    • How to run all builds for a project one at a time
    • How to delete all projects in Bamboo using Bamboo Command Line Interface (CLI)
    • How to add Bamboo CLI task in a Bamboo job with Run CLI Actions in Bamboo
    • How to add source code Checkout task in Bamboo job with Bamboo CLI
    • How to remove all tasks in Bamboo Job using Bamboo Command Line Interface (CLI)
    • How to resolve error occurring when moving plans
    • How to create projects based on a template
    • How to remove all jobs in Bamboo plan using Bamboo Command Line Interface (CLI)
    • How to determine fields for addRepository
    • How to determine fields for addTask
    • How to get build plan's repository ID
    • How to set plan variables on queueBuild
    • Plan Creation Scripting
      • Configuration as Code
    • _ExamplesForAddRepositoryAction
    • _ExamplesForAddTaskAction
    • How to add a linked repository to a plan
    • How to automate migrating repositories in Bamboo build plans
    • How to install apps from builds
    • Add branches for Bamboo plan in bulk using Bamboo Command Line Interface (CLI)
    • How to create plans that run a sequence of other plans
    • Create Bamboo plans in bulk using Bamboo Command Line Interface (CLI)
    • How to change Bitbucket repository for Bamboo plan using Bamboo Command Line Interface (CLI)
    • Update the repository name for Bamboo plan using Bamboo Command Line Interface ( CLI)
    • How to add Bitbucket server repository from a Bitbucket project in Bamboo using Bamboo Command Line Interface (CLI)
    • How to export and import Bamboo plan across different Bamboo instances
    • How to set isolation type for a Bamboo job using Bamboo Command Line Interface (CLI)
    • How to get details of all Bamboo plans with Bamboo Command Line Interface (CLI)
    • How to add a requirement to a Bamboo plan using CLI
    • Using Slack for Bamboo Status Reporting
    • How to add Confluence CLI task in Bamboo job using Bamboo Command Line Interface (CLI)
    • How to add Jira CLI task in a Bamboo job with Bamboo CLI
    • How to add labels to current build with Bamboo task using Run CLI Actions in Bamboo
    • Managing Build Expiry and Server Storage
    • How to add assignments to agents in bulk using Bamboo Command Line Interface (CLI)
    • How to add a stage to a plan with Bamboo Command Line Interface (CLI)
    • How to get the list of applications linked with Bamboo using CLI
    • How to add inline script task in Bamboo job using Bamboo Command Line Interface (CLI)
    • How to remove build history of a Bamboo plan using Bamboo Command Line Interface (CLI)
    • How to add comments to a build plan with Bamboo Command Line Interface (CLI)
    • Code Pro for Confluence (CODE)
    • How to queue builds with automatic retry on failure
    • How to add Environment trigger to a deployment project using Bamboo CLI
    • How to add an environment to deployment project using Bamboo CLI
    • How to add Bitbucket CLI task in a Bamboo job with Run CLI Actions in Bamboo
    • How to export a deployment project to a file using Bamboo CLI
    • ADMIN
    • How to clone the environment of a deployment project using Bamboo CLI
    • How to set the dependency of a plan using Bamboo CLI
    • How to add environment task to a deployment project using Bamboo CLI
    • How to delete the users who are members of group using Bamboo Command Line Interface (CLI)
    • How to move a job from one stage to another using Bamboo Command Line Interface (CLI)
    • How to add labels to all builds in a plan using Bamboo Command Line Interface (CLI)
  • Run CLI Actions in JIRA (JCLIP)
    You‘re viewing this with anonymous access, so some content might be blocked.
    /
    Configuration as Code
    Published Jul 03, 2019

    Configuration as Code

    Jul 03, 2019

    Story

    We have been on a DevOps journey with Plan Creation Scripting for almost 2 years to realize the goal of having Bamboo configuration as code. Internally, we have 100's of plan configurations under source control with the ability to deploy them to multiple Bamboo servers in an instance. It has proven to be an highly productive endeavor. We made the investment to create these script from scratch and, in the process, significantly improved the performance and reliability of our builds. We are probably on our 3rd generation of major improvements in our plan construction including standardization, common elements, support tools, and more maintainable scripts.

    Now there has been a major advances with Bamboo CLI 6.4 with the addition of exportPlan and the ability to kick start configuration from source efforts in your company as you accelerate your DevOps journey.

    Atlassian Endorses Configuration as Code for Bamboo

    With Bamboo 6.0, has made the initial steps to support Configuration as code with the release of Java based configuration source. They have articulated the advantages of this approach - Advantages of Configuration as Code.

    Options

    Source

    Bamboo

    Advantages

    Source

    Bamboo

    Advantages

    Java

    6.0 and higher

    • Provided by Atlassian

    • Finer grained access for more complete and complex requirements

    • Supports modular components to help enable standardization and reuse

    • Better suited for teams with Java programming and IDE skills

    CLI

    5.10 and higher

    • Higher level abstraction - more readable

    • Same syntax as dynamic plan modifications and related automation

    • Supports modular components to help enable standardization and reuse

    • Individual actions enable better problem determination

    • Option to continue past individual errors on plan creation or modification

    • Better suited to DevOps teams and those comfortable with command line usage

    Export Existing Plans

    Whatever option you choose, the new Bamboo CLI exportPlan action can help you with your journey and automation.

    EAP - exportPlan is marked experimental in 6.4

    • Atlassian considers export to java as beta for Bamboo 6.0 - export may be incomplete or not able to be imported without changes. The CLI exportPlan uses the Bamboo provided export for java.

    • Export plan to CLI is new in Bamboo CLI 6.4 and has some limitations as well in terms of completeness that will be addressed mostly in release 6.5.



    Export to Bamboo Specs Java
    --action exportPlan --plan EXAMPLE-PLAN --type java --file example.java





    // Exported from https://examplegear.com running Bamboo 6.0.0 on 2017-05-02 by automation using the Bamboo CLI 6.4.0-SNAPSHOT import com.atlassian.bamboo.specs.api.builders.AtlassianModule; import com.atlassian.bamboo.specs.api.builders.BambooKey; import com.atlassian.bamboo.specs.api.builders.BambooOid; import com.atlassian.bamboo.specs.api.builders.Variable; 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.Stage; import com.atlassian.bamboo.specs.api.builders.plan.artifact.Artifact; 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.project.Project; import com.atlassian.bamboo.specs.api.builders.task.AnyTask; import com.atlassian.bamboo.specs.api.model.BambooKeyProperties; import com.atlassian.bamboo.specs.api.model.BambooOidProperties; import com.atlassian.bamboo.specs.api.model.VariableProperties; import com.atlassian.bamboo.specs.api.model.plan.JobProperties; import com.atlassian.bamboo.specs.api.model.plan.PlanProperties; import com.atlassian.bamboo.specs.api.model.plan.StageProperties; import com.atlassian.bamboo.specs.api.model.plan.artifact.ArtifactProperties; import com.atlassian.bamboo.specs.api.model.plan.branches.PlanBranchManagementProperties; import com.atlassian.bamboo.specs.api.model.project.ProjectProperties; import com.atlassian.bamboo.specs.api.model.task.AnyTaskProperties; import com.atlassian.bamboo.specs.builders.task.CheckoutItem; import com.atlassian.bamboo.specs.builders.task.ScriptTask; import com.atlassian.bamboo.specs.builders.task.VcsCheckoutTask; import com.atlassian.bamboo.specs.model.task.ScriptTaskProperties; import com.atlassian.bamboo.specs.model.task.VcsCheckoutTaskProperties; import com.atlassian.bamboo.specs.util.BambooSpecSerializer; import com.atlassian.bamboo.specs.util.MapBuilder; public class HllSample { public static void main(String... argv) { Plan rootObject = new Plan(new Project() .oid(new BambooOid("1kbtpp1cvu8by")) .key(new BambooKey("ZEXPORT")), "Base", new BambooKey("BASE")) .oid(new BambooOid("1kbk0hfzo0g5d")) .stages(new Stage("FIRST") .jobs(new Job("JOB1", new BambooKey("JOB1")) .artifacts(new Artifact() .name("out.txt") .copyPattern("out.txt")) .tasks(new VcsCheckoutTask() .description("Checkout Default Repository") .checkoutItems(new CheckoutItem().defaultRepository()), new ScriptTask() .inlineBody("echo xxx > out.txt"), new AnyTask(new AtlassianModule("org.swift.bamboo.acli:bamboo")) .configuration(new MapBuilder() .append("projectFile", "") .append("scriptLocationTypes", "") .append("scriptLocation", "INLINE") .append("scriptBody", "--help") .append("label", "") .append("testChecked", "") .append("directory", "") .append("script", "") .append("testDirectoryOption", "") .append("environmentVariables", "") .append("testResultsDirectory", "") .append("buildJdk", "") .append("workingSubDirectory", "") .build())))) .linkedRepositories("cli") .variables(new Variable("v1", "xxx")) .planBranchManagement(new PlanBranchManagement() .delete(new BranchCleanup()) .notificationForCommitters()); System.out.print(BambooSpecSerializer.dump(rootObject)); } }





    Export to a CLI Script
    --action exportPlan --plan EXAMPLE-PLAN --file example.txt





    # Exported from https://examplegear.com running Bamboo 6.0.0 on 2017-05-02 by automation using the Bamboo CLI 6.4.0-SNAPSHOT -a createOrUpdatePlan --plan ZEXPORT-BASE --name "Base" --description "" -a removeRepository --plan @plan@ --repository @all -a addRepository --plan @plan@ --repository "cli" -a removeBranch --plan @plan@ --branch @all -a addBranch --plan @plan@ --branch 2.5.0 \ --name "ZEXPORT - Base - 2.5.0" -a removeVariables --plan @plan@ --field1 @all -a addVariables --plan @plan@ --field1 "v1" --value1 "xxx" -a removeStage --plan @plan@ --stage @all -a addStage --plan @plan@ --stage "FIRST" -a addJob --plan @plan@ --stage @stage@ --job JOB1 \ --name "JOB1" -a addArtifact --plan @plan@ --job @job@ \ --artifact "out.txt" \ --copyPattern "out.txt" -a addTask --plan @plan@ --job @job@ \ --taskKey CHECKOUT \ --name "Source Code Checkout" \ --description "Checkout Default Repository" -a addTask --plan @plan@ --job @job@ \ --taskKey SCRIPT \ --name "Script" \ --field1 "scriptLocation" \ --value1 "INLINE" \ --field2 "scriptBody" \ --value2 "echo xxx > out.txt" \ --field3 "interpreter" \ --value3 "RUN_AS_EXECUTABLE" -a addTask --plan @plan@ --job @job@ \ --taskKey CLI_BAMBOO \ --name "Bamboo CLI" \ --field1 "scriptLocation" \ --value1 "INLINE" \ --field2 "scriptBody" \ --value2 "--help"



    Export All Plans With One CLI Action

    One action will export all your existing plans to a directory. Alternatively, be more selective by doing this by project and using regex based filtering on names. 

    Export All Plans as Java Files
    --action runFromPlanList --project @all --common "--action exportPlan --plan @plan@ --type java --file export/@project@/@plan@.java"



    Export All Plans as CLI Scripts
    --action runFromPlanList --project @all --common "--action exportPlan --plan @plan@ --file export/@project@/@plan@.txt"

    Import - Creating or Updating Plans

    For java, use your IDE of choice and refer to the Atlassian documentation.

    For CLI, use one of the following approaches depending on your situation. We use the --continue option to keep going even if something fails along the way. The export was constructed to support updating an existing plan without deleting it first. This is important to maintain references from other plans. Also, some history is retained, but due to a Bamboo limitation, previous logs are lost. Use movePlan to another location (project or key change) in order to save all logs.

    Create same plan key as export
    --action run --file example.txt --continue



    Create new plan key
    --action run --file example.txt --findReplace "--plan EXAMPLE-TEMPLATE:--plan EXAMPLE-PLAN1, --name TEMPLATE:--name Plan1" --continue



    {"serverDuration": 13, "requestCorrelationId": "a84024c699f446f19fd8b1f23bbc5dde"}