|
1 | 1 | // vars/notifyBrokenBranch.groovy
|
| 2 | +/* groovylint-disable VariableName */ |
2 | 3 |
|
3 | 4 | /**
|
4 | 5 | * notifyBrokenBranch.groovy
|
|
12 | 13 |
|
13 | 14 | def call(Map config = [:]) {
|
14 | 15 |
|
| 16 | + String branches |
15 | 17 | if (config['branches']) {
|
16 | 18 | branches = config['branches'].split()
|
17 | 19 | } else {
|
18 | 20 | branches = ["master"]
|
19 | 21 | }
|
20 | 22 |
|
21 |
| - if (!branches.contains(env.GIT_BRANCH)) { |
| 23 | + // Needed this as a work around that env['GIT_BRANCH'] is blacklisted |
| 24 | + // inside of pipeline-lib |
| 25 | + String git_branch = env.GIT_BRANCH |
| 26 | + |
| 27 | + if (!branches.contains(git_branch)) { |
22 | 28 | return
|
23 | 29 | }
|
24 | 30 |
|
25 |
| - emailextDaos body: env.GIT_BRANCH + ' is broken and you are one of the people\n' + |
| 31 | + emailextDaos body: git_branch + ' is broken and you are one of the people\n' + |
26 | 32 | 'who have committed to it since it was last successful. Please\n' +
|
27 |
| - 'investigate if your recent patch(es) to ' + env.GIT_BRANCH + '\n' + |
| 33 | + 'investigate if your recent patch(es) to ' + git_branch + '\n' + |
28 | 34 | 'are responsible for breaking it.\n\n' +
|
29 | 35 | 'See ' + env.BUILD_URL + ' for more details.',
|
30 | 36 | recipientProviders: [
|
31 | 37 | [$class: 'DevelopersRecipientProvider'],
|
32 | 38 | [$class: 'RequesterRecipientProvider']
|
33 | 39 | ],
|
34 |
| - subject: 'Build broken on ' + env.GIT_BRANCH, |
| 40 | + subject: 'Build broken on ' + git_branch, |
35 | 41 | onPR: config['onPR']
|
36 | 42 |
|
37 |
| - def branch = env['GIT_BRANCH'].toUpperCase().replaceAll("-", "_") |
38 |
| - def watchers = env["DAOS_STACK_${branch}_WATCHER"] |
39 |
| - |
40 |
| - if (watchers != "null") { |
41 |
| - emailextDaos body: env.GIT_BRANCH + ' is broken.\n\n' + |
42 |
| - 'See ' + env.BUILD_URL + ' for more details.', |
43 |
| - to: watchers, |
44 |
| - subject: 'Build broken on ' + env.GIT_BRANCH, |
45 |
| - onPR: config['onPR'] |
| 43 | + String branch = git_branch.toUpperCase().replaceAll("-", "_") |
| 44 | + // This will need to be implemented in trusted-pipe-line lib eventually |
| 45 | + // as checking if environment variables exist is blacklisted in the |
| 46 | + // groovy sandbox. |
| 47 | + // for now we only have DAOS_STACK_MASTER_WATCHER |
| 48 | + // def watchers = env["DAOS_STACK_${branch}_WATCHER"] |
| 49 | + if (branch == 'MASTER') { |
| 50 | + String watchers = env.DAOS_STACK_MASTER_WATCHER |
| 51 | + if (watchers != "null") { |
| 52 | + emailextDaos body: git_branch + ' is broken.\n\n' + |
| 53 | + 'See ' + env.BUILD_URL + ' for more details.', |
| 54 | + to: watchers, |
| 55 | + subject: 'Build broken on ' + git_branch, |
| 56 | + onPR: config['onPR'] |
| 57 | + } |
46 | 58 | }
|
47 |
| - |
48 | 59 | }
|
0 commit comments