...
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 jobs
-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 |
...