Pipe output of Maven task to file

Markus Schulte October 26, 2016

I would like to do

mvn versions:display-dependency-updates > mvn-versions-dependency-updates.txt

 

I cannot do this via Maven3.x-task. When adding "> mvn-versions-dependency-updates.txt" to the goals, I am getting

Unknown lifecycle phase

 

Well, "> mvn-versions-dependency-updates.txt" is not a goal, so the error is fine - but

 

How can I pipe maven output to file via Maven3.x-task?

1 answer

1 accepted

1 vote
Answer accepted
Alexey Chystoprudov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 28, 2016

You can't pass non Maven settings to Maven task. If you need to achieve this goal you have to use script task, use Maven3.x capability there and pass whatever argument you want

https://confluence.atlassian.com/display/BAMBOO/Bamboo+variables#Bamboovariables-Usingcapabilities

In your case it will be something like this

${bamboo_capability_system_builder_mvn3_Maven_3}/bin/mvn -v > maven.version

As good reference of environment variables available during the build, see Job log tab, there you can find correct name of capability you can use in script task

Beginning to execute external process for build 'Test project - Test plan - Default Job #4 (TP-TP-JOB1-4)'
 ... running command line: 
.../projects/bamboo/bamboo-homes/funk-9087_hsqldb_514/temp/TP-TP-JOB1-4-ScriptBuildTask-3521333488667538048.sh
 ... in: .../projects/bamboo/bamboo-homes/funk-9087_hsqldb_514/xml-data/build-dir/TP-TP-JOB1
 ... using extra environment variables: 
bamboo_resultsUrl=http://127.0.0.1:9087/bamboo/browse/TP-TP-JOB1-4
bamboo_dependenciesDisabled=false
bamboo_capability_system_jdk_JDK_1_8_0_77=/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home
bamboo_build_working_directory=.../projects/bamboo/bamboo-homes/funk-9087_hsqldb_514/xml-data/build-dir/TP-TP-JOB1
bamboo_buildKey=TP-TP-JOB1
bamboo_capability_system_docker_executable=/usr/local/bin/docker
bamboo_shortPlanName=Test plan
bamboo_agentWorkingDirectory=.../projects/bamboo/bamboo-homes/funk-9087_hsqldb_514/xml-data/build-dir
bamboo_capability_system_git_executable=/usr/bin/git
bamboo_buildNumber=4
bamboo_shortJobName=Default Job
bamboo_buildResultsUrl=http://127.0.0.1:9087/bamboo/browse/TP-TP-JOB1-4
bamboo_capability_system_jdk_JDK=/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home
bamboo_agentId=163841
bamboo_planName=Test project - Test plan
bamboo_shortPlanKey=TP
bamboo_ManualBuildTriggerReason_userName=admin
bamboo_shortJobKey=JOB1
bamboo_buildTimeStamp=2016-10-28T13:02:16.781+02:00
bamboo_capability_system_builder_mvn3_Maven_3=.../tools/apache-maven-3.2.5
bamboo_working_directory=.../projects/bamboo/bamboo-homes/funk-9087_hsqldb_514/xml-data/build-dir/TP-TP-JOB1
bamboo_planKey=TP-TP
bamboo_capability_system_jdk_JDK_1_8=/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home
bamboo_buildResultKey=TP-TP-JOB1-4
bamboo_buildPlanName=Test project - Test plan - Default Job
bamboo_capability_system_hg_executable=/usr/local/bin/hg
Markus Schulte October 28, 2016

Not beautiful, but good enough. Thanks a lot!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events