Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #1841 from pjanouse/JENKINS-30629
[JENKINS-30629] Fixed NPE in AbstractItem.resolveForCLI()
  • Loading branch information
olivergondza committed Sep 29, 2015
2 parents 7e072b6 + 3fa9ce5 commit 7fb4696
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions core/src/main/java/hudson/model/AbstractItem.java
Expand Up @@ -723,8 +723,11 @@ public static AbstractItem resolveForCLI(
@Argument(required=true,metaVar="NAME",usage="Job name") String name) throws CmdLineException {
// 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)
throw new CmdLineException(null,Messages.AbstractItem_NoSuchJobExists(name,AbstractProject.findNearest(name).getFullName()));
if (item==null) {
AbstractProject project = AbstractProject.findNearest(name);
throw new CmdLineException(null, project == null ? Messages.AbstractItem_NoSuchJobExistsWithoutSuggestion(name)
: Messages.AbstractItem_NoSuchJobExists(name, project.getFullName()));
}
return item;
}

Expand Down
1 change: 1 addition & 0 deletions core/src/main/resources/hudson/model/Messages.properties
Expand Up @@ -29,6 +29,7 @@ AbstractBuild.BuildingInWorkspace=\ in workspace {0}
AbstractBuild.KeptBecause=This build is kept because of {0}.

AbstractItem.NoSuchJobExists=No such job \u2018{0}\u2019 exists. Perhaps you meant \u2018{1}\u2019?
AbstractItem.NoSuchJobExistsWithoutSuggestion=No such job \u2018{0}\u2019 exists.
AbstractItem.Pronoun=Item
AbstractProject.AssignedLabelString_NoMatch_DidYouMean=There\u2019s no slave/cloud that matches this assignment. Did you mean \u2018{1}\u2019 instead of \u2018{0}\u2019?
AbstractProject.NewBuildForWorkspace=Scheduling a new build to get a workspace.
Expand Down

0 comments on commit 7fb4696

Please sign in to comment.