forked from denji/homebrew-nginx
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
119 lines (108 loc) · 2.93 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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
def macos_versions = ["sierra", "el_capitan", "yosemite"]
def cleanup() {
sh 'rm -f *.bottle*.*'
}
def checkout() {
brew_bin = "/usr/local/bin"
brew_cellar = "/usr/local/Cellar"
brew_repo = "/usr/local/Homebrew"
brew_core_repo = "${brew_repo}/Library/Taps/homebrew/homebrew-core"
brew_tap_repo = "${brew_repo}/Library/Taps/homebrew/homebrew-nginx"
brew_test_bot_repo = "${brew_repo}/Library/Taps/homebrew/homebrew-test-bot"
sh "mkdir -p ${brew_bin} ${brew_cellar} ${brew_core_repo} ${brew_tap_repo} ${brew_test_bot_repo}"
dir(brew_repo) {
git url: 'https://github.com/Homebrew/brew.git', changelog: false
}
dir(brew_core_repo) {
git url: 'https://github.com/Homebrew/homebrew-core.git', changelog: false
}
dir(brew_test_bot_repo) {
git url: 'https://github.com/Homebrew/homebrew-test-bot.git', changelog: false
}
sh "ln -sf ${brew_repo}/bin/brew ${brew_bin}/brew"
dir(brew_tap_repo) {
checkout scm
}
}
def test_bot(args) {
timeout(time: 5, unit: 'HOURS') {
withEnv(["PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",
'HOMEBREW_DEVELOPER=1']) {
sh "brew test-bot --tap=homebrew/nginx ${args}"
}
}
}
def test() {
test_bot("--ci-auto")
}
def archive(stash_name) {
def test_bot_junit = 'brew-test-bot.xml'
if (fileExists(test_bot_junit)) {
junit test_bot_junit
}
def bottle_glob = '*.bottle*.*'
if (findFiles(glob: bottle_glob).length >= 1) {
stash includes: bottle_glob, name: stash_name
}
}
def build(stash_name) {
cleanup()
checkout()
try {
test()
}
catch (err) {
currentBuild.result = "FAILURE"
}
finally {
archive(stash_name)
cleanup()
}
}
try {
stage("Build") {
// TODO: figure out how to use macos_versions here.
parallel (
sierra: { node("sierra") { build("sierra") }},
el_capitan: { node("el_capitan") { build("el_capitan") }},
yosemite: { node("yosemite") { build("yosemite") }},
)
}
stage("Upload") {
node("master") {
cleanup()
checkout()
stash_passed = false
try {
for (version in macos_versions) {
unstash version
}
stash_passed = true
}
catch (err) {
stash_passed = false
}
if (stash_passed) {
try {
withCredentials([[
$class: 'UsernamePasswordMultiBinding',
credentialsId: '5b6903a9-9f39-4c1b-9de6-ba0dd99c82a0',
passwordVariable: 'BINTRAY_KEY', usernameVariable: 'BINTRAY_USER']]) {
test_bot("--ci-upload")
}
}
finally {
cleanup()
}
}
}
}
}
catch (err) {
// TODO: decide who to email and when
// mail to: '',
// from: 'Brew Test Bot <[email protected]>',
// subject: "${env.JOB_NAME} ${env.BUILD_DISPLAY_NAME} failed!",
// body: "Build: ${env.BUILD_URL}\nConsole: ${env.BUILD_URL}console\nTests: ${env.BUILD_URL}testReport/"
throw err
}