Skip to content

Commit 1e792c7

Browse files
committed
Add a 3 hour timeout to individual builds
This was part of the old system, but we hadn't yet had the problems that require it resurface yet. The limit here is kind of arbitrary, but the specific value isn't as important as having one -- we had a build hang for 6d (due to some tool that doesn't have a timeout of its own but arguably should), and this prevents that from stalling our whole process.
1 parent 2523842 commit 1e792c7

File tree

1 file changed

+52
-50
lines changed

1 file changed

+52
-50
lines changed

Jenkinsfile.build

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -84,65 +84,67 @@ node('multiarch-' + env.BASHBREW_ARCH) { ansiColor('xterm') {
8484
return
8585
}
8686

87-
/*
88-
// TODO this is currently already done on the worker machines themselves, which is a tradeoff
89-
// make sure "docker login" is localized to this workspace
90-
env.DOCKER_CONFIG = workspace + '/.docker'
91-
dir(env.DOCKER_CONFIG) { deleteDir() }
92-
93-
withCredentials([usernamePassword(
94-
credentialsId: 'docker-hub-' + env.BASHBREW_ARCH, // TODO windows?
95-
usernameVariable: 'DOCKER_USERNAME',
96-
passwordVariable: 'DOCKER_PASSWORD',
97-
)]) {
98-
sh '''#!/usr/bin/env bash
99-
set -Eeuo pipefail
100-
docker login --username "$DOCKER_USERNAME" --password-stdin <<<"$DOCKER_PASSWORD"
101-
'''
102-
}
103-
*/
104-
105-
def buildEnvs = []
106-
stage('Prep') {
107-
if (obj.commands.build.contains(' buildx ')) {
108-
def json = sh(returnStdout: true, script: '''#!/usr/bin/env bash
109-
set -Eeuo pipefail -x
110-
111-
.doi/.bin/bashbrew-buildkit-env-setup.sh \\
112-
| jq 'to_entries | map(.key + "=" + .value)'
113-
''').trim()
114-
if (json) {
115-
buildEnvs += readJSON(text: json)
116-
}
87+
timeout(time: 3, unit: 'HOURS') {
88+
/*
89+
// TODO this is currently already done on the worker machines themselves, which is a tradeoff
90+
// make sure "docker login" is localized to this workspace
91+
env.DOCKER_CONFIG = workspace + '/.docker'
92+
dir(env.DOCKER_CONFIG) { deleteDir() }
93+
94+
withCredentials([usernamePassword(
95+
credentialsId: 'docker-hub-' + env.BASHBREW_ARCH, // TODO windows?
96+
usernameVariable: 'DOCKER_USERNAME',
97+
passwordVariable: 'DOCKER_PASSWORD',
98+
)]) {
99+
sh '''#!/usr/bin/env bash
100+
set -Eeuo pipefail
101+
docker login --username "$DOCKER_USERNAME" --password-stdin <<<"$DOCKER_PASSWORD"
102+
'''
117103
}
118-
}
119-
120-
withEnv(buildEnvs) {
121-
dir('build') {
122-
deleteDir()
104+
*/
123105

124-
stage('Pull') {
125-
sh """#!/usr/bin/env bash
106+
def buildEnvs = []
107+
stage('Prep') {
108+
if (obj.commands.build.contains(' buildx ')) {
109+
def json = sh(returnStdout: true, script: '''#!/usr/bin/env bash
126110
set -Eeuo pipefail -x
127111

128-
${ obj.commands.pull }
129-
"""
112+
.doi/.bin/bashbrew-buildkit-env-setup.sh \\
113+
| jq 'to_entries | map(.key + "=" + .value)'
114+
''').trim()
115+
if (json) {
116+
buildEnvs += readJSON(text: json)
117+
}
130118
}
119+
}
131120

132-
stage('Build') {
133-
sh """#!/usr/bin/env bash
134-
set -Eeuo pipefail -x
121+
withEnv(buildEnvs) {
122+
dir('build') {
123+
deleteDir()
135124

136-
${ obj.commands.build }
137-
"""
138-
}
125+
stage('Pull') {
126+
sh """#!/usr/bin/env bash
127+
set -Eeuo pipefail -x
139128

140-
stage('Push') {
141-
sh """#!/usr/bin/env bash
142-
set -Eeuo pipefail -x
129+
${ obj.commands.pull }
130+
"""
131+
}
132+
133+
stage('Build') {
134+
sh """#!/usr/bin/env bash
135+
set -Eeuo pipefail -x
136+
137+
${ obj.commands.build }
138+
"""
139+
}
140+
141+
stage('Push') {
142+
sh """#!/usr/bin/env bash
143+
set -Eeuo pipefail -x
143144

144-
${ obj.commands.push }
145-
"""
145+
${ obj.commands.push }
146+
"""
147+
}
146148
}
147149
}
148150
}

0 commit comments

Comments
 (0)