Created
May 5, 2018 18:21
-
-
Save mistergamarra/6335ebaa14a8e4fc93f9795c9b03a497 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
node { | |
def mvnHome | |
stage('Preparation') { | |
// Get some code from a Gitlab repository | |
git 'https://gitlab.com/joedayz/ContinuousIntegrationAndContinuousDeliveryApp.git' | |
mvnHome = tool 'M2' | |
} | |
stage('Test') { | |
try { | |
sh "'${mvnHome}/bin/mvn' test" | |
} catch (e) { | |
notifyStarted("Tests Failed in Jenkins!") | |
throw e | |
} | |
} | |
stage('Build') { | |
try { | |
sh "'${mvnHome}/bin/mvn' clean package -DskipTests" | |
}catch (e) { | |
notifyStarted("Build Failed in Jenkins!") | |
throw e | |
} | |
} | |
stage('Results') { | |
try{ | |
archive 'target/*.jar' | |
}catch (e) { | |
notifyStarted("Packaging Failed in Jenkins!") | |
throw e | |
} | |
} | |
stage('Deployment') { | |
try{ | |
sh '/var/lib/jenkins/workspace/Pipeline/runDeployment.sh' | |
}catch (e) { | |
notifyStarted("Deployment Failed in Jenkins!") | |
throw e | |
} | |
} | |
notifyStarted("All is well! Your code is tested,built,and deployed.") | |
} | |
def notifyStarted(String message) { | |
slackSend (color: '#FFFF00', message: "${message}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})") | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment