...
Internally, we have the same problem and the fix was to get plan creation scripts under source control where changes could be controlled and similar plans created from the same source. We maintain multiple Bamboo sites including multiple production build instances (restricted instances for releasing products) and developer build instances. Prior to this ability, the plans diverge. Release 4.3 contains the basics for creating build plans using the most common elements. Now we have hundreds of plans created this way! More capabilities will be added based on feedback, please open an issue with your specific requirements.
There are a number of Bamboo limitations that have been worked around as best as possible. It is hoped these can be improved with future Bamboo support. For instance, plan or job deletes take place in the background and replacement plans or jobs cannot be created until they are fully deleted. Scripting will wait for this to occur, but it can take a minute or so. This means recreate scenarios take longer than one would expect. Adding tasks can be difficult to get working. We have some examples (Examples for AddTask Action), but, some careful work is required to get new ones working correctly :(. The best approach is to use exportPlan of an existing plan that represents the main elements of the kind of plan you want to create. The export provides insight and a starting point for your new plan source. Start simple and gradually add improvements and simplifications to reduce redundancy. Using bamboo variables is strongly recommended to simplify plans, making maintenance easier, and essentially parameterizing your plan.
Note that on re-create of a plan, Bamboo will no longer discard previous build logs - see and vote for on Bamboo 6.9 or higher (see BAM-15957).
See the movePlans tip below - this is the most effective way of avoiding both of these limitations! Moving plans preserves the logs and makes the recreate of the plans very fast. With an archiving process and convention defined using movePlans, you can now safely make sure all your plans are updated from the latest source quickly while preserving history.
...
Section | ||||
---|---|---|---|---|
|
...
Example - Gradle
This builds the Groovy Bamboo app with Gradle and runs integration tests with Gint. The plan is parameterized by NUMBER which represents a Bamboo instance to test against. Normally, we add a Gradle task to the build to run the plan creation script easily.
Code Block | ||
---|---|---|
| ||
# # -a run -f bamboo.cli --findReplace "%NUMBER%:711" # -a createPlan --plan "Bamboo-Groovy @NUMBER@ --replace --options addDefaultJob \ --repository bamboo-groovy -a addLabels --plan @plan@ --labels @NUMBER@ -a addVariables --plan @plan@ --field number=@NUMBER@ \ --field "buildArgs = clean build installApp -Pnumber=${bamboo.number}" \ --field "itestArgs = -Pnumber=${bamboo.number} ""-Dargs=${bamboo.baseArgs}"" " \ --field "baseArgs = --continue --parallel -Dlevel=all -DincludeLevels=all" # Default stage and job - do a clean build of the jar and install the resulting app -a addArtifact --plan @plan@ --job @job@ --artifact jar --location build/libs --copyPattern "*.jar" --shared -a addTask --plan @plan@ --job @job@ --taskKey GRADLEWRAPPER \ --field "arguments=${bamboo.buildArgs}" \ --field buildJdk=JDK # Integration test - add a job for each gint tests so they run in parallel for faster build times -a addStage --plan @plan@ --stage "ITEST" -a runFromList --list "variable,task" \ -i "-a addJob --plan @plan@ --stage @stage@ --job @entry@" \ -i "-a addArtifact --plan @plan@ --job @entry@ --artifact output_@entry@ --location build/output --copyPattern **/*" \ -i "-a addTask --plan @plan@ --job @entry@ --taskKey GRADLEWRAPPER \ --field ""arguments=itest-${bamboo.shortJobName} ${bamboo.itestArgs}"" \ --field buildJdk=JDK \ --field testChecked=true \ " |
Example - Maven
Code Block | ||
---|---|---|
| ||
# # --action run --file create-plan.txt --findReplace "%PLAN%:EXAMPLE-P1:%PLAN_NAME%:,%PLAN_DESCRIPTION%:,%PROJECT_NAME%:,%STAGE_DESCRIPTION%:" # # Plan -a createPlan --plan %PLAN% --name "%PLAN_NAME%" --description "%PLAN_DESCRIPTION%" --projectName "%PROJECT_NAME%" --replace -a addRepository --plan @plan@ --name local --repositoryKey MERCURIAL --field1 repository.hg.repositoryUrl --value1 http://examplegear.com/cli --field2 repository.hg.authentication --value2 PASSWORD --field3 selectedWebRepositoryViewer --value3 bamboo.webrepositoryviewer.provided:noRepositoryViewer -a addTrigger --plan @plan@ --name "scheduled trigger" --type scheduled --schedule 20:00 -a addTrigger --plan @plan@ --name "polling trigger" --repository @repository@ --type polling -a removeVariables --plan @plan@ --field1 @all -a addVariables --plan @plan@ --replace --field1 xxxx --value1 xxxx --field2 yyyy --value2 yyyy # Stage and jobs -a addStage --plan @plan@ --stage "FIRST" --description "%STAGE_DESCRIPTION%" -a addJob --plan @plan@ --stage "@stage@" --job JOB1 -a addArtifact --plan @plan@ --job @job@ --artifact jar --location target --copyPattern "**/*.jar" --shared -a addArtifact --plan @plan@ --job @job@ --artifact itest --location src/itest --copyPattern "**/*" --shared -a addTask --plan @plan@ --job @job@ --description "get source" --taskKey CHECKOUT --field selectedRepository_0=defaultRepository --field checkoutDir_0= -a addTask --plan @plan@ --job @job@ --description "maven compile" --taskKey MAVEN2 --field "label=Maven 2" --field goal=compile --field buildJdk=JDK # Stage and jobs -a addStage --plan @plan@ --stage "A" -a addJob --plan @plan@ --stage "@stage@" --job TEST1 --name "TEST1 job name" --description "TEST1 job description" -a addArtifactDependency --plan @plan@ --job @job@ --artifact jar --location downloads -a addJob --plan @plan@ --stage "@stage@" --job "Test 2" -a addArtifactDependency --plan @plan@ --job @job@ --artifact itest --location src/itest -a addTask --plan @plan@ --job @job@ --description "integration test" --taskKey GINT --field1 script --value1 src/itest/groovy/integration-test.gant --field label=Gant --field buildJdk=JDK --fields scriptLocation:FILE,levelAll:true,includeLevelsAll:true,clean:true,verbose:true,stopOnFail:false,testChecked:true,testDirectoryOption:standardTestDirectory,testResultsDirectory:**/*reports/*.xml # Stage and josjobs -a addStage --plan @plan@ --stage "B" -a addJob --plan @plan@ --stage "@stage@" --job TEST3 --name "selenium" -a addArtifactDependency --plan @plan@ --job @job@ --artifact itest --location src/itest -a addTask --plan @plan@ --job @job@ --description "firefox" --taskKey GINT --field1 script --value1 src/itest/groovy/selenium-test.gant --field "arguments=-Dbrowser=firefox" --field label=Gant --field buildJdk=JDK --fields scriptLocation:FILE,levelAll:true,includeLevelsAll:true,clean:true,verbose:true,stopOnFail:false,testChecked:true,testDirectoryOption:standardTestDirectory,testResultsDirectory:**/*reports/*.xml |
...
Tip | |||||
---|---|---|---|---|---|
| |||||
New for CLI 6.6 is the movePlans action. Easily archive projects or plans before replacing them with the latest plan definitions. The big advantage with this is saving all the plan logs for reference at least for a period of time. Later you can delete them all together with the deleteProject action.
|
How To's
- How to create plans that run a sequence of other plans
- How to automate migrating repositories in Bamboo build plans
- How to determine fields for addTask
- How to determine fields for addRepository
Other Related Information
...