Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
titleExport to Bamboo Specs Java
--action exportPlan --plan EXAMPLE-PLAN --type java --file example.java


Expand
titleSee generated java source


Code Block
java
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));
    }
}



Code Block
languagebash
titleExport to CLI Script
--action exportPlan --plan EXAMPLE-PLAN --file example.txt


Expand
titleSee generated CLI source


Code Block
languagebash
linenumberstrue
# 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 com.atlassian.bamboo.plugins.vcs:task.vcs.checkout \
                                                --name "Source Code Checkout" \
                                                --description "Checkout Default Repository" \
                                                --field1 "cleanCheckout" \
                                                --value1 "" \
                                                --field2 "checkoutDir_0" \
                                                --value2 "" \
                                                --field3 "checkoutDir_{index}" \
                                                --value3 "" \
                                                --field4 "selectedRepository_{index}" \
                                                --value4 "defaultRepository" \
                                                --field5 "selectedRepository_0" \
                                                --value5 "defaultRepository" 
-a addTask               --plan @plan@  --job @job@ \
                                                --taskKey com.atlassian.bamboo.plugins.scripttask:task.builder.script \
                                                --name "Script" \
                                                --field1 "argument" \
                                                --value1 "" \
                                                --field2 "scriptLocation" \
                                                --value2 "INLINE" \
                                                --field3 "environmentVariables" \
                                                --value3 "" \
                                                --field4 "scriptBody" \
                                                --value4 "echo xxx > out.txt" \
                                                --field5 "interpreter" \
                                                --value5 "RUN_AS_EXECUTABLE" \
                                                --field6 "script" \
                                                --value6 "" \
                                                --field7 "workingSubDirectory" \
                                                --value7 "" 
-a addTask               --plan @plan@  --job @job@ \
                                                --taskKey org.swift.bamboo.acli:bamboo \
                                                --name "Bamboo CLI" \
                                                --field1 "scriptLocation" \
                                                --value1 "FILE" \
                                                --field2 "scriptBody" \
                                                --value2 "--help" \
                                                --field3 "directory" \
                                                --value3 "" \
                                                --field4 "script" \
                                                --value4 ""


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. 

...