11
11
import java .io .IOException ;
12
12
import java .util .Collections ;
13
13
import java .util .List ;
14
+ import java .util .Objects ;
14
15
15
16
import org .apache .http .HttpStatus ;
16
17
import org .apache .http .client .HttpResponseException ;
17
18
18
19
import com .google .common .base .Function ;
19
20
import com .google .common .base .Optional ;
20
21
import com .google .common .base .Predicate ;
22
+ import com .google .common .collect .ImmutableMap ;
21
23
import com .google .common .collect .Iterables ;
22
24
import com .offbytwo .jenkins .client .util .EncodingUtils ;
23
25
import com .offbytwo .jenkins .helper .Range ;
@@ -339,9 +341,10 @@ public QueueItem getQueueItem() {
339
341
/**
340
342
* Get a build by the given buildNumber.
341
343
*
342
- * @param buildNumber The number to select the build by.
344
+ * @param buildNumber
345
+ * The number to select the build by.
343
346
* @return The {@link Build} selected by the given buildnumber
344
- *
347
+ *
345
348
*/
346
349
public Build getBuildByNumber (final int buildNumber ) {
347
350
@@ -366,6 +369,66 @@ public Job apply(Job job) {
366
369
}
367
370
}
368
371
372
+ /**
373
+ * Empty description to be used for {@link #updateDescription(String)}
374
+ * or {@link #updateDescription(String, boolean)}.
375
+ */
376
+ public static final String EMPTY_DESCRIPTION = "" ;
377
+
378
+ /**
379
+ * Update the <code>description</code> of a Job.
380
+ *
381
+ * @param description
382
+ * The description which should be set.
383
+ * If you like to set an empty description
384
+ * you should use {@link #EMPTY_DESCRIPTION}.
385
+ * @throws IOException
386
+ * in case of errors.
387
+ */
388
+ public void updateDescription (String description ) throws IOException {
389
+ updateDescription (description , false );
390
+ }
391
+
392
+ /**
393
+ * Update the <code>description</code> of a Job.
394
+ *
395
+ * @param description
396
+ * The description which should be set.
397
+ * If you like to set an empty description
398
+ * you should use {@link #EMPTY_DESCRIPTION}.
399
+ * @param crumbFlag
400
+ * <code>true</code> or <code>false</code>.
401
+ * @throws IOException
402
+ * in case of errors.
403
+ */
404
+ public void updateDescription (String description , boolean crumbFlag ) throws IOException {
405
+ Objects .requireNonNull (description , "description is not allowed to be null." );
406
+ ImmutableMap <String , String > params = ImmutableMap .of ("description" , description );
407
+ client .post_form (this .getUrl () + "/submitDescription?" , params , crumbFlag );
408
+ }
409
+
410
+ /**
411
+ * clear the description of a job.
412
+ *
413
+ * @throws IOException
414
+ * in case of errors.
415
+ */
416
+ public void clearDescription () throws IOException {
417
+ updateDescription (EMPTY_DESCRIPTION );
418
+ }
419
+
420
+ /**
421
+ * clear the description of a job.
422
+ *
423
+ * @param crumbFlag
424
+ * <code>true</code> or <code>false</code>.
425
+ * @throws IOException
426
+ * in case of errors.
427
+ */
428
+ public void clearDescription (boolean crumbFlag ) throws IOException {
429
+ updateDescription (EMPTY_DESCRIPTION , crumbFlag );
430
+ }
431
+
369
432
@ Override
370
433
public int hashCode () {
371
434
final int prime = 31 ;
0 commit comments