Added failure check status on error
This commit is contained in:
		
							parent
							
								
									5f7f1d25b4
								
							
						
					
					
						commit
						e68a84b851
					
				| @ -14,6 +14,20 @@ def setSuccessCheck(String name, String title) { | |||||||
| } | } | ||||||
| /* -------------------------------------------------------------------------- */ | /* -------------------------------------------------------------------------- */ | ||||||
| /** | /** | ||||||
|  | * | ||||||
|  | * Helper function that emits `Success` status. | ||||||
|  | * | ||||||
|  | */ | ||||||
|  | def setFailureCheck(String name, String title) { | ||||||
|  |   publishChecks( | ||||||
|  |     name: name, | ||||||
|  |     title: title, | ||||||
|  |     summary: '— Failed', | ||||||
|  |     conclusion: "FAILURE" | ||||||
|  |   ) | ||||||
|  | } | ||||||
|  | /* -------------------------------------------------------------------------- */ | ||||||
|  | /** | ||||||
| * Replacement for `stage` function for default pipeline. | * Replacement for `stage` function for default pipeline. | ||||||
| * | * | ||||||
| * Has the same arguments but does side-effects to the stage: | * Has the same arguments but does side-effects to the stage: | ||||||
| @ -25,8 +39,13 @@ def setSuccessCheck(String name, String title) { | |||||||
| */ | */ | ||||||
| def stageWithChecks(String name, Closure body) { | def stageWithChecks(String name, Closure body) { | ||||||
|   stage(name) { |   stage(name) { | ||||||
|     body() |     try { | ||||||
|     setSuccessCheck(name, name) |       body() | ||||||
|  |       setSuccessCheck(name, name) | ||||||
|  |     } catch (error) { | ||||||
|  |       sh "echo Stage $name failed with error: $error" | ||||||
|  |       setFailureCheck(name, name) | ||||||
|  |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
| /* -------------------------------------------------------------------------- */ | /* -------------------------------------------------------------------------- */ | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user