Curl (bash) command not working in Jenkinsfile groovy script
In my Jenkinsfile Groovy script, I have the following code;
stage('Test the 500 log URLs')
steps
script
echo 'Testing the URLs from the 500 error access log...'
sh '''#!/bin/bash
while IFS= read -r line; do
URL=`echo $line
The first parts of the file work correctly, including the command;
URL=`echo $line | awk 'print $2' | sed 's/http:/https:/' `
However, the following line;
RESULT=`curl -LI $URL -o /dev/null -w "%http_coden" -s | tr -d '[:space:]' `
fails when I run the Jenkins build.
The following error is produced;
line 4: curl: command not found
I can't see why the previous line ran ok, but this line is failing.
Is there something obvious I'm missing?
Any help would be greatly appreciated.
thanks
bash jenkins jenkins-pipeline jenkins-groovy
add a comment |
In my Jenkinsfile Groovy script, I have the following code;
stage('Test the 500 log URLs')
steps
script
echo 'Testing the URLs from the 500 error access log...'
sh '''#!/bin/bash
while IFS= read -r line; do
URL=`echo $line
The first parts of the file work correctly, including the command;
URL=`echo $line | awk 'print $2' | sed 's/http:/https:/' `
However, the following line;
RESULT=`curl -LI $URL -o /dev/null -w "%http_coden" -s | tr -d '[:space:]' `
fails when I run the Jenkins build.
The following error is produced;
line 4: curl: command not found
I can't see why the previous line ran ok, but this line is failing.
Is there something obvious I'm missing?
Any help would be greatly appreciated.
thanks
bash jenkins jenkins-pipeline jenkins-groovy
2
Does Jenkins actually respect the shebang? (If not, the[[will probably raise an error.) The mostly likely problem is not with the script itself, but thatcurlisn't available on the Jenkins host.
– chepner
Nov 13 '18 at 15:02
Please read the error again:curl: command not found. It's saying that it can't findcurlto execute. It's not installed.
– omajid
Nov 13 '18 at 16:07
add a comment |
In my Jenkinsfile Groovy script, I have the following code;
stage('Test the 500 log URLs')
steps
script
echo 'Testing the URLs from the 500 error access log...'
sh '''#!/bin/bash
while IFS= read -r line; do
URL=`echo $line
The first parts of the file work correctly, including the command;
URL=`echo $line | awk 'print $2' | sed 's/http:/https:/' `
However, the following line;
RESULT=`curl -LI $URL -o /dev/null -w "%http_coden" -s | tr -d '[:space:]' `
fails when I run the Jenkins build.
The following error is produced;
line 4: curl: command not found
I can't see why the previous line ran ok, but this line is failing.
Is there something obvious I'm missing?
Any help would be greatly appreciated.
thanks
bash jenkins jenkins-pipeline jenkins-groovy
In my Jenkinsfile Groovy script, I have the following code;
stage('Test the 500 log URLs')
steps
script
echo 'Testing the URLs from the 500 error access log...'
sh '''#!/bin/bash
while IFS= read -r line; do
URL=`echo $line
The first parts of the file work correctly, including the command;
URL=`echo $line | awk 'print $2' | sed 's/http:/https:/' `
However, the following line;
RESULT=`curl -LI $URL -o /dev/null -w "%http_coden" -s | tr -d '[:space:]' `
fails when I run the Jenkins build.
The following error is produced;
line 4: curl: command not found
I can't see why the previous line ran ok, but this line is failing.
Is there something obvious I'm missing?
Any help would be greatly appreciated.
thanks
bash jenkins jenkins-pipeline jenkins-groovy
bash jenkins jenkins-pipeline jenkins-groovy
asked Nov 13 '18 at 14:57
Darren HarleyDarren Harley
186
186
2
Does Jenkins actually respect the shebang? (If not, the[[will probably raise an error.) The mostly likely problem is not with the script itself, but thatcurlisn't available on the Jenkins host.
– chepner
Nov 13 '18 at 15:02
Please read the error again:curl: command not found. It's saying that it can't findcurlto execute. It's not installed.
– omajid
Nov 13 '18 at 16:07
add a comment |
2
Does Jenkins actually respect the shebang? (If not, the[[will probably raise an error.) The mostly likely problem is not with the script itself, but thatcurlisn't available on the Jenkins host.
– chepner
Nov 13 '18 at 15:02
Please read the error again:curl: command not found. It's saying that it can't findcurlto execute. It's not installed.
– omajid
Nov 13 '18 at 16:07
2
2
Does Jenkins actually respect the shebang? (If not, the
[[ will probably raise an error.) The mostly likely problem is not with the script itself, but that curl isn't available on the Jenkins host.– chepner
Nov 13 '18 at 15:02
Does Jenkins actually respect the shebang? (If not, the
[[ will probably raise an error.) The mostly likely problem is not with the script itself, but that curl isn't available on the Jenkins host.– chepner
Nov 13 '18 at 15:02
Please read the error again:
curl: command not found. It's saying that it can't find curl to execute. It's not installed.– omajid
Nov 13 '18 at 16:07
Please read the error again:
curl: command not found. It's saying that it can't find curl to execute. It's not installed.– omajid
Nov 13 '18 at 16:07
add a comment |
2 Answers
2
active
oldest
votes
It is possible that curl was not installed in a common location like /usr/bin/. I'd suggest you try to run curl via its full path.
$ which curl
/usr/somelocation/curl # <- just an example
Then in your script:
RESULT=`/usr/somelocation/curl -LI $URL...`
Another option is to edit your /etc/profile and append to PATH wherever curl is located.
export PATH=$PATH:/usr/somelocation/
add a comment |
Many thanks for you reply. You were right, curl wasn't installed! Running curl via it's full path and then amending my script has now resolved the problem. Thank you! :)
You should mark the answer as accepted so this question does not remain as "Unanswered".
– ssemilla
Nov 14 '18 at 16:08
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53283775%2fcurl-bash-command-not-working-in-jenkinsfile-groovy-script%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
It is possible that curl was not installed in a common location like /usr/bin/. I'd suggest you try to run curl via its full path.
$ which curl
/usr/somelocation/curl # <- just an example
Then in your script:
RESULT=`/usr/somelocation/curl -LI $URL...`
Another option is to edit your /etc/profile and append to PATH wherever curl is located.
export PATH=$PATH:/usr/somelocation/
add a comment |
It is possible that curl was not installed in a common location like /usr/bin/. I'd suggest you try to run curl via its full path.
$ which curl
/usr/somelocation/curl # <- just an example
Then in your script:
RESULT=`/usr/somelocation/curl -LI $URL...`
Another option is to edit your /etc/profile and append to PATH wherever curl is located.
export PATH=$PATH:/usr/somelocation/
add a comment |
It is possible that curl was not installed in a common location like /usr/bin/. I'd suggest you try to run curl via its full path.
$ which curl
/usr/somelocation/curl # <- just an example
Then in your script:
RESULT=`/usr/somelocation/curl -LI $URL...`
Another option is to edit your /etc/profile and append to PATH wherever curl is located.
export PATH=$PATH:/usr/somelocation/
It is possible that curl was not installed in a common location like /usr/bin/. I'd suggest you try to run curl via its full path.
$ which curl
/usr/somelocation/curl # <- just an example
Then in your script:
RESULT=`/usr/somelocation/curl -LI $URL...`
Another option is to edit your /etc/profile and append to PATH wherever curl is located.
export PATH=$PATH:/usr/somelocation/
answered Nov 13 '18 at 18:51
ssemillassemilla
3,087424
3,087424
add a comment |
add a comment |
Many thanks for you reply. You were right, curl wasn't installed! Running curl via it's full path and then amending my script has now resolved the problem. Thank you! :)
You should mark the answer as accepted so this question does not remain as "Unanswered".
– ssemilla
Nov 14 '18 at 16:08
add a comment |
Many thanks for you reply. You were right, curl wasn't installed! Running curl via it's full path and then amending my script has now resolved the problem. Thank you! :)
You should mark the answer as accepted so this question does not remain as "Unanswered".
– ssemilla
Nov 14 '18 at 16:08
add a comment |
Many thanks for you reply. You were right, curl wasn't installed! Running curl via it's full path and then amending my script has now resolved the problem. Thank you! :)
Many thanks for you reply. You were right, curl wasn't installed! Running curl via it's full path and then amending my script has now resolved the problem. Thank you! :)
answered Nov 14 '18 at 16:06
Darren HarleyDarren Harley
186
186
You should mark the answer as accepted so this question does not remain as "Unanswered".
– ssemilla
Nov 14 '18 at 16:08
add a comment |
You should mark the answer as accepted so this question does not remain as "Unanswered".
– ssemilla
Nov 14 '18 at 16:08
You should mark the answer as accepted so this question does not remain as "Unanswered".
– ssemilla
Nov 14 '18 at 16:08
You should mark the answer as accepted so this question does not remain as "Unanswered".
– ssemilla
Nov 14 '18 at 16:08
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53283775%2fcurl-bash-command-not-working-in-jenkinsfile-groovy-script%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Does Jenkins actually respect the shebang? (If not, the
[[will probably raise an error.) The mostly likely problem is not with the script itself, but thatcurlisn't available on the Jenkins host.– chepner
Nov 13 '18 at 15:02
Please read the error again:
curl: command not found. It's saying that it can't findcurlto execute. It's not installed.– omajid
Nov 13 '18 at 16:07