Curl (bash) command not working in Jenkinsfile groovy script










0















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










share|improve this question

















  • 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











  • 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















0















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










share|improve this question

















  • 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











  • 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













0












0








0








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










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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 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












  • 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











  • 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







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












2 Answers
2






active

oldest

votes


















1














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/





share|improve this answer






























    0














    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! :)






    share|improve this answer























    • You should mark the answer as accepted so this question does not remain as "Unanswered".

      – ssemilla
      Nov 14 '18 at 16:08










    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
    );



    );













    draft saved

    draft discarded


















    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









    1














    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/





    share|improve this answer



























      1














      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/





      share|improve this answer

























        1












        1








        1







        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/





        share|improve this answer













        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/






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 '18 at 18:51









        ssemillassemilla

        3,087424




        3,087424























            0














            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! :)






            share|improve this answer























            • You should mark the answer as accepted so this question does not remain as "Unanswered".

              – ssemilla
              Nov 14 '18 at 16:08















            0














            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! :)






            share|improve this answer























            • You should mark the answer as accepted so this question does not remain as "Unanswered".

              – ssemilla
              Nov 14 '18 at 16:08













            0












            0








            0







            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! :)






            share|improve this answer













            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! :)







            share|improve this answer












            share|improve this answer



            share|improve this answer










            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

















            • 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

















            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Kleinkühnau

            Makov (Slowakei)

            Deutsches Schauspielhaus