I have a powershell script that will be ran in Bamboo that will update the status of the Bamboo build. This is called in Github and then the status will be update whatever build that calls the script. This is currently working fine in a windows machine but now there are builds that are needed on a Mac machine.
Firstly the script was returning the error code -1 because I did not have powershell installed on the Mac. Now that I have installed powershell, I am getting the following error:
Failing task since return code of [powershell -ExecutionPolicy bypass -Command /bin/sh /var/folders/c6/T/MAC-CUSAPP-JOB1-14-ScriptBuildTask.ps1] was 134 while expected 0
The code itself is fine for windows as all other builds using a windows agent on bamboo will successfully build the task.
& "${bamboo.build.working.directory}\scripts\publish-status.ps1" `
-repoName MyRepo `
-status pending `
-revision ${bamboo.repository.revision.number} `
-buildUrl ${bamboo.buildResultsUrl} `
-description "Bamboo has started a build" `
-context "bamboo-build"
Is there anyway of doing this correctly so that this will work for a Mac. Currently I have checked that the windows machine in running Powershell Version 5.0.0+ while the Mac is Powershell 6.0.0 Alpha would this be the reason that it is not building and giving the error code of 134?
When I even tried to do this:
if (2 -lt 3)
{
Write-Host this is lower
}
else
{
Write-Host this is higher
}
It will give the same response, even if I did Write-Host hello it would respond with the return code of 134.
Even using a simple powershell script that says return 0 will still give the error message of the return code being 134. Also I checked the ExecutionPolicy for the machine and it is unrestricted for everything.
Also the problem is not the powershell on the Mac, as it will successfully run a powershell script perfectly but it is how bamboo is using the powershell script on the Mac. Do you need to do something different when using a powershell script on bamboo whilst you are using a Mac?
Here is am image of how I run the Bamboo, it's a script task that's needed on windows but this doesn't work on a mac. Update
I added powershell as an executable and then used a command task to call the powershell file but this still not work, any idea's if it is because of Bamboo not supporting powershell on the mac as powershell work's using visual studio code and the terminal on the mac. I did it two ways like this:
-ExecutionPolicy Bypass -File /Users/dev/Documents/PowreshellScripts/hello.ps1
and also like this:
-NoProfile -NoLogo -NonInteractive -ExecutionPolicy Bypass -File /Users/dev/Documents/PowreshellScripts/hello.ps1
return 0
and sending it to a mac to see if it works. – Calabresepowershell -ExecutionPolicy bypass -Command /bin/sh /var/folders/c6/T/MAC-CUSAPP-JOB1-14-ScriptBuildTask.ps1
forpowershell -ExecutionPolicy bypass -file /var/folders/c6/T/MAC-CUSAPP-JOB1-14-ScriptBuildTask.ps1
just to see if there is an issue with that call signature – Calabrese-Command
, i.e., in-Command /bin/sh /var/folders/c6/T/MAC-CUSAPP-JOB1-14-ScriptBuildTask.ps1
, the command string is ` /bin/sh /var/folders/c6/T/MAC-CUSAPP-JOB1-14-ScriptBuildTask.ps1. Given that
/var/folders/c6/T/MAC-CUSAPP-JOB1-14-ScriptBuildTask.ps1` is a powershell script, why is/bin/sh
involved at all? It seems to me that you should be able to invoke your scriptbuildtask script aspowershell -ExecutionPolicy Bypass -File /var/folders/c6/T/MAC-CUSAPP-JOB1-14-ScriptBuildTask.ps1
, possibly with an optional-NoProfile
. – Irishbin/sh /var/folders/c6/T/MAC-CUSAPP-JOB1-14-ScriptBuildTask.ps1
, meaning it will try and load the mac shell and then have the mac shell attempt to execute your powershell code, obviously that's not what you want to have happen. what options are you able to configure within bamboo that are related to the script execution? – CalabreseWrite-Host "hello"
command? I would like to see that definition. – Representation