-
-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Make all CLI commands compatible with Pipeline where possible #2874
Conversation
…g deprecated Remoting-based CLI calls with CLICommandInvoker.
…hile we are here.
…y for unknown reasons.
…sabled-JENKINS-27299
…o CLI-JENKINS-41527
This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation. |
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 code mostly looks good, but I am aware of some edge cases. Hence 🐛 until we discuss them at least
@@ -38,7 +37,7 @@ | |||
* @author Kohsuke Kawaguchi | |||
*/ | |||
@Extension | |||
public class DeleteBuildsCommand extends AbstractBuildRangeCommand { | |||
public class DeleteBuildsCommand extends JobRangeCommand { |
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.
🐜 This is binary incompatible. The only usage outside the core: https://github.com/jenkinsci/matrix-project-plugin/blob/8d94ba80991cf84c361c5739bc7d9a427f9171ad/src/test/java/hudson/matrix/MatrixProjectTest.java#L680 . It seems to be safe.
I would consider adding "Restricted" or maybe creating a new class instead.
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.
CLI command classes are not considered APIs. Could add @Restricted
to emphasize that, I suppose.
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.
CLI command classes are not considered APIs
By whom? No explicit documentation about that :(
But yes, Restricted would help
@@ -20,7 +21,7 @@ | |||
* @author Kohsuke Kawaguchi | |||
*/ | |||
@Extension | |||
public class ListChangesCommand extends AbstractBuildRangeCommand { | |||
public class ListChangesCommand extends JobRangeCommand { |
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.
No external usages, but also binary incompatible
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.
Ditto.
@@ -78,11 +79,10 @@ protected int run() throws Exception { | |||
} | |||
|
|||
if(job == null) { | |||
// TODO: JENKINS-30785 | |||
AbstractProject project = AbstractProject.findNearest(job_s); | |||
AbstractItem project = Items.findNearest(AbstractItem.class, job_s, jenkins); |
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.
Why not just item? Or maybe even TopLevelItem (who would reload other items anyway?)
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.
reload
is defined in AbstractItem
.
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.
Agreed.
* | ||
* @since FIXME | ||
*/ | ||
public interface RunWithSCM<JobT extends Job<JobT, RunT> & Queue.Task, |
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 am not sure it is safe to use Queue.Task/Executable here. It may be possible to imagine other Run types, and it does not seem to be really required. 🐜 , will be bug if I find a real use-case for it
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.
Ditto.
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.
@abayer fyi
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.
Ok, I can remove those.
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.
And done in 914963c
// TODO can this (and its pseudo-override in AbstractProject) share code with GenericItemOptionHandler, used for explicit CLICommand’s rather than CLIMethod’s? | ||
AbstractItem item = Jenkins.getInstance().getItemByFullName(name, AbstractItem.class); | ||
if (item==null) { | ||
AbstractProject project = AbstractProject.findNearest(name); | ||
AbstractItem project = Items.findNearest(AbstractItem.class, name, Jenkins.getInstance()); |
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.
AbstractItem is required for displaying FullName in the message. I think it could be generalized even more to Item
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.
This resolver is in AbstractItem
specifically.
public boolean supportsMakeDisabled() { | ||
return this instanceof TopLevelItem; | ||
} | ||
|
||
// Seems to be used only by tests; do not bother pulling up. |
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.
Add VisibleForTests annotation?
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.
Well, that is the only call I found from inside this repository. Did not look externally.
this.idx = idx; | ||
} | ||
|
||
Run<?, ?> getBuild() { |
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.
getRun()
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.
Comment upstream please. Anyway
- this is not an API
- we commonly use the term
build
generically to include anyRun
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.
Plus it'd theoretically be changing an API, since this got moved over from AbstractBuild
.
for (SCM s : scmItem.getSCMs()) { | ||
scmNames.add(s.getDescriptor().getDisplayName()); | ||
} | ||
scmDisplayName = " " + Util.join(scmNames, ", "); |
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.
Could be optimized to StringBuilder, issue in the migrated code anyway, so unrelated to this PR
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.
Comment in the subsumed PR, not here.
*/ | ||
public interface ParameterizedJob extends hudson.model.Queue.Task, hudson.model.Item { | ||
public interface ParameterizedJob<JobT extends Job<JobT, RunT> & ParameterizedJobMixIn.ParameterizedJob<JobT, RunT> & Queue.Task, RunT extends Run<JobT, RunT> & Queue.Executable> extends BuildableItem { |
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.
🐛 It may sound ridiculous, but the original interface didn't actually require this parameterized job to be buildable. Don't ask why anyone would need parameters then...
By extending BuildableItem
you made these items Buildable, which may impact UI (there will be build button, option to run the job in CLI, etc.). It may cause regressions in Job types, which are not supposed to be buildable. It needs more investigation before applying
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 only implementations are AbstractProject
and WorkflowJob
, both of which were already BuildableItem
. Does not directly impact the UI anyway, since the build button etc. is added explicitly by project types.
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.
Anyway please comment in the subsumed PR which defines this change, not here.
/** | ||
* Allows a {@link Run} to provide {@link SCM}-related methods, such as providing changesets and culprits. | ||
* | ||
* @since FIXME |
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.
So, Pipeline won't implement this API immediately, right?
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.
Please comment on the subsumed PR.
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.
@oleg-nenashev Correct, my plan is to not have anything downstream from #2730 merged/released until this is in an LTS that's been in the wild for a month.
Sole bug was defined in #2866, not here.
… as restricted, not APIs.
…sabled-JENKINS-27299
I cannot review it until upstream PRs are merged. It is not effective |
Effective diff from #2866 is fairly small. |
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 am not fully convinced that breaking binary compatibility of CLI commands is perfectly safe hence they were effectively a part of public API. OTOH the only usage is in MatrixProject test suite, which will be unlikely affected, will it?
Other possible approach would be to create deleteRuns
command instead of deleteBuilds
, but it may cause much confusion among users.
So, 🐝 from me though it would be great to get extra feedback from @jenkinsci/code-reviewers .
@Extension | ||
public class DeleteBuildsCommand extends AbstractBuildRangeCommand { | ||
public class DeleteBuildsCommand extends JobRangeCommand { |
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.
JobRange
? It is range of runs ...
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.
True, RunRangeCommand
would be a better name.
Access restrictions are not checked in test sources. |
…JobRangeCommand.
@reviewbybees done |
@jenkinsci/code-reviewers This change is more readable now. Are you fine with this incompatible change (no risk within jenkinsci org && no expected valid use-case)? |
I assume everybody excepting me is fine with this compat change. |
Description
Subsumes #2866 & #2694.
delete-builds
list-changes
console
(JENKINS-41527)reload-job
(JENKINS-30785)set-build-description
set-build-display-name
Changelog entries
Proposed changelog entries:
delete-builds
,list-changes
,console
,set-build-description
, andset-build-display-name
), as well as some issues affecting error reporting in other commands when used with Pipeline.Desired reviewers
@reviewbybees & @jenkinsci/code-reviewers