Advertisement
Guest User

Untitled

a guest
Apr 9th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.88 KB | None | 0 0
  1. pipeline {
  2.   agent {
  3.       docker {
  4.           label 'linux'
  5.           image 'maven:3.6.0-jdk-8-alpine'
  6.           args containerSettings()
  7.           reuseNode true
  8.       }
  9.   }
  10.   options {
  11.       timestamps()
  12.       buildDiscarder(logRotator(numToKeepStr: '5'))
  13.       timeout(time: 1, unit: 'HOURS')
  14.   }
  15.   stages {
  16.     stage('Build and Test') {
  17.        steps {
  18.          withMaven {
  19.             sh 'mvn clean install'
  20.             junit '**/surefire-reports/*.xml'
  21.          }
  22.        }
  23.     }
  24.     stage('Publish Artifacts') {
  25.       when {
  26.         anyOf {
  27.               branch 'master'
  28.               branch 'develop'
  29.             }
  30.         }
  31.         steps {
  32.           withMaven {
  33.             sh 'mvn deploy -DskipTests'
  34.           }
  35.         }
  36.       }
  37.       stage('Continuous SonarQube Analysis') {
  38.        when {
  39.           anyOf {
  40.                 branch 'master'
  41.                 branch 'develop'
  42.               }
  43.           }
  44.           steps {
  45.             withSonarQubeEnv('sonar-url') {
  46.               withMaven {
  47.                 sh "mvn org.owasp:dependency-check-maven:aggregate sonar:sonar ${persistedSonarAnalysisOptions()}"
  48.               }
  49.             }
  50.           }
  51.       }
  52.       stage('SonarQube-Reviewer') {
  53.           when {
  54.               anyOf {
  55.                   changeRequest()
  56.               }
  57.           }
  58.           steps {
  59.               withSonarQubeEnv('sonar-url') {
  60.                 withCredentials(sonarReviewer()) {
  61.                   withMaven {
  62.                      sh "mvn sonar:sonar ${passthroughSonarAnalysisOptions()}"
  63.                   }
  64.               }
  65.            }
  66.         }
  67.      }
  68.   }
  69.   post {
  70.     changed {
  71.       email isMainlineBranch() ? leadDeveloper() : nobody()
  72.     }
  73.     regression {
  74.       email isChangeRequest() ? committers() : nobody()
  75.     }
  76.     success {
  77.       email isChangeRequest() ? committers() : nobody()
  78.     }
  79.   }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement