Deploy improvements

This commit is contained in:
Juan Ferrer 2019-01-08 16:40:46 +01:00
parent b788b251b7
commit 4c9ecc61db
1 changed files with 21 additions and 5 deletions

24
Jenkinsfile vendored
View File

@ -1,5 +1,7 @@
#!/usr/bin/env groovy #!/usr/bin/env groovy
def buildError = null;
try { try {
switch (env.BRANCH_NAME) { switch (env.BRANCH_NAME) {
case 'master': case 'master':
@ -16,11 +18,11 @@ try {
node { node {
stage ('Checkout') { stage ('Checkout') {
checkout scm checkout scm
env.GIT_COMMIT_EMAIL = sh ( env.GIT_COMMITTER_EMAIL = sh (
script: "git --no-pager show -s --format='%ae'", script: "git --no-pager show -s --format='%ae'",
returnStdout: true returnStdout: true
).trim() ).trim()
echo "Commiter: ${env.GIT_COMMIT_EMAIL}" echo "Commiter: ${env.GIT_COMMITTER_EMAIL}"
} }
stage ('Build') { stage ('Build') {
nodejs('node-lts') { nodejs('node-lts') {
@ -60,9 +62,23 @@ try {
body: "Check status at ${env.BUILD_URL}" body: "Check status at ${env.BUILD_URL}"
) )
} catch(e) { } catch(e) {
buildError = e;
}
if (env.GIT_COMMIT_EMAIL) {
def status
def body = "<p>Check status at ${env.BUILD_URL}</p>";
if (buildError) {
status = 'Failed'
body += buildError.getMessage()
} else {
status = 'Success';
}
mail( mail(
to: env.GIT_COMMIT_EMAIL, to: env.GIT_COMMIT_EMAIL,
subject: "Pipeline failed: ${env.JOB_NAME} (${env.BUILD_NUMBER})", subject: "Pipeline: ${status}: ${env.JOB_NAME} (${env.BUILD_NUMBER})",
body: "Check status at ${env.BUILD_URL}" body: body
) )
} }