forked from SUSE/susemanager-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile_prs_check
100 lines (91 loc) · 3.73 KB
/
Jenkinsfile_prs_check
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
92
93
94
95
96
97
98
99
100
#!/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')
}
environment {
repository = 'SUSE/spacewalk'
gitarro_cmd = 'gitarro.ruby2.5'
gitarro_local = 'ruby gitarro.rb'
check = " -r ${repository} -t placeholder --check --changed_since 172800"
}
agent { label 'suse-manager-unit-tests' }
triggers {
cron('H/10 * * * *')
}
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://[email protected]/openSUSE/gitarro"]]])
}
}
}
}
stage('Trigger pending tests') {
steps {
echo "Trigger pending tests"
script {
contexts = [
'changelog_test' : 'notype',
'java_lint_checkstyle' : 'java/',
'java_pgsql_tests' : 'java/',
'spacecmd_unittests': 'spacecmd/',
'ruby_rubocop' : 'testsuite/',
'backend_unittests_pgsql' : 'python/',
'javascript_lint' : 'web/',
'schema_migration_test_pgsql' : 'schema/spacewalk',
'susemanager_unittests' : 'susemanager/'
]
contexts.each { context, filter ->
commands = "${gitarro_cmd} ${check} -c ${context} -f ${filter}"
if (params.GITARRO_PR_NUMBER != '') {
commands = "${gitarro_local} ${check} -c ${context} -f ${filter}"
}
PENDING = sh(
script: "${commands}",
returnStdout: true
).trim()
echo PENDING
if (PENDING.contains('TESTREQUIRED=true')) {
PR_NUMBER = sh(script: "grep 'PR_NUMBER:' ${env.WORKSPACE}/.gitarro_vars | cut -d ':' -f2", returnStdout: true).trim()
build(
job: "manager-prs-${context}-pipeline",
parameters: [
[$class: 'StringParameterValue', name: 'GITARRO_PR_NUMBER', value: params.GITARRO_PR_NUMBER],
[$class: 'StringParameterValue', name: 'PR_NUMBER', value: PR_NUMBER]
],
wait: false
)
}
}
}
}
}
}
post {
success{
script {
if (params.cleanWorkspace == true) {
echo 'Clean up current workspace, when job success.'
cleanWs()
}
}
}
}
}