mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 21:42:27 +00:00
[FIXED HUDSON-1879] don't allow renaming a job while a build is running.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@18628 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
8c1e7a0e5a
commit
f00979aea4
4 files changed
+37
-19
No files matched your search
@@ -605,14 +605,6 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
|
||||
return Hudson.getInstance().getQueue().getItem(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a build of this project is in progress.
|
||||
*/
|
||||
public boolean isBuilding() {
|
||||
R b = getLastBuild();
|
||||
return b!=null && b.isBuilding();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the JDK that this project is configured with, or null.
|
||||
*/
|
||||
|
||||
@@ -210,6 +210,14 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a build of this project is in progress.
|
||||
*/
|
||||
public boolean isBuilding() {
|
||||
RunT b = getLastBuild();
|
||||
return b!=null && b.isBuilding();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the term used in the UI to represent this kind of
|
||||
* {@link AbstractProject}. Must start with a capital letter.
|
||||
@@ -1195,6 +1203,12 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
|
||||
return;
|
||||
}
|
||||
|
||||
if (isBuilding()) {
|
||||
// redirect to page explaining that we can't rename now
|
||||
rsp.sendRedirect("rename?newName=" + newName);
|
||||
return;
|
||||
}
|
||||
|
||||
renameTo(newName);
|
||||
// send to the new job page
|
||||
// note we can't use getUrl() because that would pick up old name in the
|
||||
|
||||
@@ -25,15 +25,25 @@ THE SOFTWARE.
|
||||
<!-- Rename project -->
|
||||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
|
||||
<l:layout>
|
||||
<st:include page="sidepanel.jelly" />
|
||||
<l:main-panel>
|
||||
<j:set var="newName" value="${request.getParameter('newName')}" />
|
||||
<form method="get" action="doRename">
|
||||
${%description(it.name, newName)}
|
||||
<input type="hidden" name="newName" value="${newName}" />
|
||||
<f:submit value="${%Yes}" />
|
||||
<input type="button" value="${%No}" onclick="javascript:history.back()" class="yui-button" />
|
||||
</form>
|
||||
<st:include page="sidepanel.jelly" />
|
||||
<l:main-panel>
|
||||
<j:choose>
|
||||
<j:when test="${it.isBuilding()}">
|
||||
${%noRenameWhileBuilding}
|
||||
<j:if test="${request.referer.endsWith('/configure')}">
|
||||
<br/> ${%configWasSaved}
|
||||
</j:if>
|
||||
</j:when>
|
||||
<j:otherwise>
|
||||
<j:set var="newName" value="${request.getParameter('newName')}" />
|
||||
<form method="get" action="doRename">
|
||||
${%description(it.name, newName)}
|
||||
<input type="hidden" name="newName" value="${newName}" />
|
||||
<f:submit value="${%Yes}" />
|
||||
<input type="button" value="${%No}" onclick="javascript:history.back()" class="yui-button" />
|
||||
</form>
|
||||
</j:otherwise>
|
||||
</j:choose>
|
||||
</l:main-panel>
|
||||
</l:layout>
|
||||
</j:jelly>
|
||||
</j:jelly>
|
||||
@@ -20,6 +20,8 @@
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
|
||||
noRenameWhileBuilding=Unable to rename a job while it is building.
|
||||
configWasSaved=All other configuration options were saved.
|
||||
description=Are you sure about renaming {0} to {1}?
|
||||
Yes=Yes
|
||||
No=No
|
||||
No=No
|
||||
Reference in new issue
Block a user