issue in the pipeline script when i am running the docker command inside the pipeline script

5 views
Skip to first unread message

khushal tarsariya

unread,
Feb 13, 2023, 8:32:33 AM2/13/23
to jenkins-pipelin...@googlegroups.com
'docker' is not recognized as an internal or external command, operable program or batch file.
note:-1.I have all ready install the plugin for the docker(Docker)
2.I am using all the three docker,jenkins and sonarqube in the windows

The above line is the error i got when i am build the pipeline

Here the script which i am use for the jenkins pipeline code:-
pipeline {
    agent any
    stages {
        stage('SCM Checkout') {
            steps {
                git branch: 'master', url: 'https://github.com/khushalt-icpl/React-Admin.git'
            }
        }
        stage('SonarQube Analysis') {
            steps {
                withSonarQubeEnv('SonarQubeServer') {
                  bat "C:/sonar-scanner-4.7.0.2747-windows/bin/sonar-scanner -D sonar.login=admin -D sonar.password=Khushal@123 -D sonar.projectKey=example1 -D sonar.exclusions=vendor/**,resources/**,**/*.java -D sonar.host.url=http://localhost:9000"
                }
            }
        }
        stage('unit test'){
            steps{
                bat "npm install"
                bat "npm run test"
            }
        }
        stage('Build'){
            steps{
                bat "npm run build"
            }
        }
     
        stage('Quality Gate') {
            steps {
                script{
                timeout(time: 1, unit: 'MINUTES') {
                    waitForQualityGate abortPipeline: true
                }
                if(currentBuild.result == 'FAILUER') {
                    echo 'Quality gate has failuer'
                }
                else{
                    echo 'Quality gate has success'
                    currentBuild.result = 'SUCCESS'
                }
            }
        }
        }
        stage('Deployment'){
            steps{
                bat "docker build -t new-image ."
            }
        }
    }
    post {
        always {
            echo 'Job completed'
        }
    }
}

Please show some help thankyou

martin....@googlemail.com

unread,
Feb 14, 2023, 4:39:40 AM2/14/23
to Jenkins Pipeline Authoring SIG
Either docker is not installed on your Jenkins agent. Or docker is installed but not in the %PATH% environment variable of the user that executes `bat "docker ..."`.
Reply all
Reply to author
Forward
0 new messages