简体   繁体   中英

Unable to run Bash script from Octopus

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.

在此处输入图像描述

So what gives!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM