|
| 1 | +/** |
| 2 | + Licensed to the Indoqa Software Design und Beratung GmbH (Indoqa) under |
| 3 | + one or more contributor license agreements. See the NOTICE file distributed |
| 4 | + with this work for additional information regarding copyright ownership. |
| 5 | + Indoqa licenses this file to You under the Apache License, Version 2.0 |
| 6 | + (the "License"); you may not use this file except in compliance with |
| 7 | + the License. You may obtain a copy of the License at |
| 8 | +
|
| 9 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +
|
| 11 | + Unless required by applicable law or agreed to in writing, software |
| 12 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + See the License for the specific language governing permissions and |
| 15 | + limitations under the License. |
| 16 | +**/ |
| 17 | +pipeline { |
| 18 | + |
| 19 | + agent any |
| 20 | + |
| 21 | + environment { |
| 22 | +MAVEN_BUILD_PROPERTIES='' |
| 23 | + } |
| 24 | + |
| 25 | + triggers { |
| 26 | + snapshotDependencies() |
| 27 | + parameterizedCron'15 23 * * * % DEPLOY_ARTIFACTS=true;RUN_SONAR=true;CRON=true' |
| 28 | + } |
| 29 | + |
| 30 | + tools { |
| 31 | + maven'Maven 3.5.x' |
| 32 | + } |
| 33 | + |
| 34 | + stages { |
| 35 | + stage('Build') { |
| 36 | + options { |
| 37 | + timeout(time:5,unit:'MINUTES') |
| 38 | + } |
| 39 | + steps { |
| 40 | + sh'mvn clean install -Ptest-coverage,indoqa-release ${MAVEN_BUILD_PROPERTIES}' |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + stage('SonarQube analysis') { |
| 45 | + when { |
| 46 | + environmentname:'RUN_SONAR',value:'true' |
| 47 | + } |
| 48 | + |
| 49 | + steps { |
| 50 | + withSonarQubeEnv('sonar') { |
| 51 | + sh'mvn -Ptest-coverage,indoqa-release sonar:sonar -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_AUTH_TOKEN -Dsonar.password=' |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + stage('Deploy to nexus') { |
| 57 | + when { |
| 58 | + environmentname:'DEPLOY_ARTIFACTS',value:'true' |
| 59 | + } |
| 60 | + |
| 61 | + steps { |
| 62 | + sh'mvn deploy ${MAVEN_BUILD_PROPERTIES}' |
| 63 | + } |
| 64 | + } |
| 65 | + } |
| 66 | + |
| 67 | + post { |
| 68 | + changed { |
| 69 | + echo"Changed to${currentBuild.result}" |
| 70 | + script { |
| 71 | +if(currentBuild.resultIsBetterOrEqualTo('SUCCESS')) { |
| 72 | + slackSendchannel:'#ci_oss',color:'#008000',tokenCredentialId:'Slack_IntegrationToken',message:"${env.JOB_NAME} has recovered at${env.BUILD_NUMBER} status:${currentBuild.currentResult} (<${env.BUILD_URL}|Open>)" |
| 73 | + } |
| 74 | +if(currentBuild.resultIsWorseOrEqualTo('FAILURE')) { |
| 75 | + slackSendchannel:'#ci_oss',color:'#800000',tokenCredentialId:'Slack_IntegrationToken',message:"${env.JOB_NAME} has failed at${env.BUILD_NUMBER} status:${currentBuild.currentResult} (<${env.BUILD_URL}|Open>)" |
| 76 | + } |
| 77 | + } |
| 78 | + } |
| 79 | + } |
| 80 | +} |
| 81 | + |