Skip to content
Snippets Groups Projects

Jenkinsfile minor fix

Merged Johannes Visintini requested to merge jenkinsfile-minor-fix into master
+ 32
26
@@ -2,18 +2,18 @@ pipeline {
agent {label 'main'}
environment {
REPO_NAME = sh(returnStdout: true, script: 'basename `git remote get-url origin` .git').trim()
VERSION = sh(returnStdout: true, script: 'mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -Ev "(^\\[|Download\\w+)"').trim()
LATEST_AUTHOR = sh(returnStdout: true, script: 'git show -s --pretty=%an').trim()
REPO_NAME = sh(returnStdout: true, script: 'basename `git remote get-url origin` .git').trim()
LATEST_COMMIT_ID = sh(returnStdout: true, script: 'git describe --tags --long --always').trim()
DEFAULT_BRANCH = 'master'
MAVEN_TEST_OPTIONS = ' '
INFER_BRANCH_REGEX = /(^master$)/
SNAPSHOT_BRANCH_REGEX = /(^master$)/
RELEASE_REGEX = /^([0-9]+(\.[0-9]+)*)(-(RC|beta-|alpha-)[0-9]+)?$/
DEFAULT_BRANCH_REGEX = "/(^master$)/"
RELEASE_DEPLOY = false
SNAPSHOT_DEPLOY = false
MULTI_MODULE = false
}
stages {
@@ -22,8 +22,8 @@ pipeline {
script {
env.MAVEN_HOME = '/usr/share/maven'
echo LATEST_AUTHOR
echo REPO_NAME
echo LATEST_AUTHOR
echo LATEST_COMMIT_ID
echo env.BRANCH_NAME
@@ -51,7 +51,7 @@ pipeline {
}
post {
failure {
rocketSend channel: 'jenkinsohsome', emoji: ':sob:' , message: "${REPO_NAME}-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${LATEST_AUTHOR}. Review the code!" , rawMessage: true
rocketSend channel: 'jenkinsohsome', emoji: ':sob:' , message: "*${REPO_NAME}*-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${LATEST_AUTHOR}. Review the code!" , rawMessage: true
}
}
}
@@ -59,7 +59,7 @@ pipeline {
stage ('Deploy Snapshot') {
when {
expression {
return env.BRANCH_NAME ==~ DEFAULT_BRANCH_REGEX && VERSION ==~ /.*-SNAPSHOT$/
return env.BRANCH_NAME ==~ SNAPSHOT_BRANCH_REGEX && VERSION ==~ /.*-SNAPSHOT$/
}
}
steps {
@@ -71,7 +71,7 @@ pipeline {
}
post {
failure {
rocketSend channel: 'jenkinsohsome', message: "Deployment of ${REPO_NAME}-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${LATEST_AUTHOR}. Is Artifactory running?" , rawMessage: true
rocketSend channel: 'jenkinsohsome', emoji: ':disappointed:', message: "Deployment of *${REPO_NAME}*-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${LATEST_AUTHOR}. Is Artifactory running?" , rawMessage: true
}
}
}
@@ -98,7 +98,7 @@ pipeline {
}
post {
failure {
rocketSend channel: 'jenkinsohsome', message: "Deployment of ${REPO_NAME}-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${LATEST_AUTHOR}. Is Artifactory running?" , rawMessage: true
rocketSend channel: 'jenkinsohsome', emoji: ':disappointed:', message: "Deployment of *${REPO_NAME}*-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${LATEST_AUTHOR}. Is Artifactory running?" , rawMessage: true
}
}
}
@@ -126,7 +126,7 @@ pipeline {
}
post {
failure {
rocketSend channel: 'jenkinsohsome', message: "Deployment of javadoc ${REPO_NAME}-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${LATEST_AUTHOR}." , rawMessage: true
rocketSend channel: 'jenkinsohsome', emoji: ':disappointed:', message: "Deployment of javadoc *${REPO_NAME}*-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${LATEST_AUTHOR}." , rawMessage: true
}
}
}
@@ -134,21 +134,27 @@ pipeline {
stage ('Reports and Statistics') {
steps {
script {
report_basedir = "/srv/reports/${REPO_NAME}/${VERSION}_${env.BRANCH_NAME}/${env.BUILD_NUMBER}_${LATEST_COMMIT_ID}"
target_prefix = ''
if (MULTI_MODULE) {
target_prefix = '**/'
}
// jacoco
report_dir = "/srv/reports/" + REPO_NAME + "/" + VERSION + "_" + env.BRANCH_NAME + "/" + env.BUILD_NUMBER + "_" + LATEST_COMMIT_ID + "/jacoco/"
report_dir = report_basedir + "/jacoco/"
rtMaven.run pom: 'pom.xml', goals: 'clean verify -Pjacoco -Dmaven.repo.local=.m2 $MAVEN_TEST_OPTIONS'
jacoco(
execPattern : 'target/jacoco.exec',
classPattern : 'target/classes',
sourcePattern : 'src/main/java',
execPattern : target_prefix + 'target/jacoco.exec',
classPattern : target_prefix + 'target/classes',
sourcePattern : target_prefix + 'src/main/java',
inclusionPattern : '/org/heigit/**'
)
sh "mkdir -p ${report_dir} && rm -Rf ${report_dir}* && find . -path '*/target/site/jacoco' -exec cp -R --parents {} ${report_dir} \\; && find ${report_dir} -path '*/target/site/jacoco' | while read line; do echo \$line; neu=\${line/target\\/site\\/jacoco/} ; mv \$line/* \$neu ; done && find ${report_dir} -type d -empty -delete"
// infer
if (env.BRANCH_NAME ==~ DEFAULT_BRANCH_REGEX) {
report_dir = "/srv/reports/" + REPO_NAME + "/" + VERSION + "_" + env.BRANCH_NAME + "/" + env.BUILD_NUMBER + "_" + LATEST_COMMIT_ID + "/infer/"
if (env.BRANCH_NAME ==~ INFER_BRANCH_REGEX) {
report_dir = report_basedir + "/infer/"
sh "mvn clean"
sh "infer run --pmd-xml -r -- mvn compile"
sh "mkdir -p ${report_dir} && rm -Rf ${report_dir}* && cp -R ./infer-out/* ${report_dir}"
@@ -160,14 +166,14 @@ pipeline {
recordIssues enabledForFailure: true, tools: [mavenConsole(), java(), javaDoc()]
recordIssues enabledForFailure: true, tool: checkStyle()
recordIssues enabledForFailure: true, tool: spotBugs()
recordIssues enabledForFailure: true, tool: cpd(pattern: '**/target/cpd.xml')
recordIssues enabledForFailure: true, tool: pmdParser(pattern: '**/target/pmd.xml')
recordIssues enabledForFailure: true, tool: pmdParser(pattern: '**/infer-out/report.xml', id: 'infer')
recordIssues enabledForFailure: true, tool: cpd(pattern: target_prefix + 'target/cpd.xml')
recordIssues enabledForFailure: true, tool: pmdParser(pattern: target_prefix + 'target/pmd.xml')
recordIssues enabledForFailure: true, tool: pmdParser(pattern: 'infer-out/report.xml', id: 'infer')
}
}
post {
failure {
rocketSend channel: 'jenkinsohsome', message: "Reporting of ${REPO_NAME}-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${LATEST_AUTHOR}." , rawMessage: true
rocketSend channel: 'jenkinsohsome', emoji: ':disappointed:', message: "Reporting of *${REPO_NAME}*-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${LATEST_AUTHOR}." , rawMessage: true
}
}
}
@@ -190,11 +196,11 @@ pipeline {
update_notify = sh(returnStdout: true, script: 'mvn versions:display-dependency-updates | grep -Pzo "(?s)The following dependencies.*\\n.* \\n"').trim()
echo update_notify
}
rocketSend channel: 'jenkinsohsome', emoji: ':wave:' , message: "Check your dependencies in ${REPO_NAME}. You might have updates: ${update_notify}" , rawMessage: true
rocketSend channel: 'jenkinsohsome', emoji: ':wave:' , message: "Check your dependencies in *${REPO_NAME}*. You might have updates: ${update_notify}" , rawMessage: true
}
post {
failure {
rocketSend channel: 'jenkinsohsome', emoji: ':disappointed:' , message: "Checking for updates in ${REPO_NAME}-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${LATEST_AUTHOR}." , rawMessage: true
rocketSend channel: 'jenkinsohsome', emoji: ':disappointed:' , message: "Checking for updates in *${REPO_NAME}*-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${LATEST_AUTHOR}." , rawMessage: true
}
}
}
@@ -213,11 +219,11 @@ pipeline {
}
}
steps {
rocketSend channel: 'jenkinsohsome', message: "Hey, this is just your daily notice that Jenkins is still working for you on ${REPO_NAME} Branch ${env.BRANCH_NAME}! Happy and for free! Keep it up!" , rawMessage: true
rocketSend channel: 'jenkinsohsome', emoji: ':wink:', message: "Hey, this is just your daily notice that Jenkins is still working for you on *${REPO_NAME}* Branch ${env.BRANCH_NAME}! Happy and for free! Keep it up!" , rawMessage: true
}
post {
failure {
rocketSend channel: 'jenkinsohsome', emoji: ':wink:' , message: "Reporting of ${REPO_NAME}-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${LATEST_AUTHOR}." , rawMessage: true
rocketSend channel: 'jenkinsohsome', emoji: ':disappointed:', message: "Reporting of *${REPO_NAME}*-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${LATEST_AUTHOR}." , rawMessage: true
}
}
}
@@ -229,11 +235,11 @@ pipeline {
}
}
steps {
rocketSend channel: 'jenkinsohsome', message: "We had some problems, but we are BACK TO NORMAL! Nice debugging: ${REPO_NAME}-build-nr. ${env.BUILD_NUMBER} *succeeded* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${LATEST_AUTHOR}." , rawMessage: true
rocketSend channel: 'jenkinsohsome', emoji: ':sunglasses:', message: "We had some problems, but we are BACK TO NORMAL! Nice debugging: *${REPO_NAME}*-build-nr. ${env.BUILD_NUMBER} *succeeded* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${LATEST_AUTHOR}." , rawMessage: true
}
post {
failure {
rocketSend channel: 'jenkinsohsome', message: "Reporting of ${REPO_NAME}-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${LATEST_AUTHOR}." , rawMessage: true
rocketSend channel: 'jenkinsohsome', emoji: ':disappointed:', message: "Reporting of *${REPO_NAME}*-build nr. ${env.BUILD_NUMBER} *failed* on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${LATEST_AUTHOR}." , rawMessage: true
}
}
}
Loading