-
Bug
-
Resolution: Cannot Reproduce
-
Major
-
Operating System: (master)Windows Server 2012 R2 64-bit, (slave/agent)amazon-linux-ami 2016.03-release 64-bit
JRE/JDK: (master) 1.8.0_20, (slave/agent) 1.8.0_45
Jenkins Verison: 2.17
Plugin Versions:
pipeline 2.2
pipeline-build-step 2.2
pipeline-input-step 2.1
pipeline-rest-api 1.7
pipeline-stage-step 2.1
pipeline-stage-view 1.7
Running as Jenkins service, not in Tomcat
Reverse Proxy: No
Jenkins Install Method: Windows Installer
Slave Deploy method: via SSH
Browser Version: Chrome - Version 53.0.2785.113 (64-bit)Operating System: (master)Windows Server 2012 R2 64-bit, (slave/agent)amazon-linux-ami 2016.03-release 64-bit JRE/JDK: (master) 1.8.0_20, (slave/agent) 1.8.0_45 Jenkins Verison: 2.17 Plugin Versions: pipeline 2.2 pipeline-build-step 2.2 pipeline-input-step 2.1 pipeline-rest-api 1.7 pipeline-stage-step 2.1 pipeline-stage-view 1.7 Running as Jenkins service, not in Tomcat Reverse Proxy: No Jenkins Install Method: Windows Installer Slave Deploy method: via SSH Browser Version: Chrome - Version 53.0.2785.113 (64-bit)
In a multi-branch pipeline using a JenkinsFile in the SCM it does not appear to be possible to execute 'sh' commands on a Linux node/agent. As per the example below, when using the 'sh' command in the JenkinsFile it causes a 'bad interpreter' error.
JenkinsFile Snippit:
node('linux-agent-1') { String jdktool = tool name: "1.7", type: 'hudson.model.JDK' withEnv(["PATH+MVN=${tool 'Maven 2'}/bin", "PATH+JDK=${jdktool}/bin", "JAVA_HOME=${jdktool}"]) { stage 'Checkout' checkout scm stage 'Build' try { sh "mvn test" } catch (Exception e) { //Notification here! } }
Error from console log:
[Pipeline] node Running on linux-agent-1 in /opt/jenkins/workspace/ProjectName - TestMultiBranchPipeline/deveoper-branch-1 [Pipeline] { [Pipeline] stage (Build) Entering stage Build Proceeding [Pipeline] sh [developer-branch-1] Running shell script sh: /opt/jenkins/workspace/ProjectName - TestMultiBranchPipeline/developer-branch-1@tmp/durable-6f9c6a38/script.sh: C:\Program: bad interpreter: No such file or directory [Pipeline] }
- relates to
-
JENKINS-50902 shell pipeline step cannot use relative path to shell
-
- Resolved
-
Some additional information that I didn't feel was appropriate for the description as it is a bit speculative. Looking into the "bad interpreter: No such file or directory" output, it seems that most of the time this is related to windows style EOL characters in the script that is attempting to run. I verified that the JenkinsFile did not have the windows specific ^M line endings, to no avail. My hunch as to what is happening is that the command, "sh mvn test" is getting converted to a script, due to this line of output "sh: /opt/jenkins/workspace/ProjectName - TestMultiBranchPipeline/developer-branch-1@tmp/durable-6f9c6a38/script.sh:" and that script is either:
1. Getting created on the windows machine and copied to the node causing it to have windows style line endings
2. Getting created by the windows master on the node causing the windows line endings
Again this is speculative but seemed worth adding to the comments.