MonkeyBonkey
MonkeyBonkey

Reputation: 47921

execute shell step skipped completely in jenkins

I can't seem to run a build execute shell step in Jenkins. I've worked with Hudson in the past on windows and I was able to create shell/batch steps without a problem but I seem to be be missing something here.

It's a fresh jenkins install and I go to "add build step", "execute shell" and enter "echo hi" in the command. I run the build and when I look in the console output, nothing happens.

I've also tried executing a test.sh file which also just echoes hi. I've tested this in both a linux install and an os X installed Jenkins server.

What am I missing in the configuration to run a shell script?

The console output shows that the shell script steps were skipped completely

Started by user admin
Finished: SUCCESS

Upvotes: 9

Views: 17465

Answers (3)

theanos
theanos

Reputation: 41

Putting this here for posterity.

I had a Jenkins project configured with Maven running clean test and a execute shell in the pre steps. The logs from Maven where not coming through and the script was not executing. Once I unchecked Build modules in parallel under the Maven build options my logs and scripts started working.

Upvotes: 2

Sagar
Sagar

Reputation: 9503

It looks like Jenkins is not being able to redirect the output from the system. What version of Java are you using? If you're using OpenJDK, could you try with Sun Java/Sun JDK?

First test to try to check if anything is executing at all: add the following to your "Execute Shell"

#!/bin/bash
echo "HELLO WORLD" > /tmp/testfile

Run this and check if there is a /tmp/testfile in on your Linux system, and if it contains the HELLO WORLD text, it means your script is in fact executing.

Which version of Jenkins do you have?

The last good version that I can attest to (last one I know works well at least for us) is 1.447. If you're not using that one, would you be able to try with it?

Also, could you add #!/bin/sh or #!/bin/bash before echo hi on your "Execute Shell" for the Linux system and see if that works.

Also, try running a script using source /path/to/script and see if that works. The script should contain #!/bin/sh or #!/bin/bash as the first line, just to see if that makes a difference.

Note: none of this should be required, but is helpful just to get more information on what's going on. Couldn't fit all this into a comment. I'll update my answer based on your answers to the above, or delete if I can't get anything..

Upvotes: 6

MTR
MTR

Reputation: 1441

Make sure its in a location where Jenkins can see it, check permissions.

Upvotes: 0

Related Questions