提交 f00979ae 编写于 作者: M mindless

[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
上级 8c1e7a0e
...@@ -605,14 +605,6 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A ...@@ -605,14 +605,6 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
return Hudson.getInstance().getQueue().getItem(this); 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. * 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 ...@@ -210,6 +210,14 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
return null; 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 * Get the term used in the UI to represent this kind of
* {@link AbstractProject}. Must start with a capital letter. * {@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 ...@@ -1195,6 +1203,12 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
return; return;
} }
if (isBuilding()) {
// redirect to page explaining that we can't rename now
rsp.sendRedirect("rename?newName=" + newName);
return;
}
renameTo(newName); renameTo(newName);
// send to the new job page // send to the new job page
// note we can't use getUrl() because that would pick up old name in the // note we can't use getUrl() because that would pick up old name in the
......
...@@ -25,15 +25,25 @@ THE SOFTWARE. ...@@ -25,15 +25,25 @@ THE SOFTWARE.
<!-- Rename project --> <!-- 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"> <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> <l:layout>
<st:include page="sidepanel.jelly" /> <st:include page="sidepanel.jelly" />
<l:main-panel> <l:main-panel>
<j:set var="newName" value="${request.getParameter('newName')}" /> <j:choose>
<form method="get" action="doRename"> <j:when test="${it.isBuilding()}">
${%description(it.name, newName)} ${%noRenameWhileBuilding}
<input type="hidden" name="newName" value="${newName}" /> <j:if test="${request.referer.endsWith('/configure')}">
<f:submit value="${%Yes}" /> <br/> ${%configWasSaved}
<input type="button" value="${%No}" onclick="javascript:history.back()" class="yui-button" /> </j:if>
</form> </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:main-panel>
</l:layout> </l:layout>
</j:jelly> </j:jelly>
\ No newline at end of file
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE. # 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}? description=Are you sure about renaming {0} to {1}?
Yes=Yes Yes=Yes
No=No No=No
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册