modification v10 jenkins

This commit is contained in:
Jazze7 2024-11-06 12:51:43 +05:30
parent c431daa5f4
commit 358e14f930

14
Jenkinsfile vendored
View File

@ -52,15 +52,21 @@ pipeline {
}
}
stage('Push Docker Image') {
stage('Push Docker Image from Remote Server') {
steps {
script {
try {
docker.withRegistry('https://index.docker.io/v1/', REGISTRY_CREDENTIALS) {
docker.image("${DOCKER_IMAGE}:${DOCKER_TAG}").push()
sshagent(credentials: [SSH_CREDENTIALS]) {
// Use docker.withRegistry to login with the credentials
docker.withRegistry('https://index.docker.io/v1/', REGISTRY_CREDENTIALS) {
sh '''
ssh ${REMOTE_SERVER} "docker push ${DOCKER_IMAGE}:${DOCKER_TAG}"
"
'''
}
}
} catch (Exception e) {
error "Failed to push Docker image: ${e.message}"
error "Failed to push Docker image from remote server: ${e.message}"
}
}
}