Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-38211

JenkinsFiles cannot run on Linux agent of Windows master

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Major Major
    • pipeline

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

            jglick Jesse Glick
            bobthemagicman Justen Britain
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: