0

I have this build error saying pandoc command is not recognize, when I build my pipeline on Jenkins : enter image description here

But when I run the exact same command using cmd.exe from the same repository it works perfectly :

enter image description here

So what's wrong here, my command pandoc is well installed and can perfectly be used from cmd.exe, why doesn't it works from Jenkins ?

Here is my Jenkins code (the part causing the error is in the "Build" stage):

pipeline {
    agent any

    stages {
        stage('Prerequisites') {
            steps {
                //bat 'RMDIR C:\\wamp64\\www\\html\\doc'
                bat 'MKDIR C:\\wamp64\\www\\html\\doc'
            }
        }
        stage('Build') {
            steps {
                bat 'pandoc -s C:\\wamp64\\www\\index.md -o C:\\wamp64\\www\\index.html'
                bat 'pandoc -s C:\\wamp64\\www\\index.md -o C:\\wamp64\\www\\index.docx'
            }
        }
        stage('Deploy') {
            steps {
                bat 'COPY C:\\wamp64\\www\\index.html COPY C:\\wamp64\\www\\html\\index.html'
                bat 'COPY C:\\wamp64\\www\\index.docx COPY C:\\wamp64\\www\\html\\doc\\index.docx'
            }
        }
    }
}

Thanks for helping.

JS1
  • 631
  • 2
  • 7
  • 23

1 Answers1

0

Jenkins doesn't automatically take your Windows (path) environment variables. Instead, what you need to do is to go to Jenkins -> Configure System -> Global properties -> Environment variables and add a new variable called Path. For the value, set $Path, and your path variables should start getting registered.

The issue has been discussed extensively in this question.

M B
  • 2,700
  • 2
  • 15
  • 20
  • I tried it, and now the build fails from the beginning at my first batch command, error is : "cmd is not recognized as an internal or external command, operable program or batch file." – JS1 Apr 13 '22 at 13:35