-
Notifications
You must be signed in to change notification settings - Fork 4
Speed up builds with less sleeps steps #376
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,10 +46,16 @@ def readSecret(secret) { | |
| def props = null | ||
| log(level: 'INFO', text: 'getVaultSecret: Getting secrets') | ||
| readSecretWrapper() { | ||
| retry(2) { | ||
| sleep randomNumber(min: 5, max: 10) | ||
| def token = getVaultToken(env.VAULT_ADDR, env.VAULT_ROLE_ID, env.VAULT_SECRET_ID) | ||
| props = getVaultSecretObject(env.VAULT_ADDR, secret, token) | ||
| retry(3) { | ||
|
||
| try { | ||
| def token = getVaultToken(env.VAULT_ADDR, env.VAULT_ROLE_ID, env.VAULT_SECRET_ID) | ||
| props = getVaultSecretObject(env.VAULT_ADDR, secret, token) | ||
| } catch(e) { | ||
| // When running in the CI with multiple parallel stages | ||
| // the access could be considered as a DDOS attack. Let's sleep a bit if it fails. | ||
| sleep randomNumber(min: 2, max: 5) | ||
| throw e | ||
| } | ||
| } | ||
| //we do not have permissions to revoke a token. | ||
| //revokeToken(env.VAULT_ADDR, token) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,11 @@ def call(params) { | |
| def retryWithSleep(int i, body) { | ||
| retry(i) { | ||
| log(level: 'DEBUG', text: "Let's git (${i} tries).") | ||
| sleep(20) | ||
| body() | ||
| try { | ||
|
||
| body() | ||
| } catch(e) { | ||
| sleep(20) | ||
|
||
| throw e | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,16 +27,17 @@ def call(Map params = [:], Closure body) { | |
| def path = params.containsKey('path') ? params.path : env.WORKSPACE | ||
| def tokenFile = params.containsKey('tokenFile') ? params.tokenFile : '.vault-token' | ||
| getVaultSecret.readSecretWrapper { | ||
| retry(2) { | ||
| sleep randomNumber(min: 5, max: 10) | ||
| retry(3) { | ||
| def token = getVaultSecret.getVaultToken(env.VAULT_ADDR, env.VAULT_ROLE_ID, env.VAULT_SECRET_ID) | ||
| dir(path) { | ||
| writeFile file: tokenFile, text: token | ||
| } | ||
| try { | ||
| body() | ||
| } catch (err) { | ||
| error "withVaultToken: error ${err}" | ||
|
||
| // When running in the CI with multiple parallel stages | ||
| // the access could be considered as a DDOS attack. Let's sleep a bit if it fails. | ||
| sleep randomNumber(min: 2, max: 5) | ||
| throw err | ||
| } finally { | ||
| // ensure any sensitive details are deleted | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.