Jenkins - Execute Shell Build Step Not Working

17,172

Solution 1

I played with this and found that it worked if I specified the path to the script. If the script is in your job's workspace directory,

./surveyToolRequest.sh

should work as Jenkins looks for files relative to the root of the workspace.

It's more common to just put the contents of the script file directory into the job configuration; that way you can see what the job is doing and you'll avoid problems like this one.

Solution 2

You should use run "Execute windows batch command" and not "Execute Shell"

Share:
17,172
Chiefwarpaint
Author by

Chiefwarpaint

My cats' breath smells like cat food.

Updated on June 14, 2022

Comments

  • Chiefwarpaint
    Chiefwarpaint almost 2 years

    I'm trying to create a job in Jenkins that will execute a simple shell script. However, it seems that Jenkins isn't actually doing anything with my script. No matter what value I put into the Execute Shell Command section, Jenkins always says that it passes. Even if I put in a bogus filename like "RandomBogusFilename.sh" it'll say the job was a success.

    Can anyone point out what I'm doing wrong and how I can get Jenkins to actually use my shell script?

    The shell script, the job config, and the console output are all shown below. I'm currently trying to do this on a Windows Server 2008 R2 Standard machine.

    Thanks.


    My .sh file

    File Name: surveyToolRequest.sh
    File Location: /jobs/Jeff Shell Script Test/workspace
    Description: Hit a web address and retrieve the HTTP Response. Then print out the HTTP Response.


    #!/bin/bash
    
    response_code=$(curl -s -o /dev/null -w "%{http_code}" http://SOME-WEBSITE.COM)
    echo "The response code is " $response_code  
    



    My Jenkins Job Config


    Jenkins Job Config




    Jenkins Console Output


    enter image description here


  • Chiefwarpaint
    Chiefwarpaint over 9 years
    Thanks for the reply. I'll try it later tonight or first thing in the morning and let you know how it goes.
  • gareth_bowles
    gareth_bowles over 9 years
    Question creator says he is using cygwin, so Execute Shell should be fine.
  • Tomasz Waszczyk
    Tomasz Waszczyk almost 9 years
    @Chiefwarpaint and...?
  • Chiefwarpaint
    Chiefwarpaint almost 9 years
    @PantaRhei I did respond to this thread the next day. If you show all comments, you can see my last reply. Here it is again :: Well, after wasting way too much time trying to get this to work, I just decided to go ahead and do what I need with a Batch file. Maybe I'll revisit this some day in the future. Thanks to those who offered advice. – Chiefwarpaint Dec 12 '14 at 2:54