-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adicionando try catch no Jenkinsfile
- Loading branch information
1 parent
d9b0760
commit 79c100b
Showing
1 changed file
with
26 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,37 @@ | ||
node { | ||
try{ | ||
|
||
deleteDir() | ||
stage('Clone Repo') { | ||
checkout scm | ||
} | ||
|
||
stage('Clone Repo') { | ||
checkout scm | ||
stage('Build Docker Image') { | ||
app = docker.build('joaoallmeida/calculadora-fiis') | ||
} | ||
|
||
} | ||
stage('Build Docker Image') { | ||
app = docker.build('joaoallmeida/calculadora-fiis') | ||
stage('Push Docker Image') { | ||
docker.withRegistry('https://registry.hub.docker.com','dockerHubCredentials') { | ||
app.push("${env.BUILD_NUMBER}") | ||
} | ||
} | ||
|
||
stage('Set Environment Variables') { | ||
sh "sed -i 's|latest|${env.BUILD_NUMBER}|' kubernetes/deploy.yaml" | ||
sh "sed -i 's|buildNumber|${env.BUILD_NUMBER}|' kubernetes/deploy.yaml" | ||
} | ||
|
||
} | ||
stage('Push Docker Image') { | ||
docker.withRegistry('https://registry.hub.docker.com','dockerHubCredentials') { | ||
app.push("${env.BUILD_NUMBER}") | ||
stage('Deploy to K8s') { | ||
withKubeConfig([credentialsId: 'mykubeconfig']) { | ||
sh 'kubectl apply -f kubernetes/deploy.yaml' | ||
} | ||
} | ||
} | ||
|
||
stage('Set Environment Variables') { | ||
sh "sed -i 's|latest|${env.BUILD_NUMBER}|' kubernetes/deploy.yaml" | ||
sh "sed -i 's|buildNumber|${env.BUILD_NUMBER}|' kubernetes/deploy.yaml" | ||
|
||
} | ||
} catch (Exception e) { | ||
error "Failed: ${e}" | ||
throw | ||
|
||
stage('Deploy to K8s') { | ||
withKubeConfig([credentialsId: 'mykubeconfig']) { | ||
sh 'kubectl apply -f kubernetes/deploy.yaml' | ||
} | ||
} finally { | ||
deleteDir() | ||
} | ||
|
||
} |