Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
roginluo
Jenkins
提交
5d38d40e
J
Jenkins
项目概览
roginluo
/
Jenkins
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
Jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5d38d40e
编写于
2月 27, 2013
作者:
N
Nicolas De Loof
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FIXED JENKINS-13502] impersonate a SYSTEM to handle upstream build trigger
上级
6d40738a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
68 addition
and
54 deletion
+68
-54
changelog.html
changelog.html
+3
-0
core/src/main/java/hudson/model/AbstractProject.java
core/src/main/java/hudson/model/AbstractProject.java
+65
-54
未找到文件。
changelog.html
浏览文件 @
5d38d40e
...
...
@@ -67,6 +67,9 @@ Upcoming changes</a>
<li
class=
bug
>
Revert ampersand encoding which can cause backwad incompatibility issue
(
<a
href=
"https://github.com/jenkinsci/jenkins/pull/683"
>
pull 683
</a>
)
<li
class=
bug
>
Fix dependency graph computation when upstream build trigger is involved
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-13502"
>
issue 13502
</a>
)
</ul>
</div>
<!--=TRUNK-END=-->
...
...
core/src/main/java/hudson/model/AbstractProject.java
浏览文件 @
5d38d40e
...
...
@@ -63,6 +63,7 @@ import hudson.scm.SCM;
import
hudson.scm.SCMRevisionState
;
import
hudson.scm.SCMS
;
import
hudson.search.SearchIndexBuilder
;
import
hudson.security.ACL
;
import
hudson.security.Permission
;
import
hudson.slaves.WorkspaceList
;
import
hudson.tasks.BuildStep
;
...
...
@@ -88,6 +89,8 @@ import jenkins.scm.SCMCheckoutStrategy;
import
jenkins.scm.SCMCheckoutStrategyDescriptor
;
import
jenkins.util.TimeDuration
;
import
net.sf.json.JSONObject
;
import
org.acegisecurity.context.SecurityContext
;
import
org.acegisecurity.context.SecurityContextHolder
;
import
org.kohsuke.accmod.Restricted
;
import
org.kohsuke.accmod.restrictions.NoExternalUse
;
import
org.kohsuke.args4j.Argument
;
...
...
@@ -747,60 +750,8 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
// dependency setting might have been changed by the user, so rebuild.
Jenkins
.
getInstance
().
rebuildDependencyGraph
();
convertUpstreamBuildTrigger
(
upstream
);
// reflect the submission of the pseudo 'upstream build trriger'.
// this needs to be done after we release the lock on 'this',
// or otherwise we could dead-lock
for
(
AbstractProject
<?,?>
p
:
Jenkins
.
getInstance
().
getAllItems
(
AbstractProject
.
class
))
{
// Don't consider child projects such as MatrixConfiguration:
if
(!
p
.
isConfigurable
())
continue
;
boolean
isUpstream
=
upstream
.
contains
(
p
);
synchronized
(
p
)
{
// does 'p' include us in its BuildTrigger?
DescribableList
<
Publisher
,
Descriptor
<
Publisher
>>
pl
=
p
.
getPublishersList
();
BuildTrigger
trigger
=
pl
.
get
(
BuildTrigger
.
class
);
List
<
AbstractProject
>
newChildProjects
=
trigger
==
null
?
new
ArrayList
<
AbstractProject
>():
trigger
.
getChildProjects
(
p
);
if
(
isUpstream
)
{
if
(!
newChildProjects
.
contains
(
this
))
newChildProjects
.
add
(
this
);
}
else
{
newChildProjects
.
remove
(
this
);
}
if
(
newChildProjects
.
isEmpty
())
{
pl
.
remove
(
BuildTrigger
.
class
);
}
else
{
// here, we just need to replace the old one with the new one,
// but there was a regression (we don't know when it started) that put multiple BuildTriggers
// into the list.
// for us not to lose the data, we need to merge them all.
List
<
BuildTrigger
>
existingList
=
pl
.
getAll
(
BuildTrigger
.
class
);
BuildTrigger
existing
;
switch
(
existingList
.
size
())
{
case
0
:
existing
=
null
;
break
;
case
1
:
existing
=
existingList
.
get
(
0
);
break
;
default
:
pl
.
removeAll
(
BuildTrigger
.
class
);
Set
<
AbstractProject
>
combinedChildren
=
new
HashSet
<
AbstractProject
>();
for
(
BuildTrigger
bt
:
existingList
)
combinedChildren
.
addAll
(
bt
.
getChildProjects
(
p
));
existing
=
new
BuildTrigger
(
new
ArrayList
<
AbstractProject
>(
combinedChildren
),
existingList
.
get
(
0
).
getThreshold
());
pl
.
add
(
existing
);
break
;
}
if
(
existing
!=
null
&&
existing
.
hasSame
(
p
,
newChildProjects
))
continue
;
// no need to touch
pl
.
replace
(
new
BuildTrigger
(
newChildProjects
,
existing
==
null
?
Result
.
SUCCESS
:
existing
.
getThreshold
()));
}
}
}
// notify the queue as the project might be now tied to different node
Jenkins
.
getInstance
().
getQueue
().
scheduleMaintenance
();
...
...
@@ -809,7 +760,67 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
Jenkins
.
getInstance
().
rebuildDependencyGraph
();
}
/**
/**
* Reflect the submission of the pseudo 'upstream build trigger'.
*/
private
void
convertUpstreamBuildTrigger
(
Set
<
AbstractProject
>
upstream
)
throws
IOException
{
SecurityContext
saveCtx
=
ACL
.
impersonate
(
ACL
.
SYSTEM
);
try
{
for
(
AbstractProject
<?,?>
p
:
Jenkins
.
getInstance
().
getAllItems
(
AbstractProject
.
class
))
{
// Don't consider child projects such as MatrixConfiguration:
if
(!
p
.
isConfigurable
())
continue
;
boolean
isUpstream
=
upstream
.
contains
(
p
);
synchronized
(
p
)
{
// does 'p' include us in its BuildTrigger?
DescribableList
<
Publisher
,
Descriptor
<
Publisher
>>
pl
=
p
.
getPublishersList
();
BuildTrigger
trigger
=
pl
.
get
(
BuildTrigger
.
class
);
List
<
AbstractProject
>
newChildProjects
=
trigger
==
null
?
new
ArrayList
<
AbstractProject
>():
trigger
.
getChildProjects
(
p
);
if
(
isUpstream
)
{
if
(!
newChildProjects
.
contains
(
this
))
newChildProjects
.
add
(
this
);
}
else
{
newChildProjects
.
remove
(
this
);
}
if
(
newChildProjects
.
isEmpty
())
{
pl
.
remove
(
BuildTrigger
.
class
);
}
else
{
// here, we just need to replace the old one with the new one,
// but there was a regression (we don't know when it started) that put multiple BuildTriggers
// into the list. For us not to lose the data, we need to merge them all.
List
<
BuildTrigger
>
existingList
=
pl
.
getAll
(
BuildTrigger
.
class
);
BuildTrigger
existing
;
switch
(
existingList
.
size
())
{
case
0
:
existing
=
null
;
break
;
case
1
:
existing
=
existingList
.
get
(
0
);
break
;
default
:
pl
.
removeAll
(
BuildTrigger
.
class
);
Set
<
AbstractProject
>
combinedChildren
=
new
HashSet
<
AbstractProject
>();
for
(
BuildTrigger
bt
:
existingList
)
combinedChildren
.
addAll
(
bt
.
getChildProjects
(
p
));
existing
=
new
BuildTrigger
(
new
ArrayList
<
AbstractProject
>(
combinedChildren
),
existingList
.
get
(
0
).
getThreshold
());
pl
.
add
(
existing
);
break
;
}
if
(
existing
!=
null
&&
existing
.
hasSame
(
p
,
newChildProjects
))
continue
;
// no need to touch
pl
.
replace
(
new
BuildTrigger
(
newChildProjects
,
existing
==
null
?
Result
.
SUCCESS
:
existing
.
getThreshold
()));
}
}
}
}
finally
{
SecurityContextHolder
.
setContext
(
saveCtx
);
}
}
/**
* @deprecated
* Use {@link #scheduleBuild(Cause)}. Since 1.283
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录