modification v1 jenkin
This commit is contained in:
parent
8f85f8c5d3
commit
1ed6207275
35
Jenkinsfile
vendored
35
Jenkinsfile
vendored
@ -11,6 +11,18 @@ pipeline {
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Add Host Key') {
|
||||
steps {
|
||||
script {
|
||||
sshagent(credentials: [SSH_CREDENTIALS]) {
|
||||
sh '''
|
||||
ssh-keyscan -H 160.187.166.47 >> ~/.ssh/known_hosts
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Checkout and Install Dependencies on Remote Server') {
|
||||
steps {
|
||||
script {
|
||||
@ -31,10 +43,14 @@ pipeline {
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build Docker Image') {
|
||||
stage('Build Docker Image') {
|
||||
steps {
|
||||
script {
|
||||
docker.build("${DOCKER_IMAGE}:${DOCKER_TAG}")
|
||||
try {
|
||||
docker.build("${DOCKER_IMAGE}:${DOCKER_TAG}")
|
||||
} catch (Exception e) {
|
||||
error "Failed to build Docker image: ${e.message}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -42,8 +58,12 @@ pipeline {
|
||||
stage('Push Docker Image') {
|
||||
steps {
|
||||
script {
|
||||
docker.withRegistry('https://index.docker.io/v1/', REGISTRY_CREDENTIALS) {
|
||||
docker.image("${DOCKER_IMAGE}:${DOCKER_TAG}").push()
|
||||
try {
|
||||
docker.withRegistry('https://index.docker.io/v1/', REGISTRY_CREDENTIALS) {
|
||||
docker.image("${DOCKER_IMAGE}:${DOCKER_TAG}").push()
|
||||
}
|
||||
} catch (Exception e) {
|
||||
error "Failed to push Docker image: ${e.message}"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -79,7 +99,7 @@ pipeline {
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,5 +107,10 @@ pipeline {
|
||||
always {
|
||||
cleanWs()
|
||||
}
|
||||
failure {
|
||||
mail to: 'jassim.mohammed@tech4biz.io',
|
||||
subject: "Pipeline Failed: ${currentBuild.fullDisplayName}",
|
||||
body: "Pipeline failed. Check the Jenkins console for more details."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user