-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JENKINS-37655: Use Credentials API for SMTP authentication
- Loading branch information
1 parent
d726a11
commit 48c9f9a
Showing
20 changed files
with
473 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ target/ | |
*.iws | ||
*.ipr | ||
.idea | ||
out | ||
out | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package hudson.tasks; | ||
|
||
class Retryable { | ||
|
||
private Retryable() { | ||
|
||
} | ||
|
||
interface Fn { | ||
void run(int attempt) throws Exception; | ||
} | ||
|
||
/** | ||
* Run the provided function once, and if it fails, retry up to n times. | ||
* | ||
* This does not support asynchronous functions. | ||
* | ||
* @param times the number of times to retry after a failure. When times=0, the function runs once, with no retries if it fails. When times=2, the function runs once, with up to 2 retries if it fails. | ||
* @param fn the function to run and retry | ||
* @return whether any of the function invocations succeeded | ||
*/ | ||
static boolean retry(int times, Fn fn) { | ||
int attempt = 0; | ||
|
||
do { | ||
try { | ||
fn.run(attempt + 1); | ||
|
||
return true; | ||
} catch (Exception e) { | ||
// try again | ||
} | ||
|
||
++attempt; | ||
} while (attempt <= times); | ||
|
||
return false; | ||
} | ||
} |
Oops, something went wrong.