jenkins: retry pc setup (#30659)

* retry pc setup

* sleep and retry

* exception

* throw e

* remove force exit

* make a function for it

* remove force exit

* move to top

* separate exception
pull/30707/head
Justin Newberry 1 year ago committed by GitHub
parent c066fdd7a3
commit 93cd19e3a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      Jenkinsfile

14
Jenkinsfile vendored

@ -1,3 +1,15 @@
def retryWithDelay(int maxRetries, int delay, Closure body) {
for (int i = 0; i < maxRetries; i++) {
try {
body()
return
} catch (Exception e) {
sleep(delay)
}
}
throw Exception("Failed after ${maxRetries} retries")
}
def device(String ip, String step_label, String cmd) { def device(String ip, String step_label, String cmd) {
withCredentials([file(credentialsId: 'id_rsa', variable: 'key_file')]) { withCredentials([file(credentialsId: 'id_rsa', variable: 'key_file')]) {
def ssh_cmd = """ def ssh_cmd = """
@ -92,9 +104,11 @@ def pcStage(String stageName, Closure body) {
docker.build("openpilot-base:build-${env.GIT_COMMIT}", "-f Dockerfile.openpilot_base .").inside(dockerArgs) { docker.build("openpilot-base:build-${env.GIT_COMMIT}", "-f Dockerfile.openpilot_base .").inside(dockerArgs) {
timeout(time: 20, unit: 'MINUTES') { timeout(time: 20, unit: 'MINUTES') {
try { try {
retryWithDelay (3, 15) {
sh "git config --global --add safe.directory '*'" sh "git config --global --add safe.directory '*'"
sh "git submodule update --init --recursive" sh "git submodule update --init --recursive"
sh "git lfs pull" sh "git lfs pull"
}
body() body()
} finally { } finally {
sh "rm -rf ${env.WORKSPACE}/* || true" sh "rm -rf ${env.WORKSPACE}/* || true"

Loading…
Cancel
Save