Skip to content

Commit

Permalink
JENKINS-38084 - Add support to mark jobs as disabled on import
Browse files Browse the repository at this point in the history
  • Loading branch information
Evildethow committed Sep 12, 2016
1 parent 2b4a0f9 commit 144aa1d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Expand Up @@ -36,6 +36,7 @@
import hudson.model.Item;
import hudson.model.RootAction;
import hudson.model.TopLevelItem;
import hudson.model.AbstractProject;
import hudson.security.ACL;
import hudson.util.FormValidation;
import java.io.IOException;
Expand Down Expand Up @@ -125,7 +126,12 @@ public void doImport(final StaplerRequest request, final StaplerResponse respons

try {
inputStream = URLUtils.fetchUrl(remoteJob.getUrl() + "/config.xml", username, password);
Jenkins.getInstance().createProjectFromXML(remoteJob.getName(), inputStream);
TopLevelItem topLevelItem = Jenkins.getInstance().createProjectFromXML(remoteJob.getName(), inputStream);
boolean disableProject = request.getParameter("disable-" + jobUrl) != null;
if (topLevelItem instanceof AbstractProject && disableProject) {
AbstractProject project = (AbstractProject)topLevelItem;
project.disable();
}
remoteJobsImportStatus.get(remoteJob).setStatus(MessagesUtils.formatSuccess());
}

Expand Down
Expand Up @@ -60,12 +60,14 @@
<table class="jobImportPlugin" cellpadding="3" cellspacing="3">
<tr>
<th>Import?</th>
<th>Disable?</th>
<th>Name</th>
<th>Description</th>
</tr>
<j:forEach var="job" items="${it.remoteJobs}">
<tr>
<td><f:checkbox name="jobUrl" value="${job.url}"/></td>
<td><f:checkbox name="disable-${job.url}" /></td>
<td><a target="_blank" href="${job.url}">${job.name}</a></td>
<td>${job.description}</td>
</tr>
Expand Down

0 comments on commit 144aa1d

Please sign in to comment.