New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JENKINS-55612] Add optional label to echo step #80
Conversation
a0d2c9c
to
37a56ed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In jenkinsci/workflow-durable-task-step-plugin#93 (comment) Jesse raised the point that maybe it would have been better to use StepDescriptor#argumentsToString
instead of a label, so maybe we should use that approach instead? I am interested to hear what @abayer thinks.
The main benefit with that approach AIUI is that the label would always be consistently "Print Message" and what was shown next to it would either be the script, if it is short, or the label if it is specified, or nothing if there is no label and the script is too long or multiple arguments are passed.
Also, by adding a second argument to the step but still using the default implementation of argumentsToString
, the message won't show up in the Blue Ocean view if a label is specified. Maybe that's fine, or maybe we should update argumentsToString
to handle multiple args similarly to ShellStep.
@DataBoundSetter | ||
public void setLabel(String label) { | ||
if (label == null) | ||
throw new IllegalArgumentException(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: It feels a little awkward to me to throw an exception here. On the one hand it makes sense to fail fast, but I don't think anyone should be calling this method directly except for Stapler and maybe devs in a unit test, so perhaps adding an @Nonnull
annotation would be good enough, and you still have to have the null check in start
anyway for builds deserialized from before the label existed so it seems like a bit of a wash. Maybe you could add a doCheckLabel
method to the descriptor to do some validation for anyone using the pipeline syntax page, but I'm not sure whether that works well with optional @DataBoundSetter
s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dwnusbaum
Yeah, since I check for null in the start
this is overkill. I like the @NonNull
annotation for self-documenting code.
@dwnusbaum Ah, wait.
Back to the drawing board for a minute. |
@dwnusbaum I responded on the other PR, but to summarize: That aside, as I noted above, the user's core problem is that Blue Ocean only shows the message for short I think adding a label is still the right way to go. |
@dwnusbaum I've updated this PR with a version that truncate the argument string to the first line of the message but also adds the label field. I haven't run this up in a local blue ocean yet to verify the behavior. |
This PR exemplifies the reason I thought JENKINS-55410 was a bad idea to begin with—it just leads to endless creeping requests to add And what really is the use case here?
This behavior is not fixed in stone. It is just the current design of
without needing to change your script. I actually argued for such a behavior during the design, but it was deferred: jenkinsci/workflow-api-plugin#26 (comment) ¹ Actually my original choice of step name was |
JENKINS-55612
This is a minimal implementation for this issue, including some basic tests.
Based on this PR: jenkinsci/workflow-durable-task-step-plugin#93