|
| 1 | +properties properties: [ |
| 2 | + [$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '30', numToKeepStr: '10']], |
| 3 | + disableConcurrentBuilds() |
| 4 | +] |
| 5 | + |
| 6 | +@Library('mare-build-library') |
| 7 | +def git = new de.mare.ci.jenkins.Git() |
| 8 | + |
| 9 | +timeout(60) { |
| 10 | + node { |
| 11 | + def buildNumber = env.BUILD_NUMBER |
| 12 | + def branchName = env.BRANCH_NAME |
| 13 | + def workspace = env.WORKSPACE |
| 14 | + def buildUrl = env.BUILD_URL |
| 15 | + |
| 16 | + try { |
| 17 | + withEnv(["JAVA_HOME=${tool 'JDK8'}", "PATH+MAVEN=${tool 'Maven3'}/bin:${env.JAVA_HOME}/bin"]) { |
| 18 | + |
| 19 | + // PRINT ENVIRONMENT TO JOB |
| 20 | + echo "workspace directory is $workspace" |
| 21 | + echo "build URL is $buildUrl" |
| 22 | + echo "build Number is $buildNumber" |
| 23 | + echo "branch name is $branchName" |
| 24 | + echo "PATH is $env.PATH" |
| 25 | + |
| 26 | + stage('Checkout') { |
| 27 | + checkout scm |
| 28 | + } |
| 29 | + stage('Build') { |
| 30 | + sh "mvn package -DskipUnitTests=true" |
| 31 | + } |
| 32 | + |
| 33 | + stage('Unit-Tests') { |
| 34 | + sh "mvn test -Dmaven.test.failure.ignore" |
| 35 | + } |
| 36 | + |
| 37 | + stage('Integration-Tests') { |
| 38 | + // TODO add for OWASP ZAP version 2.7.0 |
| 39 | + } |
| 40 | + |
| 41 | + stage('Deploy') { |
| 42 | + if (git.isProductionBranch()) { |
| 43 | + sh "mvn -Prelease package source:jar gpg:sign install:install deploy:deploy" |
| 44 | + } else { |
| 45 | + sh "mvn deploy" |
| 46 | + } |
| 47 | + |
| 48 | + stage('Sonar') { |
| 49 | + sh "mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=hypery2k-github -Dsonar.login=${env['sonarcloud.io.token']}" |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | + archiveArtifacts artifacts: '*/target/*.jar' |
| 54 | + junit healthScaleFactor: 1.0, testResults: '*/target/surefire-reports/TEST*.xml' |
| 55 | + } |
| 56 | + } catch (e) { |
| 57 | + mail subject: "${env.JOB_NAME} (${env.BUILD_NUMBER}): Error on build", to: '[email protected]', body: "Please go to ${env.BUILD_URL}." |
| 58 | + throw e |
| 59 | + } |
| 60 | + } |
| 61 | +} |
0 commit comments