I am following a youtube CICD Pipeline video:
The jenkinsfile is below:
pipeline{
agent{
label "jenkins-agent"
}
tools {
jdk 'Java17'
maven 'Maven3'
dockerTool 'DOCKER25'
}
environment {
APP_NAME = "complete-prodcution-e2e-pipeline"
RELEASE = "1.0.0"
PATH = "C:\\WINDOWS\\SYSTEM32"
DOCKER_USER = "docker_username"
DOCKER_PASS = "docker_token"
IMAGE_NAME = "${DOCKER_USER}" + "/" + "${APP_NAME}"
IMAGE_TAG = "${RELEASE}-${BUILD_NUMBER}"
}
stages{
stage("Cleanup Workspace"){
steps {
cleanWs()
}
}
stage("Checkout from SCM"){
steps {
git branch: 'main', credentialsId: 'github', url: 'https://github.com/Coding-s-Life/complete-prodcution-e2e-pipeline'
}
}
stage("Build Application"){
steps {
bat 'mvn clean package'
}
}
stage("Test Application"){
steps {
bat 'mvn test'
}
}
stage("SonarQube Static Code Analysis"){
steps {
script {
withSonarQubeEnv(credentialsId: 'jenkins-sonarqube-token') {
bat 'mvn sonar:sonar'
}
}
}
}
//stage("SonarQube Quality Gate"){
// steps {
// script {
// waitForQualityGate abortPipeline: false, credentialsId: 'jenkins-sonarqube-token'
// }
// }
//}
// stage('Docker login') {
// steps {
// withCredentials([usernamePassword(credentialsId: 'docker_token', DOCKER_USER: 'DOCKER_USERNAME', DOCKER_PASS: 'DOCKER_PASSWORD')]) {
// bat "echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin"
// }
//}
//}
stage("Build & Push Docker Image") {
steps {
script {
docker.withRegistry('',DOCKER_PASS) {
docker_image = docker.build "${IMAGE_NAME}"
}
docker.withRegistry('',DOCKER_PASS) {
docker_image.push("${IMAGE_TAG}")
docker_image.push('latest')
}
}
}
}
}
}
I am trying to configure docker to read my dockerfile and get executed in the docker’s build pipeline. In the Configuration Tools section I have defined
but cannot reach to docker and it gives this following error My actual path in the environment variables in Windows is set as : C:\Program Files\Docker\Docker\resources\bin but this is taking some path always starting from C:\ProgramData\Jenkins.jenkins\tools\hudson, Don’t know why?
$ docker login -u eagertolearn001 -p ******** https://index.docker.io/v1/
exec: "com.docker.cli.exe": executable file not found in %PATH%
Current PATH : C:\ProgramData\Jenkins\.jenkins\tools\hudson.model.JDK\Java17/bin;C:\ProgramData\Jenkins\.jenkins\tools\hudson.tasks.Maven_MavenInstallation\Maven3/bin;C:\ProgramData\Jenkins\.jenkins\tools\hudson.model.JDK\Java17/bin;C:\ProgramData\Jenkins\.jenkins\tools\hudson.tasks.Maven_MavenInstallation\Maven3/bin;C:\WINDOWS\SYSTEM32;C:\Program Files\Jenkins
[Pipeline] // withDockerRegistry
Any help will be greatly appreciated.
Sincere Regards
EagerToLearn