Professional Documents
Culture Documents
agent any
tools {
maven 'maven3.6.3'
}
stages {
stage('Build') {
steps {
sh 'mvn clean package -B -ntp'
}
post {
success {
echo 'Job ejecutado exitosamente'
jacoco()
}
}
}
stage('Sonarqube') {
steps {
withSonarQubeEnv('SonarQube') {
withCredentials([file(credentialsId: 'sonnarscanner-settings',
variable: 'M2_SETTINGS')]) {
sh "mvn sonar:sonar -B -ntp -s ${M2_SETTINGS}"
}
}
}
}
stage('Quality Gate') {
steps {
script {
timeout(time: 1, unit: 'HOURS') { // Just in case something
goes wrong, pipeline will be killed after a timeout
def qg = waitForQualityGate()
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: $
{qg.status}"
}
}
}
}
}
stage('Artifact') {
steps {
script {
def pom = readMavenPom file: 'pom.xml'
println pom
}
}
}
stage('Deploy JBoss') {
steps {
// ansible-playbook -i hosts install-jboss.yml
// sh """
// scp -o StrictHostKeyChecking=no target/spring-petclinic-
rest-2.4.2.war root@147.182.135.249:/root
// ssh root@147.182.135.249 '~/jboss-eap-7.4/bin/jboss-cli.sh
-c --command="undeploy spring-petclinic-rest-2.4.2.war"'
// ssh root@147.182.135.249 '~/jboss-eap-7.4/bin/jboss-cli.sh
-c --command="deploy /root/spring-petclinic-rest-2.4.2.war"'
// """
sh """
ansible-playbook -i hosts deploy-jboss.yml
"""
}
}
}
post {
always {
echo 'always'
archiveArtifacts artifacts: 'target/*.war', onlyIfSuccessful: true
deleteDir()
}
failure {
echo 'Job Fallo!!!'
}
}
}