@@ -67,13 +67,11 @@ void beforeEach(JenkinsRule rule) {
6767 void specialStatus () throws Exception {
6868 User .getById ("smrt" , true );
6969 WorkflowJob p = r .jenkins .createProject (WorkflowJob .class , "p" );
70- p .setDefinition (new CpsFlowDefinition (
71- """
70+ p .setDefinition (new CpsFlowDefinition ("""
7271 catchError {
7372 semaphore 'specialStatus'
7473 }
75- """ ,
76- true ));
74+ """ , true ));
7775 SemaphoreStep .failure (
7876 "specialStatus/1" ,
7977 new FlowInterruptedException (Result .UNSTABLE , new CauseOfInterruption .UserInterruption ("smrt" )));
@@ -133,13 +131,11 @@ void serialFormWhenTypeOfBuildResultFieldWasResult() throws Exception {
133131 @ Test
134132 void customBuildResult () throws Exception {
135133 WorkflowJob p = r .jenkins .createProject (WorkflowJob .class , "p" );
136- p .setDefinition (new CpsFlowDefinition (
137- """
134+ p .setDefinition (new CpsFlowDefinition ("""
138135 catchError(message: 'caught error', buildResult: 'unstable') {
139136 error 'oops'
140137 }
141- """ ,
142- true ));
138+ """ , true ));
143139 WorkflowRun b = p .scheduleBuild2 (0 ).waitForStart ();
144140 assertCatchError (r , b , Result .UNSTABLE , null , true );
145141 r .assertLogContains ("Setting overall build result to UNSTABLE" , b );
@@ -148,13 +144,11 @@ void customBuildResult() throws Exception {
148144 @ Test
149145 void invalidBuildResult () throws Exception {
150146 WorkflowJob p = r .jenkins .createProject (WorkflowJob .class , "p" );
151- p .setDefinition (new CpsFlowDefinition (
152- """
147+ p .setDefinition (new CpsFlowDefinition ("""
153148 catchError(buildResult: 'typo') {
154149 error 'oops'
155150 }
156- """ ,
157- true ));
151+ """ , true ));
158152 WorkflowRun b = r .assertBuildStatus (Result .FAILURE , p .scheduleBuild2 (0 ));
159153 r .assertLogContains ("buildResult is invalid: typo" , b );
160154 }
@@ -163,27 +157,23 @@ void invalidBuildResult() throws Exception {
163157 @ Test
164158 void customStageResult () throws Exception {
165159 WorkflowJob p = r .jenkins .createProject (WorkflowJob .class , "p" );
166- p .setDefinition (new CpsFlowDefinition (
167- """
160+ p .setDefinition (new CpsFlowDefinition ("""
168161 catchError(message: 'caught error', stageResult: 'failure') {
169162 error 'oops'
170163 }
171- """ ,
172- true ));
164+ """ , true ));
173165 WorkflowRun b = p .scheduleBuild2 (0 ).waitForStart ();
174166 assertCatchError (r , b , Result .FAILURE , Result .FAILURE , true );
175167 }
176168
177169 @ Test
178170 void invalidStageResult () throws Exception {
179171 WorkflowJob p = r .jenkins .createProject (WorkflowJob .class , "p" );
180- p .setDefinition (new CpsFlowDefinition (
181- """
172+ p .setDefinition (new CpsFlowDefinition ("""
182173 catchError(stageResult: 'typo') {
183174 error 'oops'
184175 }
185- """ ,
186- true ));
176+ """ , true ));
187177 WorkflowRun b = r .assertBuildStatus (Result .FAILURE , p .scheduleBuild2 (0 ));
188178 r .assertLogContains ("stageResult is invalid: typo" , b );
189179 }
@@ -192,59 +182,51 @@ void invalidStageResult() throws Exception {
192182 @ Test
193183 void stepResultOnly () throws Exception {
194184 WorkflowJob p = r .jenkins .createProject (WorkflowJob .class , "p" );
195- p .setDefinition (new CpsFlowDefinition (
196- """
185+ p .setDefinition (new CpsFlowDefinition ("""
197186 catchError(message: 'caught error', buildResult: 'success', stageResult: 'unstable') {
198187 error 'oops'
199188 }
200- """ ,
201- true ));
189+ """ , true ));
202190 WorkflowRun b = p .scheduleBuild2 (0 ).waitForStart ();
203191 assertCatchError (r , b , Result .SUCCESS , Result .UNSTABLE , true );
204192 }
205193
206194 @ Test
207195 void catchesInterruptionsByDefault () throws Exception {
208196 WorkflowJob p = r .jenkins .createProject (WorkflowJob .class , "p" );
209- p .setDefinition (new CpsFlowDefinition (
210- """
197+ p .setDefinition (new CpsFlowDefinition ("""
211198 import jenkins.model.CauseOfInterruption
212199 import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException
213200 catchError(message: 'caught error') {
214201 throw new FlowInterruptedException(Result.ABORTED, true, new CauseOfInterruption[0])
215202 }
216- """ ,
217- false ));
203+ """ , false ));
218204 WorkflowRun b = p .scheduleBuild2 (0 ).waitForStart ();
219205 assertCatchError (r , b , Result .ABORTED , Result .ABORTED , true );
220206 }
221207
222208 @ Test
223209 void canAvoidCatchingInterruptionsWithOption () throws Exception {
224210 WorkflowJob p = r .jenkins .createProject (WorkflowJob .class , "p" );
225- p .setDefinition (new CpsFlowDefinition (
226- """
211+ p .setDefinition (new CpsFlowDefinition ("""
227212 import jenkins.model.CauseOfInterruption
228213 import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException
229214 catchError(message: 'caught error', catchInterruptions: false) {
230215 throw new FlowInterruptedException(Result.ABORTED, true, new CauseOfInterruption[0])
231216 }
232- """ ,
233- false ));
217+ """ , false ));
234218 WorkflowRun b = p .scheduleBuild2 (0 ).waitForStart ();
235219 assertCatchError (r , b , Result .ABORTED , null , false );
236220 }
237221
238222 @ Test
239223 void catchesAttemptsToStopBuildByDefault () throws Exception {
240224 WorkflowJob p = r .jenkins .createProject (WorkflowJob .class , "p" );
241- p .setDefinition (new CpsFlowDefinition (
242- """
225+ p .setDefinition (new CpsFlowDefinition ("""
243226 catchError(message: 'caught error') {
244227 semaphore 'ready'
245228 }
246- """ ,
247- true ));
229+ """ , true ));
248230 WorkflowRun b = p .scheduleBuild2 (0 ).waitForStart ();
249231 SemaphoreStep .waitForStart ("ready/1" , b );
250232 b .doStop ();
@@ -254,13 +236,11 @@ void catchesAttemptsToStopBuildByDefault() throws Exception {
254236 @ Test
255237 void canAvoidCatchingAttemptsToStopBuildWithOption () throws Exception {
256238 WorkflowJob p = r .jenkins .createProject (WorkflowJob .class , "p" );
257- p .setDefinition (new CpsFlowDefinition (
258- """
239+ p .setDefinition (new CpsFlowDefinition ("""
259240 catchError(message: 'caught error', catchInterruptions: false) {
260241 semaphore 'ready'
261242 }
262- """ ,
263- true ));
243+ """ , true ));
264244 WorkflowRun b = p .scheduleBuild2 (0 ).waitForStart ();
265245 SemaphoreStep .waitForStart ("ready/1" , b );
266246 b .doStop ();
@@ -273,14 +253,12 @@ void catchesDownstreamBuildFailureEvenWhenNotCatchingInterruptions() throws Exce
273253 WorkflowJob ds = r .createProject (WorkflowJob .class , "ds" );
274254 ds .setDefinition (new CpsFlowDefinition ("error 'oops!'" , true ));
275255 WorkflowJob us = r .createProject (WorkflowJob .class , "us" );
276- us .setDefinition (new CpsFlowDefinition (
277- """
256+ us .setDefinition (new CpsFlowDefinition ("""
278257 int count = 1
279258 catchError(message: 'caught error', catchInterruptions: false) {
280259 build 'ds'
281260 }
282- """ ,
283- true ));
261+ """ , true ));
284262 WorkflowRun b = r .assertBuildStatus (Result .FAILURE , us .scheduleBuild2 (0 ));
285263 assertCatchError (r , b , Result .FAILURE , Result .FAILURE , true );
286264 }
0 commit comments