[JIRA] (JENKINS-51932) Directive Generator: `when` is missing `isRestartedRun()`

19 views
Skip to first unread message

kshultz@cloudbees.com (JIRA)

unread,
Jun 13, 2018, 2:57:01 PM6/13/18
to jenkinsc...@googlegroups.com
Karl Shultz created an issue
 
Jenkins / Bug JENKINS-51932
Directive Generator: `when` is missing `isRestartedRun()`
Issue Type: Bug Bug
Assignee: Andrew Bayer
Components: pipeline-model-definition-plugin
Created: 2018-06-13 18:56
Environment: Jenkins:
- Core 2.127
- Experimental UC plugins
- Declarative at 1.3.0-SNAPSHOT, which was master at commit eeb92e42
Priority: Minor Minor
Reporter: Karl Shultz

Summary
When using the Directive Generator, building a when / allOf directive with no conditions attached produces a NPE. This was another accidental find.

Steps to recreate
1. Go to the Declarative Directive Generator via http://1.2.3.4:8080/job/your-pipeline-job/directive-generator/

2. Set it up as follows:

  • Sample Directive: when
  • whenCondition: allOf
  • Execute the stage if all nested conditions are true: no selections made

3. And press the Generate Declarative Directive button, you'll get a NPE in your sample:

when {
  // ERROR TRANSLATING CONDITIONAL: java.lang.NullPointerException
}

Accidental find.

Unable to render embedded object: File (image-2018-06-13-14-36-02-967.png) not found.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

kshultz@cloudbees.com (JIRA)

unread,
Jun 13, 2018, 3:01:02 PM6/13/18
to jenkinsc...@googlegroups.com
Karl Shultz updated an issue
Change By: Karl Shultz
Attachment: image-2018-06-13-14-59-55-242.png
*Summary*
When using the Directive Generator,
building a the generator for {{when}} / is missing {{ allOf isRestartedRun() }} directive with no conditions attached produces a NPE . This was another accidental find.


*Steps to recreate*

1. Go to the Declarative Directive Generator via {{http://1.2.3.4:8080/job/your-pipeline-job/directive-generator/}}

2.
Set it up as follows:
*
Pick the Sample Directive: {{when}}
* whenCondition: {{allOf}}
* Execute the stage if all nested conditions are true: no selections made

3. And press Look in the Generate Declarative Directive button dropdown for When Condition. I was expecting to see `isRestartedRun` , you but it ' ll get a NPE in your sample:
{code:none}
when {
  // ERROR TRANSLATING CONDITIONAL: java
s not there . lang.NullPointerException
}
{code}

Accidental find.

!image-2018-06-13-14- 36 59 - 02 55 - 967 242 .png|thumbnail!

andrew.bayer@gmail.com (JIRA)

unread,
Aug 7, 2018, 9:42:01 AM8/7/18
to jenkinsc...@googlegroups.com
Change By: Andrew Bayer
Status: In Progress Review
This message was sent by Atlassian JIRA (v7.10.1#710002-sha1:6efc396)

andrew.bayer@gmail.com (JIRA)

unread,
Aug 7, 2018, 9:42:01 AM8/7/18
to jenkinsc...@googlegroups.com
Andrew Bayer started work on Bug JENKINS-51932
 
Change By: Andrew Bayer
Status: Open In Progress

andrew.bayer@gmail.com (JIRA)

unread,
Aug 7, 2018, 9:43:02 AM8/7/18
to jenkinsc...@googlegroups.com

badevcich@gmail.com (JIRA)

unread,
Aug 8, 2018, 11:54:02 AM8/8/18
to jenkinsc...@googlegroups.com

Is there documentation how this this isRestartedRun is used? If I put this in the when block of stage 1 and restart at stage 3 will it skip the stage 1 block or will it actually do stage 1 first, and then stage 3 and so on?

I ask because I'm looking for a way to always run an earlier stage (to do some setup) no matter what stage is selected as the restart point.

badevcich@gmail.com (JIRA)

unread,
Aug 8, 2018, 11:57:01 AM8/8/18
to jenkinsc...@googlegroups.com
Blake Devcich edited a comment on Bug JENKINS-51932
Is there documentation how this this isRestartedRun is used? If I put this in the when block of stage 1 and restart at stage 3 will it skip the stage 1 block or will it actually do stage 1 first, and then stage 3 and so on?

I ask because I'm looking for a way to always run an earlier stage (to do some setup) no matter what stage is selected as the restart point.


[https://jenkins.io/doc/book/pipeline/syntax/#when] makes no mention of this feature.

andrew.bayer@gmail.com (JIRA)

unread,
Aug 8, 2018, 12:49:02 PM8/8/18
to jenkinsc...@googlegroups.com

It allows you to only fire a stage if it's part of a restarted run (or, of course, with not, you can have it do the reverse). But this still only applies for stages from the restart point onward - if you restart at stage 3, stages 1 and 2 will always be skipped regardless.

badevcich@gmail.com (JIRA)

unread,
Aug 8, 2018, 5:03:03 PM8/8/18
to jenkinsc...@googlegroups.com

Thanks Andrew! So just to confirm there's no way to always run a setup stage when a pipeline is restarted?

The only thing I can think of right now is to have a function that is called in the beginning of every stage that is executed only on a restart.

andrew.bayer@gmail.com (JIRA)

unread,
Aug 8, 2018, 5:11:02 PM8/8/18
to jenkinsc...@googlegroups.com

Blake Devcich - correct. It's an interesting idea, though - probably would be worth opening a JIRA for that as a new feature.

andrew.bayer@gmail.com (JIRA)

unread,
Aug 9, 2018, 10:02:01 AM8/9/18
to jenkinsc...@googlegroups.com
 

This'll be in the next release (1.3.2)

Change By: Andrew Bayer
Status: In Review Resolved
Resolution: Fixed

bitwiseman@gmail.com (JIRA)

unread,
Oct 22, 2019, 11:25:54 PM10/22/19
to jenkinsc...@googlegroups.com
Liam Newman closed an issue as Fixed
 

Bulk closing resolved issues.

Change By: Liam Newman
Status: Resolved Closed
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages