0

I'm trying to make a jenkinsfile to compile c++ file through the shell however i'm having the following error:

1.scripts/Linux-Build.sh: 5: cmake: not found

  1. scripts/Linux-Build.sh: 5: make: not found

my jenkinsfile:

    pipeline {    
          agent any  
         /*  environment {
           PATH = "${env.PATH}:/usr/bin"    }
        */ stages{
             stage('Build'){
                steps{
                 echo "Building..."
                 echo "PATH is: ${env.PATH}"
                 sh 'chmod +x scripts/Linux-Build.sh'
                 sh 'scripts/Linux-Build.sh'
          }    }    stage('Test'){
            steps{
                sh 'echo "Running..."'
                sh 'chmod +x scripts/Linux-Run.sh'
                sh 'scripts/Linux-Run.sh'
           }    
  }
}
    

Linux-Build.sh: #!/bin/sh

echo "${PATH}"

cmake . make

jenkins console output:

> git config core.sparsecheckout # timeout=10
 > git checkout -f eba9957b24cf36c5d5666036e45669ea04bea366 # timeout=10
 > git branch -a -v --no-abbrev # timeout=10
 > git branch -D master # timeout=10
 > git checkout -b master eba9957b24cf36c5d5666036e45669ea04bea366 # timeout=10
Commit message: "Update"
 > git rev-list --no-walk c712362f967199fdd279560bad38e3f26e3a5759 # timeout=10
Cleaning workspace
 > git rev-parse --verify HEAD # timeout=10
Resetting working tree
 > git reset --hard # timeout=10
 > git clean -fdx # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] echo
Building...
[Pipeline] echo
PATH is: /opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[Pipeline] sh
+ chmod +x scripts/Linux-Build.sh
[Pipeline] sh
+ scripts/Linux-Build.sh
/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
scripts/Linux-Build.sh: 6: cmake: not found
scripts/Linux-Build.sh: 7: make: not found
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Test)
Stage "Test" skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 127

GitHub has been notified of this commit’s build result

Finished: FAILURE

1 Answers1

0

This is what I would do:

  1. As Stephen said, log in to the server where the pipeline actually is executed and check with which cmake and which make if the tools are installed on that machine. It is very unlikely that they are. If you are not sure on which server the pipeline is executed you can add the command hostname to your shell-script to dump it.
  2. After cmake is installed and can be found, please double-check the last line of your script. In the question it is cmake . make. This looks odd to me. I would expect some configure and/or build step link.
  3. Finally, you may want to use the CMake plugin for Jenkins instead of a batch script.
Markus
  • 5,976
  • 5
  • 6
  • 21