Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
07198294
J
jenkins
项目概览
LinuxSuRen
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
07198294
编写于
9月 01, 2012
作者:
K
Kohsuke Kawaguchi
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'pull-543'
上级
a0c02400
a267ad90
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
146 addition
and
4 deletion
+146
-4
changelog.html
changelog.html
+3
-0
core/src/main/java/hudson/matrix/DefaultMatrixExecutionStrategyImpl.java
...ava/hudson/matrix/DefaultMatrixExecutionStrategyImpl.java
+13
-1
core/src/main/java/hudson/matrix/MatrixChildAction.java
core/src/main/java/hudson/matrix/MatrixChildAction.java
+39
-0
core/src/main/java/hudson/matrix/MatrixConfiguration.java
core/src/main/java/hudson/matrix/MatrixConfiguration.java
+24
-2
core/src/main/java/hudson/model/ParametersAction.java
core/src/main/java/hudson/model/ParametersAction.java
+2
-1
test/src/test/groovy/hudson/matrix/MatrixProjectTest.groovy
test/src/test/groovy/hudson/matrix/MatrixProjectTest.groovy
+65
-0
未找到文件。
changelog.html
浏览文件 @
07198294
...
...
@@ -61,6 +61,9 @@ Upcoming changes</a>
<li
class=
bug
>
Detect bugs relating to short
<code>
Descriptor
</code>
names early.
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-14995"
>
issue 14995
</a>
continued)
<li
class=
rfe
>
Parameters defined in matrix projects are now available in configuration builds.
(
<a
href=
"https://github.com/jenkinsci/jenkins/pull/543"
>
pull 543
</a>
)
</ul>
</div>
<!--=TRUNK-END=-->
...
...
core/src/main/java/hudson/matrix/DefaultMatrixExecutionStrategyImpl.java
浏览文件 @
07198294
...
...
@@ -2,6 +2,7 @@ package hudson.matrix;
import
hudson.AbortException
;
import
hudson.Extension
;
import
hudson.Util
;
import
hudson.console.ModelHyperlinkNote
;
import
hudson.matrix.MatrixBuild.MatrixBuildExecution
;
import
hudson.matrix.listeners.MatrixBuildListener
;
...
...
@@ -194,10 +195,21 @@ public class DefaultMatrixExecutionStrategyImpl extends MatrixExecutionStrategy
return
r
;
}
/** Function to start schedule a single configuration
*
* This function schedule a build of a configuration passing all of the Matrixchild actions
* that are present in the parent build.
*
* @param exec Matrix build that is the parent of the configuration
* @param c Configuration to schedule
*/
private
void
scheduleConfigurationBuild
(
MatrixBuildExecution
exec
,
MatrixConfiguration
c
)
{
MatrixBuild
build
=
exec
.
getBuild
();
exec
.
getListener
().
getLogger
().
println
(
Messages
.
MatrixBuild_Triggering
(
ModelHyperlinkNote
.
encodeTo
(
c
)));
c
.
scheduleBuild
(
build
.
getAction
(
ParametersAction
.
class
),
new
UpstreamCause
((
Run
)
build
));
// filter the parent actions for those that can be passed to the individual jobs.
List
<
MatrixChildAction
>
childActions
=
Util
.
filter
(
build
.
getActions
(),
MatrixChildAction
.
class
);
c
.
scheduleBuild
(
childActions
,
new
UpstreamCause
((
Run
)
build
));
}
private
MatrixRun
waitForCompletion
(
MatrixBuildExecution
exec
,
MatrixConfiguration
c
)
throws
InterruptedException
,
IOException
{
...
...
core/src/main/java/hudson/matrix/MatrixChildAction.java
0 → 100644
浏览文件 @
07198294
/*
* The MIT License
*
* Copyright (c) 2012, Chris Johnson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
hudson.matrix
;
import
hudson.model.Action
;
import
hudson.model.Queue
;
import
hudson.model.Queue.Task
;
/**
* Optional interface for {@link Action}s that are used as parameters
* to {@link Queue#schedule(Task, int, Action...)} to indicate that they
* want to be also passed to the {@link MatrixRun}s from its parent {@link MatrixBuild}.
*
* @author Chris Johnson
* @since 1.481
*/
public
interface
MatrixChildAction
extends
Action
{
}
core/src/main/java/hudson/matrix/MatrixConfiguration.java
浏览文件 @
07198294
...
...
@@ -53,6 +53,8 @@ import hudson.tasks.LogRotator;
import
hudson.tasks.Publisher
;
import
java.io.IOException
;
import
java.util.Collections
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -359,13 +361,33 @@ public class MatrixConfiguration extends Project<MatrixConfiguration,MatrixRun>
return
scheduleBuild
(
parameters
,
new
LegacyCodeCause
());
}
/**
/**
Starts the build with the ParametersAction that are passed in.
*
* @param parameters
* Can be null.
* @deprecated
* Use {@link #scheduleBuild(List<? extends Action>, Cause)}. Since 1.480
*/
public
boolean
scheduleBuild
(
ParametersAction
parameters
,
Cause
c
)
{
return
Jenkins
.
getInstance
().
getQueue
().
schedule
(
this
,
getQuietPeriod
(),
parameters
,
new
CauseAction
(
c
),
new
ParentBuildAction
())!=
null
;
return
scheduleBuild
(
Collections
.
singletonList
(
parameters
),
c
);
}
/**
* Starts the build with the actions that are passed in.
*
* @param actions Can be null.
* @param cause Reason for starting the build
*/
public
boolean
scheduleBuild
(
List
<?
extends
Action
>
actions
,
Cause
c
)
{
List
<
Action
>
allActions
=
new
ArrayList
<
Action
>();
if
(
actions
!=
null
)
allActions
.
addAll
(
actions
);
allActions
.
add
(
new
ParentBuildAction
());
allActions
.
add
(
new
CauseAction
(
c
));
return
Jenkins
.
getInstance
().
getQueue
().
schedule
(
this
,
getQuietPeriod
(),
allActions
)!=
null
;
}
/**
...
...
core/src/main/java/hudson/model/ParametersAction.java
浏览文件 @
07198294
...
...
@@ -26,6 +26,7 @@ package hudson.model;
import
hudson.Util
;
import
hudson.EnvVars
;
import
hudson.diagnosis.OldDataMonitor
;
import
hudson.matrix.MatrixChildAction
;
import
hudson.model.Queue.QueueAction
;
import
hudson.model.labels.LabelAssignmentAction
;
import
hudson.model.queue.SubTask
;
...
...
@@ -52,7 +53,7 @@ import java.util.Set;
* that were specified when scheduling.
*/
@ExportedBean
public
class
ParametersAction
implements
Action
,
Iterable
<
ParameterValue
>,
QueueAction
,
EnvironmentContributingAction
,
LabelAssignmentAction
{
public
class
ParametersAction
implements
Action
,
Iterable
<
ParameterValue
>,
QueueAction
,
EnvironmentContributingAction
,
LabelAssignmentAction
,
MatrixChildAction
{
private
final
List
<
ParameterValue
>
parameters
;
...
...
test/src/test/groovy/hudson/matrix/MatrixProjectTest.groovy
浏览文件 @
07198294
...
...
@@ -53,6 +53,13 @@ import hudson.model.FileParameterDefinition
import
hudson.model.Cause.LegacyCodeCause
import
hudson.model.ParametersAction
import
hudson.model.FileParameterValue
import
hudson.model.StringParameterDefinition
import
hudson.model.StringParameterValue
import
hudson.scm.SubversionSCM.SvnInfo
;
import
hudson.scm.RevisionParameterAction
;
import
java.util.List
;
import
java.util.ArrayList
;
import
hudson.model.Action
;
import
java.util.concurrent.CountDownLatch
...
...
@@ -366,4 +373,62 @@ public class MatrixProjectTest extends HudsonTestCase {
assertEquals
4
,
dirs
.
size
()
}
/**
* Test that Actions are passed to configurations
*/
public
void
testParameterActions
()
throws
Exception
{
MatrixProject
p
=
createMatrixProject
();
ParametersDefinitionProperty
pdp
=
new
ParametersDefinitionProperty
(
new
StringParameterDefinition
(
"PARAM_A"
,
"default_a"
),
new
StringParameterDefinition
(
"PARAM_B"
,
"default_b"
),
);
p
.
addProperty
(
pdp
);
ParametersAction
pa
=
new
ParametersAction
(
pdp
.
getParameterDefinitions
().
collect
{
return
it
.
getDefaultParameterValue
()
}
)
MatrixBuild
build
=
p
.
scheduleBuild2
(
0
,
new
LegacyCodeCause
(),
pa
).
get
();
assertEquals
(
4
,
build
.
getRuns
().
size
());
for
(
MatrixRun
run
:
build
.
getRuns
())
{
ParametersAction
pa1
=
run
.
getAction
(
ParametersAction
.
class
);
assertNotNull
(
pa1
);
[
"PARAM_A"
,
"PARAM_B"
].
each
{
assertNotNull
(
pa1
.
getParameter
(
it
))
}
}
}
/**
* Test that other Actions are passed to configurations
* requires supported version of subversion plugin 1.43+
*/
//~ public void testMatrixChildActions() throws Exception {
//~ MatrixProject p = createMatrixProject();
//~ ParametersDefinitionProperty pdp = new ParametersDefinitionProperty(
//~ new StringParameterDefinition("PARAM_A","default_a"),
//~ new StringParameterDefinition("PARAM_B","default_b"),
//~ );
//~ p.addProperty(pdp);
//~ List<Action> actions = new ArrayList<Action>();
//~ actions.add(new RevisionParameterAction(new SvnInfo("http://example.com/svn/repo/",1234)));
//~ actions.add(new ParametersAction( pdp.getParameterDefinitions().collect { return it.getDefaultParameterValue() } ));
//~ MatrixBuild build = p.scheduleBuild2(0,new LegacyCodeCause(), actions).get();
//~ assertEquals(4, build.getRuns().size());
//~ for(MatrixRun run : build.getRuns()) {
//~ ParametersAction pa1 = run.getAction(ParametersAction.class);
//~ assertNotNull(pa1);
//~ ["PARAM_A","PARAM_B"].each{ assertNotNull(pa1.getParameter(it)) };
//~ assertNotNull(run.getAction(RevisionParameterAction.class));
//~ }
//~ }
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录