Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
a197999c
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a197999c
编写于
8月 31, 2014
作者:
C
CloudBees DEV@Cloud
浏览文件
操作
浏览文件
下载
差异文件
Merge commit '
52c28ae3
'
上级
c07463dd
52c28ae3
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
24 addition
and
19 deletion
+24
-19
core/src/main/java/hudson/FilePath.java
core/src/main/java/hudson/FilePath.java
+2
-1
core/src/main/java/hudson/model/AbstractBuild.java
core/src/main/java/hudson/model/AbstractBuild.java
+1
-1
core/src/main/java/hudson/model/AbstractProject.java
core/src/main/java/hudson/model/AbstractProject.java
+1
-1
core/src/main/java/hudson/slaves/WorkspaceList.java
core/src/main/java/hudson/slaves/WorkspaceList.java
+17
-15
test/src/test/java/hudson/model/ProjectTest.java
test/src/test/java/hudson/model/ProjectTest.java
+3
-1
未找到文件。
core/src/main/java/hudson/FilePath.java
浏览文件 @
a197999c
...
...
@@ -111,6 +111,7 @@ import java.util.regex.Pattern;
import
static
hudson
.
FilePath
.
TarCompression
.*;
import
static
hudson
.
Util
.*;
import
javax.annotation.Nonnull
;
/**
* {@link File} like object with remoting support.
...
...
@@ -1161,7 +1162,7 @@ public final class FilePath implements Serializable {
* @param relOrAbsolute a relative or absolute path
* @return a file on the same channel
*/
public
FilePath
child
(
String
relOrAbsolute
)
{
public
@Nonnull
FilePath
child
(
String
relOrAbsolute
)
{
return
new
FilePath
(
this
,
relOrAbsolute
);
}
...
...
core/src/main/java/hudson/model/AbstractBuild.java
浏览文件 @
a197999c
...
...
@@ -292,7 +292,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
* Normally, a workspace is assigned by {@link hudson.model.Run.RunExecution}, but this lets you set the workspace in case
* {@link AbstractBuild} is created without a build.
*/
protected
void
setWorkspace
(
FilePath
ws
)
{
protected
void
setWorkspace
(
@Nonnull
FilePath
ws
)
{
this
.
workspace
=
ws
.
getRemote
();
}
...
...
core/src/main/java/hudson/model/AbstractProject.java
浏览文件 @
a197999c
...
...
@@ -1432,7 +1432,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
}
}
private
PollingResult
pollWithWorkspace
(
TaskListener
listener
,
SCM
scm
,
R
lb
,
FilePath
ws
,
WorkspaceList
l
)
throws
InterruptedException
,
IOException
{
private
PollingResult
pollWithWorkspace
(
TaskListener
listener
,
SCM
scm
,
R
lb
,
@Nonnull
FilePath
ws
,
WorkspaceList
l
)
throws
InterruptedException
,
IOException
{
// if doing non-concurrent build, acquire a workspace in a way that causes builds to block for this workspace.
// this prevents multiple workspaces of the same job --- the behavior of Hudson < 1.319.
//
...
...
core/src/main/java/hudson/slaves/WorkspaceList.java
浏览文件 @
a197999c
...
...
@@ -32,6 +32,7 @@ import java.util.HashMap;
import
java.util.Map
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
javax.annotation.Nonnull
;
/**
* Used by {@link Computer} to keep track of workspaces that are actively in use.
...
...
@@ -72,7 +73,7 @@ public final class WorkspaceList {
*/
public
final
boolean
quick
;
public
final
FilePath
path
;
public
final
@Nonnull
FilePath
path
;
/**
* Multiple threads can acquire the same lock if they share the same context object.
...
...
@@ -81,11 +82,11 @@ public final class WorkspaceList {
public
int
lockCount
=
1
;
private
Entry
(
FilePath
path
,
boolean
quick
)
{
private
Entry
(
@Nonnull
FilePath
path
,
boolean
quick
)
{
this
(
path
,
quick
,
new
Object
());
// unique context
}
private
Entry
(
FilePath
path
,
boolean
quick
,
Object
context
)
{
private
Entry
(
@Nonnull
FilePath
path
,
boolean
quick
,
Object
context
)
{
this
.
path
=
path
;
this
.
quick
=
quick
;
this
.
context
=
context
;
...
...
@@ -104,9 +105,10 @@ public final class WorkspaceList {
* Represents a leased workspace that needs to be returned later.
*/
public
static
abstract
class
Lease
{
public
final
FilePath
path
;
public
final
@Nonnull
FilePath
path
;
protected
Lease
(
FilePath
path
)
{
protected
Lease
(
@Nonnull
FilePath
path
)
{
path
.
getRemote
();
// null check
this
.
path
=
path
;
}
...
...
@@ -118,7 +120,7 @@ public final class WorkspaceList {
/**
* Creates a dummy {@link Lease} object that does no-op in the release.
*/
public
static
Lease
createDummyLease
(
FilePath
p
)
{
public
static
Lease
createDummyLease
(
@Nonnull
FilePath
p
)
{
return
new
Lease
(
p
)
{
public
void
release
()
{
// noop
...
...
@@ -130,7 +132,7 @@ public final class WorkspaceList {
* Creates a {@link Lease} object that points to the specified path, but the lock
* is controlled by the given parent lease object.
*/
public
static
Lease
createLinkedDummyLease
(
FilePath
p
,
final
Lease
parent
)
{
public
static
Lease
createLinkedDummyLease
(
@Nonnull
FilePath
p
,
final
Lease
parent
)
{
return
new
Lease
(
p
)
{
public
void
release
()
{
parent
.
release
();
...
...
@@ -151,7 +153,7 @@ public final class WorkspaceList {
* This method doesn't block prolonged amount of time. Whenever a desired workspace
* is in use, the unique variation is added.
*/
public
synchronized
Lease
allocate
(
FilePath
base
)
throws
InterruptedException
{
public
synchronized
Lease
allocate
(
@Nonnull
FilePath
base
)
throws
InterruptedException
{
return
allocate
(
base
,
new
Object
());
}
...
...
@@ -162,7 +164,7 @@ public final class WorkspaceList {
* Threads that share the same context can re-acquire the same lock (which will just increment the lock count.)
* This allows related executors to share the same workspace.
*/
public
synchronized
Lease
allocate
(
FilePath
base
,
Object
context
)
throws
InterruptedException
{
public
synchronized
Lease
allocate
(
@Nonnull
FilePath
base
,
Object
context
)
throws
InterruptedException
{
for
(
int
i
=
1
;
;
i
++)
{
FilePath
candidate
=
i
==
1
?
base
:
base
.
withSuffix
(
COMBINATOR
+
i
);
Entry
e
=
inUse
.
get
(
candidate
);
...
...
@@ -175,7 +177,7 @@ public final class WorkspaceList {
/**
* Just record that this workspace is being used, without paying any attention to the synchronization support.
*/
public
synchronized
Lease
record
(
FilePath
p
)
{
public
synchronized
Lease
record
(
@Nonnull
FilePath
p
)
{
if
(
LOGGER
.
isLoggable
(
Level
.
FINE
))
{
LOGGER
.
log
(
Level
.
FINE
,
"recorded "
+
p
,
new
Throwable
(
"from "
+
this
));
}
...
...
@@ -188,7 +190,7 @@ public final class WorkspaceList {
/**
* Releases an allocated or acquired workspace.
*/
private
synchronized
void
_release
(
FilePath
p
)
{
private
synchronized
void
_release
(
@Nonnull
FilePath
p
)
{
Entry
old
=
inUse
.
get
(
p
);
if
(
old
==
null
)
throw
new
AssertionError
(
"Releasing unallocated workspace "
+
p
);
...
...
@@ -207,7 +209,7 @@ public final class WorkspaceList {
* @return
* The same {@link FilePath} as given to this method.
*/
public
synchronized
Lease
acquire
(
FilePath
p
)
throws
InterruptedException
{
public
synchronized
Lease
acquire
(
@Nonnull
FilePath
p
)
throws
InterruptedException
{
return
acquire
(
p
,
false
);
}
...
...
@@ -218,7 +220,7 @@ public final class WorkspaceList {
* If true, indicates that the acquired workspace will be returned quickly.
* This makes other calls to {@link #allocate(FilePath)} to wait for the release of this workspace.
*/
public
synchronized
Lease
acquire
(
FilePath
p
,
boolean
quick
)
throws
InterruptedException
{
public
synchronized
Lease
acquire
(
@Nonnull
FilePath
p
,
boolean
quick
)
throws
InterruptedException
{
return
acquire
(
p
,
quick
,
new
Object
());
}
...
...
@@ -229,7 +231,7 @@ public final class WorkspaceList {
* Threads that share the same context can re-acquire the same lock (which will just increment the lock count.)
* This allows related executors to share the same workspace.
*/
public
synchronized
Lease
acquire
(
FilePath
p
,
boolean
quick
,
Object
context
)
throws
InterruptedException
{
public
synchronized
Lease
acquire
(
@Nonnull
FilePath
p
,
boolean
quick
,
Object
context
)
throws
InterruptedException
{
Entry
e
;
Thread
t
=
Thread
.
currentThread
();
...
...
@@ -257,7 +259,7 @@ public final class WorkspaceList {
/**
* Wraps a path into a valid lease.
*/
private
Lease
lease
(
FilePath
p
)
{
private
Lease
lease
(
@Nonnull
FilePath
p
)
{
return
new
Lease
(
p
)
{
public
void
release
()
{
_release
(
path
);
...
...
test/src/test/java/hudson/model/ProjectTest.java
浏览文件 @
a197999c
...
...
@@ -419,7 +419,9 @@ public class ProjectTest {
FreeStyleProject
p
=
j
.
createFreeStyleProject
(
"project"
);
Slave
slave
=
j
.
createOnlineSlave
();
AbstractBuild
build
=
p
.
createExecutable
();
FilePath
path
=
slave
.
toComputer
().
getWorkspaceList
().
allocate
(
slave
.
getWorkspaceFor
(
p
),
build
).
path
;
FilePath
ws
=
slave
.
getWorkspaceFor
(
p
);
assertNotNull
(
ws
);
FilePath
path
=
slave
.
toComputer
().
getWorkspaceList
().
allocate
(
ws
,
build
).
path
;
build
.
setWorkspace
(
path
);
BuildListener
listener
=
new
StreamBuildListener
(
BuildListener
.
NULL
.
getLogger
(),
Charset
.
defaultCharset
());
assertTrue
(
"Project with null smc should perform checkout without problems."
,
p
.
checkout
(
build
,
new
RemoteLauncher
(
listener
,
slave
.
getChannel
(),
true
),
listener
,
new
File
(
build
.
getRootDir
(),
"changelog.xml"
)));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录