Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
977f9221
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,发现更多精彩内容 >>
提交
977f9221
编写于
5月 02, 2017
作者:
A
Andrew Bayer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor for supporting on-demand calculation of culprits
上级
39136804
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
58 addition
and
46 deletion
+58
-46
core/src/main/java/hudson/model/AbstractBuild.java
core/src/main/java/hudson/model/AbstractBuild.java
+29
-0
core/src/main/java/jenkins/scm/RunWithSCM.java
core/src/main/java/jenkins/scm/RunWithSCM.java
+29
-46
未找到文件。
core/src/main/java/hudson/model/AbstractBuild.java
浏览文件 @
977f9221
...
...
@@ -336,6 +336,35 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
return
culprits
;
}
@Override
public
boolean
shouldCalculateCulprits
()
{
return
getCulpritIds
()
==
null
;
}
@Override
@Nonnull
public
Set
<
User
>
calculateCulprits
()
{
Set
<
User
>
c
=
RunWithSCM
.
super
.
calculateCulprits
();
AbstractBuild
<
P
,
R
>
p
=
getPreviousCompletedBuild
();
if
(
upstreamCulprits
)
{
// If we have dependencies since the last successful build, add their authors to our list
if
(
p
.
getPreviousNotFailedBuild
()
!=
null
)
{
Map
<
AbstractProject
,
AbstractBuild
.
DependencyChange
>
depmap
=
p
.
getDependencyChanges
(
p
.
getPreviousSuccessfulBuild
());
for
(
AbstractBuild
.
DependencyChange
dep
:
depmap
.
values
())
{
for
(
AbstractBuild
<?,
?>
b
:
dep
.
getBuilds
())
{
for
(
ChangeLogSet
.
Entry
entry
:
b
.
getChangeSet
())
{
c
.
add
(
entry
.
getAuthor
());
}
}
}
}
}
return
c
;
}
/**
* Gets the version of Hudson that was used to build this job.
*
...
...
core/src/main/java/jenkins/scm/RunWithSCM.java
浏览文件 @
977f9221
...
...
@@ -24,8 +24,6 @@
package
jenkins.scm
;
import
hudson.model.AbstractBuild
;
import
hudson.model.AbstractProject
;
import
hudson.model.Job
;
import
hudson.model.Queue
;
import
hudson.model.Result
;
...
...
@@ -42,7 +40,6 @@ import java.util.AbstractSet;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
...
...
@@ -52,15 +49,16 @@ import java.util.logging.Logger;
*/
public
interface
RunWithSCM
<
JobT
extends
Job
<
JobT
,
RunT
>
&
Queue
.
Task
,
RunT
extends
Run
<
JobT
,
RunT
>
&
RunWithSCM
<
JobT
,
RunT
>
&
Queue
.
Executable
>
{
/**
* Set if we want the blame information to flow from upstream to downstream build.
*/
boolean
upstreamCulprits
=
SystemProperties
.
getBoolean
(
"hudson.upstreamCulprits"
);
RunT
asRun
();
List
<
ChangeLogSet
<?
extends
ChangeLogSet
.
Entry
>>
getChangeSets
();
@CheckForNull
Set
<
String
>
getCulpritIds
();
boolean
shouldCalculateCulprits
();
/**
* List of users who committed a change since the last non-broken build till now.
*
...
...
@@ -73,40 +71,8 @@ public interface RunWithSCM<JobT extends Job<JobT, RunT> & Queue.Task,
*/
@Exported
@Nonnull
default
Set
<
User
>
getCulprits
()
{
if
(
getCulpritIds
()
==
null
)
{
Set
<
User
>
r
=
new
HashSet
<
User
>();
RunT
p
=
asRun
().
getPreviousCompletedBuild
();
if
(
p
!=
null
&&
asRun
().
isBuilding
())
{
Result
pr
=
p
.
getResult
();
if
(
pr
!=
null
&&
pr
.
isWorseThan
(
Result
.
SUCCESS
))
{
// we are still building, so this is just the current latest information,
// but we seems to be failing so far, so inherit culprits from the previous build.
// isBuilding() check is to avoid recursion when loading data from old Hudson, which doesn't record
// this information
r
.
addAll
(
p
.
getCulprits
());
}
}
for
(
ChangeLogSet
<?
extends
ChangeLogSet
.
Entry
>
c
:
getChangeSets
())
{
for
(
ChangeLogSet
.
Entry
e
:
c
)
r
.
add
(
e
.
getAuthor
());
}
if
(
p
instanceof
AbstractBuild
&&
upstreamCulprits
)
{
// If we have dependencies since the last successful build, add their authors to our list
if
(
p
.
getPreviousNotFailedBuild
()
!=
null
)
{
Map
<
AbstractProject
,
AbstractBuild
.
DependencyChange
>
depmap
=
((
AbstractBuild
<?,?>)
p
).
getDependencyChanges
((
AbstractBuild
<?,?>)
p
.
getPreviousSuccessfulBuild
());
for
(
AbstractBuild
.
DependencyChange
dep
:
depmap
.
values
())
{
for
(
AbstractBuild
<?,
?>
b
:
dep
.
getBuilds
())
{
for
(
ChangeLogSet
.
Entry
entry
:
b
.
getChangeSet
())
{
r
.
add
(
entry
.
getAuthor
());
}
}
}
}
}
return
r
;
if
(
shouldCalculateCulprits
())
{
return
calculateCulprits
();
}
return
new
AbstractSet
<
User
>()
{
...
...
@@ -124,6 +90,27 @@ public interface RunWithSCM<JobT extends Job<JobT, RunT> & Queue.Task,
};
}
default
Set
<
User
>
calculateCulprits
()
{
Set
<
User
>
r
=
new
HashSet
<
User
>();
RunT
p
=
asRun
().
getPreviousCompletedBuild
();
if
(
p
!=
null
&&
asRun
().
isBuilding
())
{
Result
pr
=
p
.
getResult
();
if
(
pr
!=
null
&&
pr
.
isWorseThan
(
Result
.
SUCCESS
))
{
// we are still building, so this is just the current latest information,
// but we seems to be failing so far, so inherit culprits from the previous build.
// isBuilding() check is to avoid recursion when loading data from old Hudson, which doesn't record
// this information
r
.
addAll
(
p
.
getCulprits
());
}
}
for
(
ChangeLogSet
<?
extends
ChangeLogSet
.
Entry
>
c
:
getChangeSets
())
{
for
(
ChangeLogSet
.
Entry
e
:
c
)
r
.
add
(
e
.
getAuthor
());
}
return
r
;
}
/**
* Returns true if this user has made a commit to this build.
*/
...
...
@@ -134,14 +121,10 @@ public interface RunWithSCM<JobT extends Job<JobT, RunT> & Queue.Task,
if
(
e
.
getAuthor
()
==
user
)
return
true
;
}
catch
(
RuntimeException
re
)
{
Logger
LOGGER
=
Logger
.
getLogger
(
RunWithSCM
.
class
.
getName
());
LOGGER
.
log
(
Level
.
INFO
,
"Failed to determine author of changelog "
+
e
.
getCommitId
()
+
"for "
+
asRun
().
getParent
().
getDisplayName
()
+
", "
+
asRun
().
getDisplayName
(),
re
);
}
}
return
false
;
}
@CheckForNull
Set
<
String
>
getCulpritIds
();
Logger
LOGGER
=
Logger
.
getLogger
(
RunWithSCM
.
class
.
getName
());
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录