forked from stackalytics/default_data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
57 lines (53 loc) · 1.18 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
def handleCheckout = {
if (env.ghprbPullId) {
echo "This is pull requet"
def credentialsId = scm.userRemoteConfigs[0].credentialsId
checkout ([
$class: 'GitSCM',
branches: [[name: sha1]],
userRemoteConfigs: [[url: env.ghprbAuthorRepoGitUrl, credentialsId: credentialsId, refspec: '+refs/pull/*:refs/remotes/origin/pr/*']],
extensions: [
[$class: 'PruneStaleBranch'],
[$class: 'CleanCheckout'],
[
$class: 'PreBuildMerge',
options: [
fastForwardMode: 'NO_FF',
mergeRemote: 'origin',
mergeTarget: env.ghprbTargetBranch
]
]
],
])
} else {
echo "No pull request detected. Checking out current brach"
checkout ([
$class: 'GitSCM',
branches: scm.branches,
userRemoteConfigs: scm.userRemoteConfigs,
extensions: [
[$class: 'PruneStaleBranch'],
[$class: 'CleanCheckout']
],
])
}
}
pipeline {
agent any
stages {
stage('checkout'){
steps {
script {
echo "1. Checkout step"
handleCheckout()
sh "cp Jenkinsfile /tmp"
}
}
}
stage('Build maven_base_pom if change') {
steps {
sh "env | sort"
}
}
}
}