-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathJenkinsfile-aem-dispatcher-optimizer-push_pipeline
68 lines (63 loc) · 2.03 KB
/
Jenkinsfile-aem-dispatcher-optimizer-push_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
65
66
67
68
pipeline {
agent { label 'main' }
environment{
GITHUB_CLONE_URL = 'https://github.com/adobe/aem-dispatcher-optimizer-tool.git'
GITHUB_CLONE_ORG = 'adobe'
GITHUB_CLONE_REPO = 'aem-dispatcher-optimizer-tool'
GITHUB_CLONE_BRANCH = 'main'
EMAIL_ENABLED = true
EMAIL_RECIPIENTS = '[email protected]'
}
tools {
maven 'Maven 3.2.1'
jdk 'Latest Java'
}
stages{
stage("clean workspace") {
steps {
deleteDir()
}
}
//Stage: GitHub Integration
stage('Clone sources') {
steps{
script{
def gitbranch = "${env.GITHUB_CLONE_BRANCH}"
if (!env.GITHUB_CLONE_BRANCH) {
gitbranch = "${env.GIT_BRANCH}"
}else{
//to handle issue with origin/BRANCH_NAME
def gitbranchOriginSplit = gitbranch.split('origin/')
def gitbranchOriginSplitLength = gitbranchOriginSplit.size()
gitbranch = gitbranchOriginSplitLength > 1 ? gitbranchOriginSplit[1] : gitbranch
}
print "git branch is ${gitbranch}"
git credentialsId: "${env.GITHUB_CLONE_CREDENTIALS}", url: "${env.GITHUB_CLONE_URL}", branch: "${gitbranch}"
}
}
}
//Stage: Maven Integration
stage('Maven build') {
steps{
sh "mvn clean install"
}
}
}
post {
failure {
script {
currentBuild.result = 'FAILURE'
}
}
always {
script{
if(env.EMAIL_ENABLED.toBoolean()){
step([$class: 'Mailer',
notifyEveryUnstableBuild: true,
recipients: "${env.EMAIL_RECIPIENTS}",
sendToIndividuals: true])
}
}
}
}
}