@@ -43,14 +43,16 @@ pipeline {
4343
4444 parallel {
4545
46- stage(" Unit Test" ) {
46+ stage(" Test & SonarScanner " ) {
4747 agent { docker {
4848 image " ${ env.MAVEN_IMAGE} "
4949 args " -v maven-cache:/root/.m2"
5050 reuseNode true
5151 }}
5252 steps {
53- sh ' mvn -B clean test'
53+ withSonarQubeEnv(' ces-sonar' ) {
54+ sh " mvn -B clean verify sonar:sonar -Dsonar.projectKey=gitops-playground -Dsonar.branch.name=${ BRANCH_NAME} "
55+ }
5456 }
5557 post {
5658 always {
@@ -63,7 +65,7 @@ pipeline {
6365 stage(" Build Image" ) {
6466 steps {
6567 script {
66- def buildArgs = " --no-cache " +
68+ def buildArgs = (params . noCache ? " --no-cache " : " " ) +
6769 " --build-arg BUILD_DATE='${ env.BUILD_DATE} ' " +
6870 " --build-arg VCS_REF='${ env.GIT_COMMIT} ' "
6971 docker. build(env. FULL_IMAGE_TAG , " ${ buildArgs} ." )
@@ -73,19 +75,6 @@ pipeline {
7375 }
7476 }
7577
76- stage(" SonarScanner" ) {
77- agent { docker {
78- image " ${ env.MAVEN_IMAGE} "
79- args " -v maven-cache:/root/.m2"
80- reuseNode true
81- }}
82- steps {
83- withSonarQubeEnv(' ces-sonar' ) {
84- sh " mvn clean verify sonar:sonar -Dsonar.projectKey=gitops-playground -Dsonar.branch.name=${ BRANCH_NAME} "
85- }
86- }
87- }
88-
8978 stage(' Security & Integration' ) {
9079
9180 parallel {
@@ -113,9 +102,8 @@ pipeline {
113102 steps {
114103 script {
115104 def profiles = []
116- def isTriggeredByTimer = currentBuild. getBuildCauses(' hudson.triggers.TimerTrigger$TimerTriggerCause' ). size() > 0
117105
118- if (isTriggeredByTimer || params. chooseProfile == ' all-profiles' || env. BRANCH_NAME == ' main' ) {
106+ if (isTriggeredByTimer() || params. chooseProfile == ' all-profiles' || env. BRANCH_NAME == ' main' ) {
119107 profiles = [' minimal' , ' full' , ' full-prefix' , ' content-examples' , ' operator-full' ,' operator-mandants' ]
120108 } else if (env. BRANCH_NAME == ' develop' ) {
121109 profiles = [' full-prefix' , ' operator-mandants' , ' operator-full' ]
@@ -242,16 +230,37 @@ pipeline {
242230 }
243231
244232 post {
233+ always {
234+ script {
235+ if (isTriggeredByTimer()) {
236+ currentBuild. displayName = " #${ env.BUILD_NUMBER} weekly"
237+ emailext(
238+ subject : " Weekly build ${ currentBuild.currentResult} : ${ env.JOB_NAME} #${ env.BUILD_NUMBER} " ,
239+ body : ' ${SCRIPT, template="groovy-html.template"}' ,
240+ mimeType : ' text/html' ,
241+ to : env. GOP_DEVELOPERS
242+ )
243+ }
244+ }
245+ }
245246 changed {
246- emailext(
247- subject : " ${ currentBuild.result} : ${ env.JOB_NAME} #${ env.BUILD_NUMBER} " ,
248- body : ' ${SCRIPT, template="groovy-html.template"}' ,
249- mimeType : ' text/html' ,
250- recipientProviders : [
251- [$class : ' DevelopersRecipientProvider' ],
252- [$class : ' RequesterRecipientProvider' ]
253- ]
254- )
247+ script {
248+ if (! isTriggeredByTimer()) {
249+ emailext(
250+ subject : " ${ currentBuild.result} : ${ env.JOB_NAME} #${ env.BUILD_NUMBER} " ,
251+ body : ' ${SCRIPT, template="groovy-html.template"}' ,
252+ mimeType : ' text/html' ,
253+ recipientProviders : [
254+ [$class : ' DevelopersRecipientProvider' ],
255+ [$class : ' RequesterRecipientProvider' ]
256+ ]
257+ )
258+ }
259+ }
255260 }
256261 }
257262}
263+
264+ boolean isTriggeredByTimer () {
265+ return ! currentBuild. getBuildCauses(' hudson.triggers.TimerTrigger$TimerTriggerCause' ). isEmpty()
266+ }
0 commit comments