Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
de9002b3
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,发现更多精彩内容 >>
提交
de9002b3
编写于
1月 23, 2013
作者:
J
Jesse Glick
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FIXED JENKINS-16462] Run parameters do not support folders.
上级
1979302f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
81 addition
and
10 deletion
+81
-10
changelog.html
changelog.html
+3
-0
core/src/main/java/hudson/model/AutoCompletionCandidates.java
.../src/main/java/hudson/model/AutoCompletionCandidates.java
+2
-1
core/src/main/java/hudson/model/Run.java
core/src/main/java/hudson/model/Run.java
+2
-3
core/src/main/java/hudson/model/RunParameterDefinition.java
core/src/main/java/hudson/model/RunParameterDefinition.java
+7
-1
core/src/main/resources/hudson/model/RunParameterDefinition/config.jelly
...esources/hudson/model/RunParameterDefinition/config.jelly
+1
-5
test/src/test/java/hudson/model/RunParameterDefinitionTest.java
...rc/test/java/hudson/model/RunParameterDefinitionTest.java
+66
-0
未找到文件。
changelog.html
浏览文件 @
de9002b3
...
...
@@ -58,6 +58,9 @@ Upcoming changes</a>
<li
class=
bug
>
Bogus “Build Record Root Directory” inadequately diagnosed.
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-16457"
>
issue 16457
</a>
)
<li
class=
bug
>
Run parameters do not support folders.
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-16462"
>
issue 16462
</a>
)
</ul>
</div>
<!--=TRUNK-END=-->
...
...
core/src/main/java/hudson/model/AutoCompletionCandidates.java
浏览文件 @
de9002b3
...
...
@@ -36,6 +36,7 @@ import java.io.IOException;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
javax.annotation.CheckForNull
;
/**
* Data representation of the auto-completion candidates.
...
...
@@ -86,7 +87,7 @@ public class AutoCompletionCandidates implements HttpResponse {
* @param container
* The nearby contextual {@link ItemGroup} to resolve relative job names from.
*/
public
static
<
T
extends
Item
>
AutoCompletionCandidates
ofJobNames
(
final
Class
<
T
>
type
,
final
String
value
,
Item
self
,
ItemGroup
container
)
{
public
static
<
T
extends
Item
>
AutoCompletionCandidates
ofJobNames
(
final
Class
<
T
>
type
,
final
String
value
,
@CheckForNull
Item
self
,
ItemGroup
container
)
{
if
(
self
==
container
)
container
=
self
.
getParent
();
...
...
core/src/main/java/hudson/model/Run.java
浏览文件 @
de9002b3
...
...
@@ -101,7 +101,6 @@ import jenkins.model.Jenkins;
import
jenkins.model.JenkinsLocationConfiguration
;
import
jenkins.util.io.OnMaster
;
import
net.sf.json.JSONObject
;
import
org.apache.commons.io.input.NullInputStream
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.jelly.XMLOutput
;
import
org.kohsuke.accmod.Restricted
;
...
...
@@ -2028,7 +2027,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
}
public
String
getExternalizableId
()
{
return
project
.
getName
()
+
"#"
+
getNumber
();
return
project
.
get
Full
Name
()
+
"#"
+
getNumber
();
}
public
static
Run
<?,?>
fromExternalizableId
(
String
id
)
{
...
...
@@ -2039,7 +2038,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
String
jobName
=
id
.
substring
(
0
,
hash
);
int
number
=
Integer
.
parseInt
(
id
.
substring
(
hash
+
1
));
Job
<?,?>
job
=
(
Job
<?,?>)
Jenkins
.
getInstance
().
getItem
(
jobName
);
Job
<?,?>
job
=
Jenkins
.
getInstance
().
getItemByFullName
(
jobName
,
Job
.
class
);
return
job
.
getBuildByNumber
(
number
);
}
...
...
core/src/main/java/hudson/model/RunParameterDefinition.java
浏览文件 @
de9002b3
...
...
@@ -30,6 +30,7 @@ import org.kohsuke.stapler.DataBoundConstructor;
import
org.kohsuke.stapler.StaplerRequest
;
import
org.kohsuke.stapler.export.Exported
;
import
hudson.Extension
;
import
org.kohsuke.stapler.QueryParameter
;
public
class
RunParameterDefinition
extends
SimpleParameterDefinition
{
...
...
@@ -65,7 +66,7 @@ public class RunParameterDefinition extends SimpleParameterDefinition {
}
public
Job
getProject
()
{
return
(
Job
)
Jenkins
.
getInstance
().
getItem
(
projectName
);
return
Jenkins
.
getInstance
().
getItemByFullName
(
projectName
,
Job
.
class
);
}
@Extension
...
...
@@ -84,6 +85,11 @@ public class RunParameterDefinition extends SimpleParameterDefinition {
public
ParameterDefinition
newInstance
(
StaplerRequest
req
,
JSONObject
formData
)
throws
FormException
{
return
req
.
bindJSON
(
RunParameterDefinition
.
class
,
formData
);
}
public
AutoCompletionCandidates
doAutoCompleteProjectName
(
@QueryParameter
String
value
)
{
return
AutoCompletionCandidates
.
ofJobNames
(
Job
.
class
,
value
,
null
,
Jenkins
.
getInstance
());
}
}
@Override
...
...
core/src/main/resources/hudson/model/RunParameterDefinition/config.jelly
浏览文件 @
de9002b3
...
...
@@ -30,11 +30,7 @@ THE SOFTWARE.
<f:textbox name="parameter.name" value="${instance.name}" />
</f:entry>
<f:entry title="${%Project}" help="/help/parameter/run-project.html">
<select name="parameter.projectName">
<j:forEach var="project" items="${app.items}">
<f:option selected="${instance.project==project}">${project.displayName}</f:option>
</j:forEach>
</select>
<f:textbox name="parameter.projectName" value="${instance.projectName}" autoCompleteField="projectName"/>
</f:entry>
<f:entry title="${%Description}" help="/help/parameter/description.html">
<f:textarea name="parameter.description" value="${instance.description}" />
...
...
test/src/test/java/hudson/model/RunParameterDefinitionTest.java
0 → 100644
浏览文件 @
de9002b3
/*
* The MIT License
*
* Copyright 2013 Jesse Glick.
*
* 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.model
;
import
hudson.EnvVars
;
import
static
org
.
junit
.
Assert
.*;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.jvnet.hudson.test.Bug
;
import
org.jvnet.hudson.test.JenkinsRule
;
import
org.jvnet.hudson.test.MockFolder
;
public
class
RunParameterDefinitionTest
{
@Rule
public
JenkinsRule
j
=
new
JenkinsRule
();
@Bug
(
16462
)
@Test
public
void
inFolders
()
throws
Exception
{
MockFolder
dir
=
j
.
createFolder
(
"dir"
);
MockFolder
subdir
=
dir
.
createProject
(
MockFolder
.
class
,
"sub dir"
);
FreeStyleProject
p
=
subdir
.
createProject
(
FreeStyleProject
.
class
,
"some project"
);
p
.
scheduleBuild2
(
0
).
get
();
FreeStyleBuild
build2
=
p
.
scheduleBuild2
(
0
).
get
();
p
.
scheduleBuild2
(
0
).
get
();
String
id
=
build2
.
getExternalizableId
();
assertEquals
(
"dir/sub dir/some project#2"
,
id
);
assertEquals
(
build2
,
Run
.
fromExternalizableId
(
id
));
RunParameterDefinition
def
=
new
RunParameterDefinition
(
"build"
,
"dir/sub dir/some project"
,
"my build"
);
assertEquals
(
"dir/sub dir/some project"
,
def
.
getProjectName
());
assertEquals
(
p
,
def
.
getProject
());
EnvVars
env
=
new
EnvVars
();
def
.
getDefaultParameterValue
().
buildEnvVars
(
null
,
env
);
assertEquals
(
j
.
jenkins
.
getRootUrl
()
+
"job/dir/job/sub%20dir/job/some%20project/3/"
,
env
.
get
(
"build"
));
RunParameterValue
val
=
def
.
createValue
(
id
);
assertEquals
(
build2
,
val
.
getRun
());
assertEquals
(
"dir/sub dir/some project"
,
val
.
getJobName
());
assertEquals
(
"2"
,
val
.
getNumber
());
val
.
buildEnvVars
(
null
,
env
);
assertEquals
(
j
.
jenkins
.
getRootUrl
()
+
"job/dir/job/sub%20dir/job/some%20project/2/"
,
env
.
get
(
"build"
));
assertEquals
(
"dir/sub dir/some project"
,
env
.
get
(
"build.jobName"
));
assertEquals
(
"2"
,
env
.
get
(
"build.number"
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录