I have created a simple Bamboo Powershell task (Bamboo cloud) and for the life of me cannot get anything to run successfully.
Right now I've disabled all other Tasks in the Plan and have my Powershell script down to this single line...
I'm using a single "Remote" Build Agent that is running on my local network.
The output from my build is this...
simple 14-Mar-2016 17:41:46 Build CT - User Security - Default Job #14 (CT-US-JOB1-14) started building on agent DEV-BUILD01.criticaltech.com simple 14-Mar-2016 17:41:46 Remote agent on host DEV-BUILD01.criticaltech.com simple 14-Mar-2016 17:41:46 Build working directory is C:\Users\dmiller\bamboo-agent-home\xml-data\build-dir\CT-US-JOB1 simple 14-Mar-2016 17:41:46 Executing build CT - User Security - Default Job #14 (CT-US-JOB1-14) simple 14-Mar-2016 17:41:46 Skipping execution of task 'Checkout Default Repository' as it is disabled simple 14-Mar-2016 17:41:46 Running pre-build action: VCS Version Collector simple 14-Mar-2016 17:41:47 Skipping execution of task 'Checkout Default Repository' as it is disabled simple 14-Mar-2016 17:41:47 Skipping execution of task 'NuGet Package Restore' as it is disabled simple 14-Mar-2016 17:41:47 Skipping execution of task 'Build User Security' as it is disabled simple 14-Mar-2016 17:41:47 Starting task 'Set Version Variable' of type 'com.atlassian.bamboo.plugins.scripttask:task.builder.script' command 14-Mar-2016 17:41:47 Beginning to execute external process for build 'CT - User Security - Default Job #14 (CT-US-JOB1-14)'\n ... running command line: \nC:\Users\dmiller\AppData\Local\Temp\CT-US-JOB1-14-ScriptBuildTask-753372486520642903.ps1\n ... in: C:\Users\dmiller\bamboo-agent-home\xml-data\build-dir\CT-US-JOB1\n ... using extra environment variables: \nbamboo_planRepository_1_branch=master\nbamboo_repository_revision_number=02aeb1cb3549a4e900fc225816263975d3d37131\nbamboo_repository_360449_previous_revision_number=02aeb1cb3549a4e900fc225816263975d3d37131\nbamboo_capability_system_builder_msbuild_MSBuild_v14_0__64bit_=C:\Program Files (x86)\MSBuild\14.0\bin\amd64\MSBuild.exe\nbamboo_resultsUrl=https://criticaltech.atlassian.net/builds/browse/CT-US-JOB1-14\nbamboo_capability_system_jdk_JDK_1_8_0_73=C:\Program Files\Java\jre1.8.0_73\nbamboo_capability_system_builder_msbuild_MSBuild_v4_0__32bit_=C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe\nbamboo_repository_360449_name=CT\nbamboo_planRepository_1_name=CT\nbamboo_build_working_directory=C:\Users\dmiller\bamboo-agent-home\xml-data\build-dir\CT-US-JOB1\nbamboo_buildKey=CT-US-JOB1\nbamboo_shortPlanName=User Security\nbamboo_repository_360449_revision_number=02aeb1cb3549a4e900fc225816263975d3d37131\nbamboo_planRepository_name=CT\nbamboo_buildNumber=14\nbamboo_shortJobName=Default Job\nbamboo_buildResultsUrl=https://criticaltech.atlassian.net/builds/browse/CT-US-JOB1-14\nbamboo_planRepository_repositoryUrl=https://bitbucket.org/airvault/ct\nbamboo_agentId=327681\nbamboo_planName=CT - User Security\nbamboo_shortPlanKey=US\nbamboo_repository_360449_branch_name=master\nbamboo_shortJobKey=JOB1\nbamboo_planRepository_revision=02aeb1cb3549a4e900fc225816263975d3d37131\nbamboo_repository_previous_revision_number=02aeb1cb3549a4e900fc225816263975d3d37131\nbamboo_buildTimeStamp=2016-03-14T17:41:42.328-05:00\nbamboo_planRepository_previousRevision=02aeb1cb3549a4e900fc225816263975d3d37131\nbamboo_repository_360449_git_branch=master\nbamboo_buildResultKey=CT-US-JOB1-14\nbamboo_repository_git_branch=master\nbamboo_repository_branch_name=master\nbamboo_buildPlanName=CT - User Security - Default Job\nbamboo_repository_360449_git_username=racingcow\nbamboo_planRepository_1_revision=02aeb1cb3549a4e900fc225816263975d3d37131\nbamboo_repository_name=CT\nbamboo_version=0.0.0.0\nbamboo_dependenciesDisabled=false\nbamboo_planRepository_branch=master\nbamboo_repository_360449_git_repositoryUrl=https://bitbucket.org/airvault/ct\nbamboo_agentWorkingDirectory=C:\Users\dmiller\bamboo-agent-home\xml-data\build-dir\nbamboo_planRepository_1_previousRevision=02aeb1cb3549a4e900fc225816263975d3d37131\nbamboo_repository_git_username=racingcow\nbamboo_planRepository_1_type=bb\nbamboo_planRepository_branchName=master\nbamboo_capability_system_jdk_JDK=C:\Program Files\Java\jre1.8.0_73\nbamboo_planRepository_type=bb\nbamboo_planRepository_1_username=racingcow\nbamboo_ManualBuildTriggerReason_userName=racingcow\nbamboo_capability_system_builder_msbuild_MSBuild_v14_0__32bit_=C:\Program Files (x86)\MSBuild\14.0\bin\MSBuild.exe\nbamboo_repository_git_repositoryUrl=https://bitbucket.org/airvault/ct\nbamboo_capability_system_builder_msbuild_MSBuild_v4_0__64bit_=C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe\nbamboo_working_directory=C:\Users\dmiller\bamboo-agent-home\xml-data\build-dir\CT-US-JOB1\nbamboo_planKey=CT-US\nbamboo_planRepository_1_repositoryUrl=https://bitbucket.org/airvault/ct\nbamboo_planRepository_username=racingcow\nbamboo_capability_system_jdk_JDK_1_8=C:\Program Files\Java\jre1.8.0_73\nbamboo_planRepository_1_branchName=master\n simple 14-Mar-2016 17:41:47 Failing task since return code of [powershell -ExecutionPolicy bypass -Command C:\Users\dmiller\AppData\Local\Temp\CT-US-JOB1-14-ScriptBuildTask-753372486520642903.ps1] was -1 while expected 0 simple 14-Mar-2016 17:41:47 Finished task 'Set Version Variable' with result: Failed simple 14-Mar-2016 17:41:47 Running post build plugin 'Docker Container Cleanup' simple 14-Mar-2016 17:41:47 Running post build plugin 'NCover Results Collector' simple 14-Mar-2016 17:41:47 Running post build plugin 'Clover Results Collector' simple 14-Mar-2016 17:41:47 Running post build plugin 'npm Cache Cleanup' simple 14-Mar-2016 17:41:47 Running post build plugin 'Artifact Copier' simple 14-Mar-2016 17:41:47 Finalising the build... simple 14-Mar-2016 17:41:47 Stopping timer. simple 14-Mar-2016 17:41:47 Build CT-US-JOB1-14 completed. simple 14-Mar-2016 17:41:44 Running on server: post build plugin 'NCover Results Collector' simple 14-Mar-2016 17:41:44 Running on server: post build plugin 'Build Hanging Detection Configuration' simple 14-Mar-2016 17:41:44 Running on server: post build plugin 'Clover Delta Calculator' simple 14-Mar-2016 17:41:44 Running on server: post build plugin 'Maven Dependencies Postprocessor' simple 14-Mar-2016 17:41:44 All post build plugins have finished simple 14-Mar-2016 17:41:44 Generating build results summary... simple 14-Mar-2016 17:41:44 Saving build results to disk... simple 14-Mar-2016 17:41:44 Logging substituted variables... simple 14-Mar-2016 17:41:44 Indexing build results... simple 14-Mar-2016 17:41:44 Finished building CT-US-JOB1-14.
I've tried adding "Exit 0" to the end of the script, etc. to no avail.
Does anyone know what is causing this?
I don't have node installed on the remote agent, but this stackoverflow post indicates that the build agent may not be merging user and system PATH environment variables in Windows. Just to see if that was the case, I 1) opened the Environment Variables applet, 2) merged the user-level PATH environment information in to the system-level PATH and 3) removed the user-level PATH variable as the answer on that post suggests (see screenshot).
After restarting the remote build agent and re-running the build, the PowerShell script is now running successfully!
14-Mar-2016 17:41:47 Failing task since return code of [powershell -ExecutionPolicy bypass -Command C:\Users\dmiller\AppData\Local\Temp\CT-US-JOB1-14-ScriptBuildTask-753372486520642903.ps1] was -1 while expected 0
The keyword here would be is the machine allowing you to run powershell scripts as this user that is executing. Meaning have you checked the execution policy command that it works in your case.
I would use -File instead of -Command here for example.
Both popular ways ran from cmd:
PowerShell.exe -ExecutionPolicy Bypass -File .runme.ps1
PowerShell.exe -ExecutionPolicy UnRestricted -File .runme.ps1
Thanks for the response, @Kalle Sirkesalo. That command that referenced is actually something that Bamboo controls. The inline script that I type into the Bamboo interface is placed into that T-US-JOB1-14-ScriptBuildTask-753372486520642903.ps1 file, and then Bamboo generates the command to run it while the build is being executed. I don't think I can make Bamboo Cloud or the Remote Agent use the -File switch instead of -Command, but let me know if you know of some config setting for that.
To make sure my user had permissions, I logged in to the remote agent machine as dmiller and created a test.ps1 file in that same folder with my single line of script. Then I ran the same command, and it seemed to run fine with both the -File and -Command switches (see screenshot).
Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs
We're bringing product updates and pro tips on teamwork to ten cities around the world.Save your spot