-
Notifications
You must be signed in to change notification settings - Fork 11
/
mvn-pipeline
64 lines (58 loc) · 2.29 KB
/
mvn-pipeline
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
pipeline {
agent any
options {
buildDiscarder(logRotator(numToKeepStr: '10', artifactNumToKeepStr: '2'))
}
parameters {
string(name: 'JAVA_HOME', defaultValue: '/opt/oracle/java/', description: 'Java home')
string(name: 'MAVEN_HOME', defaultValue: '/opt/tools/apache-maven-3.6.3', description: 'Maven home')
string(name: 'CRON_PATTERN', defaultValue: 'H/5 * * * *', description: 'cron pattern to trigger the job')
string(name: 'POLL_PATTERN', defaultValue: 'H/5 * * * *', description: 'cron pattern to poll the SCM')
}
environment {
HERA_HOSTNAME = 'olympus'
}
stages {
stage('Prep') {
steps {
//cleanWs()
dir('hera') {
git 'https://github.com/jboss-set/hera.git'
}
timeout(time: 10) {
script {
// warning, GIT_BRANCH var alreads points to pipeline's branch
if ( env.GIT_REPOSITORY_BRANCH == null || "".equals("${env.GIT_REPOSITORY_BRANCH}") ) {
env.GIT_REPOSITORY_BRANCH = "master"
}
echo "GIT_REPOSITORY_BRANCH:[${env.GIT_REPOSITORY_BRANCH}]"
// Start container
env.BUILD_SCRIPT = "${env.WORKSPACE}/hera/mvn-wrapper.sh"
git url: "${env.GIT_REPOSITORY_URL}",
branch: "${env.GIT_REPOSITORY_BRANCH}"
sh label: '', script: "${env.WORKSPACE}/hera/hera.sh run"
}
}
}
}
stage ('Build') {
steps {
sh label: '', script: "${env.WORKSPACE}/hera/hera.sh job"
archiveArtifacts artifacts: '**/*', fingerprint: true, followSymlinks: false, onlyIfSuccessful: true
junit allowEmptyResults: true, testResults: '**/target/surefire-reports/*.xml'
}
}
}
post {
always {
script {
try {
sh label: '', script: "${env.WORKSPACE}/hera/hera.sh stop"
} catch (err) {
echo "Error while deleting container: ${err}"
return err
}
}
}
}
}