I recently installed a new bamboo remote agent and added all the capabilities. Now when I try to test a simple powershell job in bamboo on that agent, I am getting this error:
Version:1.0 StartHTML:000000244 EndHTML:000000636 StartFragment:000000411 EndFragment:000000598 StartSelection:000000411 EndSelection:000000598 SourceURL:https://bamboo.i.fgvms.com/download/ID-STFNA-JOB1/build_logs/ID-STFNA-JOB1-17.log
Failing task since return code of [powershell -ExecutionPolicy bypass -Command \bamboo-agent-home\temp\ID-STFNA-JOB1-17-ScriptBuildTask-8096323714329391444.ps1] was -1 while expected 0
@Hector Magnanao Can you try to write a very simple powershell script like printing something to the console and see if that works?
Hi Hector,
Thanks for your question!
The bamboo task is failing because the return code of the PowerShell Script is -1 which means error. Bamboo script task works on the return status code returned by the script. So I believe this script will fail even when executed outside Bamboo (on the same machine in the PowerShell Terminal) So if it fails there it will fail in Bamboo also.
You should first test the script in the PowerShell and then configure it in bamboo.
Let me know if it passes locally. Share the code then.
Thanks,
Robhit
Hi Minh,
all i'm doing is write-host 'Hello' and it fails with that error.
Robhit,
I am not calling a script. All I'm doing is typing write-host 'hello' and it fails with that error message.
Did you configure the requirement to use a Windows OS?
I am not quite sure what "write-host 'hello'" command does in Windows. But could you try to execute a simple "echo hello" command using Bamboo?
that is powershell command that doesn't work. Echo hello works if i'm not using powershell.
yes, this is a Windows OS.
I found out some interesting things while trying find a solution. If I create the script using the shell interpreter and calling the powershell executable like this: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe write-host 'hello' --- this works !!!! But if I use the windows powershell as the interpreter directly, it fails !!!
Hector, Did you ever find a real solution to this problem? We've got the same issue in Bamboo 6.6.2 if we use the Atlassian script task but if we use a 3rd party PowerShell plugin it works just fine... so the issue is definitely the Atlassian Script task.
Failing task since return code of [powershell -NonInteractive -ExecutionPolicy bypass -Command \builds\1\ABC-123\DevOpsScripts\v1\GetAppNameAndVersion.ps1 -Prefix ABC] was -1 while expected 0
Yes, this is already resolved. It resolved itself when I was able to correct the path for the bamboo service account.
For those who are wondering, I also had this issue on a Windows 2016 box, with bamboo agent running as a non-interactive service, using the java wrapper.exe. On that machine, the system %PATH% was not being loaded for a domain user account which was being used to run the service. I got things working by modifying the wrapper.conf (referenced on the command line for the win service) to include the following lines:
set.default.MYPATH=%PATH%%WRAPPER_PATH_SEPARATOR%C:\Windows\System32\WindowsPowerShell\v1.0\%WRAPPER_PATH_SEPARATOR%set.PATH=%MYPATH%
These statements should be on two lines. I used a temporary variable due to a bug mentioned in https://wrapper.tanukisoftware.com/doc/english/props-envvars.html
This may be a hack. I'm not sure what the proper way of injecting the system PATH into a service context is, if any,
It looks like you're new here. Sign in or register to get started.