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!
I had this problem intermittently.
For me, the problem was that my Deployment Agent restrictions (Specifically "Windows exists") somehow got lost, so sometimes one of our Linux agents would pick up the job, and of course Powershell or Batch files can't be run by Linux. Be sure you're running on a Windows build agent.
Which reminds me. . .running Linux no longer implies that you can't run PowerShell. And most Windows systems with a git client (which is probably most Windows systems used by developers) have a reasonable bash implementation. I should probably head over to JIRA for Bamboo and check and see if support for these has been suggested (or implemented) yet.
[later edit - I have added this request as a comment to https://jira.atlassian.com/browse/BAM-15825 . BAM-15825 actually requests the opposite (that PowerShell be disallowed on non-Windows systems), but has been rendered obsolete by foot-dragging^H^H^H^H^H^H^H^H^H^H^H^H^Hthe passage of time.]
Thank you for this tip. Removing the registry entry for PATH for the .DEFAULT user fixed the issue for me.
For additional context, this is what happened in our setup:
1. We initially installed the agent as a standard dedicated user.
2. Then we switched it to run as a Windows service and then as the System user. After this, we couldn't execute any PowerShell commands.
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).
I am also facing the same issue , Bamboo remote agent is not able to run the powershell command whereas when using directly from the powershell it is working fine. Here is the error I get when I run using the Bamboo
Failing task since return code of [powershell -NonInteractive -ExecutionPolicy bypass -Command C:\Users\Missionuser\bamboo-agent-home\temp\SDM-SDCE2-JOB1-240-ScriptBuildTask-5153737850206120377.ps1] was -1 while expected 0
If you've followed the links and tried the suggestions in this thread and you're still not getting any results, I'd recommend monitoring the task using procmon.
(I'm not familiar with Bamboo Cloud. I use a local Bamboo installation. There may or may not be difficulties running procmon in the cloud. Perhaps other people on the thread could speak to that).
If you end up using procmon, you'll want to start procmon just before the test runs and stop it just after the task finishes - procmon captures a lot of events and you'll spend less time wading through irrelevant stuff if you narrow down the time window.
PowerShell may sometimes fail in a way the procmon doesn't reveal, but that's pretty rare.
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
G’day Bamboo customers, The wait is over! Bamboo Data Center edition you have been asking for is finally here! This self-managed enterprise offering of Bamboo has the resilience, reliability, and s...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events