1
1
#! /usr/bin/env groovy
2
- @NonCPS
3
- private def get_matching_jobs (pattern ) {
4
- def jobs = []
5
- for (job in Jenkins . getInstance(). getAllItems(Job )) {
6
- def jobname = job. getName()
7
- def m = jobname =~ pattern
8
- if (m) {
9
- def shortname = m[0 ][1 ]
10
- jobs. push([shortname, jobname])
11
- }
12
- }
13
- return jobs
14
- }
15
-
16
2
private def basename (path ) {
17
3
return path. drop(path. lastIndexOf(' /' ) + 1 )
18
4
}
19
5
20
- private def relay_steps (job_pattern , artifact_url , last_good_properties_url ) {
6
+ private def relay_steps (joblist , artifact_url , last_good_properties_url ) {
21
7
// The upstream jobs triggering the relay produce a
22
8
// "last_good_build.properties" file that contains a reference to the
23
9
// compiler artifact that should be used for this run and which llvm
24
10
// revision it is based on.
25
- propfile = basename(last_good_properties_url)
26
- sh """
27
- rm -f ${ propfile}
28
- curl -fksSO "${ last_good_properties_url} "
29
- """
11
+ // Ensure you have the AWS CLI on path before triggering the relay
12
+ withCredentials([string(credentialsId : ' s3_resource_bucket' , variable : ' S3_BUCKET' )]) {
13
+ propfile = basename(last_good_properties_url)
14
+ sh """
15
+ rm -f ${ propfile}
16
+ aws s3 cp $S3_BUCKET /clangci/${ last_good_properties_url} ${ propfile}
17
+ """
18
+ }
19
+
30
20
def props = readProperties file : propfile
31
- def artifact = " http://green-dragon-21.local/artifacts/ ${ props.ARTIFACT} "
21
+ def artifact = props. ARTIFACT
32
22
currentBuild. setDisplayName(" ${ props.GIT_DISTANCE} -${ props.GIT_SHA} " )
33
23
34
- // Trigger all jobs with names matching the `job_pattern` regex.
35
- def joblist = get_matching_jobs(job_pattern)
24
+ // Trigger all jobs within the provided list
36
25
def parallel_builds = [:]
37
26
for (j in joblist) {
38
- def shortname = j[0 ]
39
- def jobname = j[1 ]
40
- parallel_builds[shortname] = {
27
+ def jobname = j
28
+ parallel_builds[jobname] = {
41
29
def job_params = [
42
30
[$class : ' StringParameterValue' ,
43
31
name : ' ARTIFACT' ,
@@ -49,28 +37,39 @@ curl -fksSO "${last_good_properties_url}"
49
37
name : ' GIT_DISTANCE' ,
50
38
value : props. GIT_DISTANCE ],
51
39
]
52
- build job : jobname, parameters : job_params
40
+ build job : jobname, parameters : job_params, propagate : false
53
41
}
54
42
}
55
- parallel parallel_builds
56
- }
57
43
58
- def pipeline ( job_pattern ,
59
- artifact_url = ' http://green-dragon-21.local/artifacts/ ' ,
60
- last_good_properties_url = ' http://green-dragon-21.local/artifacts/clang-stage1-RA/last_good_build.properties ' ) {
61
- node( ' master ' ) {
62
- stage( ' main ' ) {
63
- relay_steps job_pattern, artifact_url, last_good_properties_url
64
- }
44
+ // Workaround to prevent LNT jobs from running in parallel and overloading the LNT server with submissions
45
+ if (joblist . any { it . contains( " lnt-ctmark " ) }) {
46
+ for (j in joblist ) {
47
+ parallel_builds[j] . call()
48
+ }
49
+ } else {
50
+ parallel parallel_builds
65
51
}
66
52
}
67
53
68
- def lldb_pipeline ( job_pattern ,
69
- artifact_url = ' http://green-dragon-21.local/artifacts/ ' ,
70
- last_good_properties_url = ' http://green-dragon-21.local/artifacts/lldb-cmake /last_good_build.properties' ) {
71
- node(' master ' ) {
54
+ def pipeline ( joblist ,
55
+ artifact_url = ' llvm.org/clang-stage1-RA/latest ' ,
56
+ last_good_properties_url = ' llvm.org/clang-stage1-RA /last_good_build.properties' ) {
57
+ node(label : ' macos-x86_64 ' ) {
72
58
stage(' main' ) {
73
- relay_steps job_pattern, artifact_url, last_good_properties_url
59
+ // Download aws CLI used to gather artifacts
60
+ sh """
61
+ rm -rf venv
62
+ python3 -m venv venv
63
+ set +u
64
+ source ./venv/bin/activate
65
+ pip install awscli
66
+ set -u
67
+ """
68
+ withEnv([
69
+ " PATH=$PATH :$WORKSPACE /venv/bin:/usr/bin:/usr/local/bin"
70
+ ]) {
71
+ relay_steps joblist, artifact_url, last_good_properties_url
72
+ }
74
73
}
75
74
}
76
75
}
0 commit comments