提交 c4f6034a 编写于 作者: J jpederzolli

Issue: HUDSON-2494

patch to prevent copied jobs from running until initial save



git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@31444 71c3de6d-444a-0410-be80-ed276b4c234a
上级 ef61325f
......@@ -447,7 +447,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
}
public boolean isBuildable() {
return !isDisabled();
return !isDisabled() && !isHoldOffBuildUntilSave();
}
/**
......
......@@ -135,6 +135,12 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
*/
protected transient volatile int nextBuildNumber = 1;
/**
* Newly copied jobs get this flag set, so that Hudson doesn't try to run the job until its configuration
* is saved once.
*/
private transient volatile boolean holdOffBuildUntilSave;
private volatile LogRotator logRotator;
/**
......@@ -156,6 +162,12 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
super(parent, name);
}
@Override
public synchronized void save() throws IOException {
super.save();
holdOffBuildUntilSave = false;
}
@Override
public void onLoad(ItemGroup<? extends Item> parent, String name)
throws IOException {
......@@ -191,6 +203,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
super.onCopiedFrom(src);
synchronized (this) {
this.nextBuildNumber = 1; // reset the next build number
this.holdOffBuildUntilSave = true;
}
}
......@@ -212,6 +225,10 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
return new TextFile(new File(this.getRootDir(), "nextBuildNumber"));
}
protected boolean isHoldOffBuildUntilSave() {
return holdOffBuildUntilSave;
}
protected synchronized void saveNextBuildNumber() throws IOException {
if (nextBuildNumber == 0) { // #3361
nextBuildNumber = 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册