forked from SUSE/susemanager-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile_prs_changelog_test
91 lines (83 loc) · 3.64 KB
/
Jenkinsfile_prs_changelog_test
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env groovy
// Configure the build properties
properties([
buildDiscarder(logRotator(numToKeepStr: '500'))
])
pipeline {
options {
timeout(time: 30, unit: 'MINUTES')
}
parameters {
string(defaultValue: '', description: 'Gitarro PR', name: 'GITARRO_PR_NUMBER')
string(defaultValue: '', description: 'SUSE Manager PR', name: 'PR_NUMBER')
booleanParam(defaultValue: true, description: 'Clean up workspace after a successful execution.', name: 'cleanWorkspace')
}
environment {
repository = "SUSE/spacewalk"
gitarro_cmd = 'gitarro.ruby2.5'
gitarro_local = 'ruby gitarro.rb'
gitarro_changelog_test = "-r ${repository}" +
" -c changelog_test -d \"test if changelog was updated\" " +
" -t /var/lib/jenkins/bin/changelog.rb " +
" -u ${env.BUILD_URL}" +
" -g \"${env.WORKSPACE}\" "
gitarro_enable_merging = "-r ${repository}" +
" --force_test -c merge_enabled -d \"Merging enabled (requires changelog_test passing)\" " +
" -u ${env.BUILD_URL}" +
" -g \"${env.WORKSPACE}\" "
}
// run only on specific hosts
agent { label 'suse-manager-unit-tests' }
stages {
stage('Clean Up Workspace') {
steps {
echo 'Clean up previous workspace'
cleanWs()
echo 'Check out SCM'
checkout scm
script {
if (params.GITARRO_PR_NUMBER != '') {
echo 'Check out Gitarro PR'
checkout([$class : 'GitSCM', branches: [[name: "FETCH_HEAD"]],
extensions : [[$class: 'LocalBranch']],
userRemoteConfigs: [[refspec: "+refs/pull/${params.GITARRO_PR_NUMBER}/head:refs/remotes/origin/PR-${params.GITARRO_PR_NUMBER}", url: "https://git@github.com/openSUSE/gitarro"]]])
}
}
}
}
stage('Run changelog test') {
steps {
echo 'Run changelog tests'
script {
gitarro_changelog_test_cmd = "${gitarro_cmd} ${gitarro_changelog_test}"
gitarro_enable_merging_cmd = "${gitarro_cmd} ${gitarro_enable_merging}"
if (params.GITARRO_PR_NUMBER != '') {
gitarro_changelog_test_cmd = "${gitarro_local} ${gitarro_changelog_test}"
gitarro_enable_merging_cmd = "${gitarro_local} ${gitarro_enable_merging}"
}
if (params.PR_NUMBER != '') {
gitarro_changelog_test_cmd = "${gitarro_changelog_test_cmd} -P ${params.PR_NUMBER}"
gitarro_enable_merging_cmd = "${gitarro_enable_merging_cmd} -P ${params.PR_NUMBER}"
currentBuild.displayName = "PR: ${params.PR_NUMBER}"
}
}
sh "set +e; export PRODUCT=SUSE-Manager; ${gitarro_changelog_test_cmd}; CLRET=\${?}; " +
"if [ \$CLRET -eq 0 ]; then " +
"${gitarro_enable_merging_cmd} -t /usr/bin/true; " +
"else ${gitarro_enable_merging_cmd} -t /usr/bin/false; " +
"fi; exit \$CLRET"
}
}
}
// postactions
post {
success {
script {
if (params.cleanWorkspace == true) {
echo 'Clean up current workspace, when job success.'
cleanWs()
}
}
}
}
}