-
Notifications
You must be signed in to change notification settings - Fork 73
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-39203] Create new action to mark a FlowNode with a result such as unstable #91
Conversation
Closing and reopening in an attempt to get a CI build. |
I think I'm running into JENKINS-54126, so I'll just deploy snapshots manually. |
public final class WarningAction implements PersistentAction { | ||
private final @Nonnull String message; | ||
|
||
public WarningAction(@Nonnull String message) { |
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.
Maybe it would make more sense for this to be @Nullable
so that something like unstable()
with no message would work without having to create some kind of default message.
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.
I do not see a use case for a null message, so would suggest keeping it @Nonnull
unless and until one is found.
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.
On second thought, perhaps it would be appropriate to have the constructor take no arguments, then use the idiom
public WarningAction withMessage(@Nonnull String message) {
this.message = message;
return this;
}
as I think it is likely we will at some point want an associated URL and perhaps even a badge icon.
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.
Any particular reason to prefer withMessage
, withUrl
, etc. over adding new constructors that take additional arguments? With the former pattern it is easy to forget to call withMessage
. We could use the builder pattern and validate that the message is non-null when constructing the WarningAction
from the builder, but that seems like overkill.
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.
The builder style makes it easier to introduce new features compatibly. If we decide that a message is mandatory, then keep it in the constructor.
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.
Sounds fine in isolation.
import javax.annotation.Nonnull; | ||
import jenkins.model.Jenkins; | ||
import org.apache.commons.io.output.NullOutputStream; | ||
|
||
/** | ||
* Attached to {@link AtomNode} that caused an error. | ||
* Attached to {@link FlowNode} that caused an error. |
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.
Good catch!
src/main/java/org/jenkinsci/plugins/workflow/actions/WarningAction.java
Outdated
Show resolved
Hide resolved
public final class WarningAction implements PersistentAction { | ||
private final @Nonnull String message; | ||
|
||
public WarningAction(@Nonnull String message) { |
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.
I do not see a use case for a null message, so would suggest keeping it @Nonnull
unless and until one is found.
c = BallColor.ABORTED; | ||
} else { | ||
c = BallColor.RED; | ||
} | ||
} else if (getPersistentAction(WarningAction.class) != null) { | ||
c = BallColor.YELLOW; |
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.
Here is an example of what this change looks like for the following pipeline:
stage('unstable-one') {
unstable('foobar')
}
stage('success') {
echo('whatever')
}
stage('failure') {
unstable('three')
error('uncaught')
}
For now only the actual FlowNode
that has the WarningAction
attached will be shown as unstable (unlike Blue Ocean in jenkinsci/pipeline-graph-analysis-plugin#25 which searches all FlowNodes
in a stage/branch for a WarningAction
.). This seems like the most obvious behavior to me, but I could make it work like Blue Ocean if desired.
All of the upstream PRs are using the current version of the API and I don't anticipate any further changes to it right now, so I'm going to go ahead and merge this PR and release the plugin. |
See JENKINS-39203. (I am intentionally not updating the status of that ticket or assigning it to myself until I am ready to merge/release all relevant changes to avoid giving users premature hope of a fix and so that I have clear answers for what will and won't work and when any fixes will be released.) Subsumes #63.
This PR adds a new action named
WarningAction
. This action can be stored on aFlowNode
to mark that although it completed successfully, some kind of non-fatal problem occurred. For now, this action will be used by Blue Ocean to mark stages containing aFlowNode
with aWarningAction
asResult.UNSTABLE
.In the future, if we wanted to add the ability to track some new kind of non-fatal result, we could update
WarningAction
to store a customResult
(or similar) and use that in visualizations to modify how the action should be displayed.Upstream PRs: