Unable to run Bash script from Octopus

546 Views Asked by At

I have been trying to trigger Jenkins Job from Octopus. One way that I found - Remote Access API.

But when I trigger the command from Octopus, I get an error.

Command:

curl -X POST -s "https://jenkins.jenkins.dev/job/MyService/buildWithParameters" -u user:xxx-F dstenv=p1-qa version=from-qa

Error:

The remote script failed with exit code 6 
April 21st 2021 07:51:35 Fatal
The action step1 on a Worker failed 

I ran the command on the slave machine directly - runs fine. When I run other commands from octopus, it runs fine, just when I run the curl command it gives the error.

enter image description here

So what gives!

1

There are 1 best solutions below

0
On

I found that Octopus is unable to understand the responses coming from the Bash commands, so we have to handle the status messages ourselves.

So after triggering the command, I print out the status message, that lets otopus know that the error message is handled:

curl -X POST -s "https://jenkins.jenkins.dev/job/MyService/buildWithParameters" -u user:xxx-F dstenv=p1-qa version=from-qa
echo $?

This way i was able to execute my bash scripts from octopus. There are bunch of bash commands that show up as errors in octopus deplyments in UI. If we dont handle the status code in this manner, the deployment in octopus is marked as failed.