提交 b3758892 编写于 作者: K Kohsuke Kawaguchi

[FIXED JENKINS-10057] capture the failure to install a plugin better

上级 af89f5e9
......@@ -58,6 +58,9 @@ Upcoming changes</a>
<li class=bug>
Fixed a bug where SSH public key authentication for CLI wasn't working for username/password based security realm.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-10647">issue 10647</a>)
<li class=bug>
Failing to install a plugin from CLI should result in non-zero exit code
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-10057">issue 10057</a>)
<li class=bug>
Disable auto refresh in slave markOffline screen
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-10608">issue 10608</a>)
......
......@@ -25,6 +25,7 @@ package hudson.cli;
import hudson.Extension;
import hudson.FilePath;
import hudson.util.IOException2;
import jenkins.model.Jenkins;
import hudson.model.UpdateSite;
import hudson.model.UpdateSite.Data;
......@@ -100,7 +101,9 @@ public class InstallPluginCommand extends CLICommand {
UpdateSite.Plugin p = h.getUpdateCenter().getPlugin(source);
if (p!=null) {
stdout.println(Messages.InstallPluginCommand_InstallingFromUpdateCenter(source));
p.deploy().get();
Throwable e = p.deploy().get().getError();
if (e!=null)
throw new IOException2("Failed to install plugin "+source,e);
continue;
}
......
......@@ -729,6 +729,11 @@ public class UpdateCenter extends AbstractModelObject implements Saveable {
*/
public final UpdateSite site;
/**
* If this job fails, set to the error.
*/
protected Throwable error;
protected UpdateCenterJob(UpdateSite site) {
this.site = site;
}
......@@ -751,6 +756,10 @@ public class UpdateCenter extends AbstractModelObject implements Saveable {
jobs.add(this);
return installerService.submit(this,this);
}
public Throwable getError() {
return error;
}
}
/**
......@@ -789,10 +798,10 @@ public class UpdateCenter extends AbstractModelObject implements Saveable {
status = new Running();
try {
Jenkins.getInstance().safeRestart();
}
catch (RestartNotSupportedException exception) {
} catch (RestartNotSupportedException exception) {
// ignore if restart is not allowed
status = new Failure();
error = exception;
}
}
......@@ -853,8 +862,10 @@ public class UpdateCenter extends AbstractModelObject implements Saveable {
} catch (UnknownHostException e) {
statuses.add(Messages.UpdateCenter_Status_UnknownHostException(e.getMessage()));
addStatus(e);
error = e;
} catch (IOException e) {
statuses.add(Functions.printThrowable(e));
error = e;
}
}
......@@ -926,6 +937,7 @@ public class UpdateCenter extends AbstractModelObject implements Saveable {
} catch (Throwable e) {
LOGGER.log(Level.SEVERE, "Failed to install "+getName(),e);
status = new Failure(e);
error = e;
}
}
......@@ -1113,6 +1125,7 @@ public class UpdateCenter extends AbstractModelObject implements Saveable {
} catch (Throwable e) {
LOGGER.log(Level.SEVERE, "Failed to downgrade "+getName(),e);
status = new Failure(e);
error = e;
}
}
......@@ -1208,6 +1221,7 @@ public class UpdateCenter extends AbstractModelObject implements Saveable {
} catch (Throwable e) {
LOGGER.log(Level.SEVERE, "Failed to downgrade "+getName(),e);
status = new Failure(e);
error = e;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册