forked from openshift-eng/aos-cd-jobs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
66 lines (64 loc) · 1.63 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
properties(
[
disableConcurrentBuilds(),
disableResume(),
buildDiscarder(
logRotator(
artifactDaysToKeepStr: '60',
daysToKeepStr: '60')
),
]
)
// https://issues.jenkins-ci.org/browse/JENKINS-33511
def set_workspace() {
if(env.WORKSPACE == null) {
env.WORKSPACE = WORKSPACE = pwd()
}
}
node('openshift-build-1') {
try {
timeout(time: 30, unit: 'MINUTES') {
deleteDir()
set_workspace()
dir('aos-cd-jobs') {
stage('clone') {
checkout scm
sh 'git checkout master'
}
stage('run') {
final url = sh(
returnStdout: true,
script: 'git config remote.origin.url')
if(!(url =~ /^[-\w]+@[-\w]+(\.[-\w]+)*:/)) {
error('This job uses ssh keys for auth, please use an ssh url')
}
def prune = true, key = 'openshift-bot'
if(url.trim() != 'git@github.com:openshift-eng/aos-cd-jobs.git') {
prune = false
key = "${(url =~ /.*:([^\/]+)/)[0][1]}-aos-cd-bot"
}
sshagent([key]) {
sh """\
virtualenv ../env/ -p python3
. ../env/bin/activate
pip install gitpython
export GIT_PYTHON_TRACE=full
${prune ? 'python -m aos_cd_jobs.pruner' : 'echo Fork, skipping pruner'}
python -m aos_cd_jobs.updater
"""
}
}
}
}
} catch(err) {
mail(
to: 'jupierce@redhat.com',
from: "aos-cicd@redhat.com",
subject: 'aos-cd-jobs-branches job: error',
body: """\
Encountered an error while running the aos-cd-jobs-branches job: ${err}\n\n
Jenkins job: ${env.BUILD_URL}
""")
throw err
}
}