-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
66 lines (65 loc) · 2.55 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
pipeline {
agent none
stages {
stage('Test') {
when {
anyOf {
branch 'development';
branch pattern: 'PR-\\d+', comparator: 'REGEXP'
}
}
agent {
docker {
image 'maven:3-adoptopenjdk-8'
args '-v $HOME/.m2:/root/.m2 --network docker-ci_default'
}
}
steps {
// sh 'mvn clean test sonar:sonar -Dsonar.host.url=http://sonarqube:9000/sonarqube -Dsonar.login=$SONAR_TOKEN'
sh 'mvn clean test'
}
}
stage('Build'){
when {
anyOf{
branch 'main';
branch pattern: 'iteration\\d+', comparator: 'REGEXP'
}
}
agent {
docker {
image 'maven:3-adoptopenjdk-8'
args '-v $HOME/.m2:/root/.m2 --network docker-ci_default'
}
}
steps {
sh 'mvn clean package'
}
// TODO: add pushing to a future de4a maven repo?
// TODO: add building a release on a tag and push to GitHub?
}
}
post {
failure {
node('master') {
script {
env.ORG=env.JOB_NAME.split('/')[0]
env.REPO=env.JOB_NAME.split('/')[1]
env.BR=env.JOB_NAME.split('/')[2]
env.ERRORLOG = sh returnStdout: true, script: "cat ${env.JENKINS_HOME}/jobs/${env.ORG}/jobs/${env.REPO}/branches/${env.BR}/builds/${BUILD_NUMBER}/log | grep -B 1 -A 5 '\\[ERROR\\]'"
slackSend color: "danger", message: ":darth_maul: Build fail! :darth_maul:\nJob name: ${env.JOB_NAME}, Build number: ${env.BUILD_NUMBER}\nGit Author: ${env.CHANGE_AUTHOR}, Branch: ${env.GIT_BRANCH}, ${env.GIT_URL}\nMaven [ERROR] log below:\n ${env.ERRORLOG}"
}
}
}
success {
node('master') {
script {
if(currentBuild.getPreviousBuild() &&
currentBuild.getPreviousBuild().getResult().toString() != 'SUCCESS') {
slackSend color: "good", message: ":baby-yoda: This is the way! :baby-yoda: \nJob name: ${env.JOB_NAME}, Build number: ${env.BUILD_NUMBER}\nGit Author: ${env.CHANGE_AUTHOR}, Branch: ${env.GIT_BRANCH}, ${env.GIT_URL}\n"
}
}
}
}
}
}