Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
730d6ecb
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,发现更多精彩内容 >>
提交
730d6ecb
编写于
10月 24, 2015
作者:
O
Oleg Nenashev
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1528 from Wilfred/better_default_text
[JENKINS-755] Describe the built-in JDK as '(System)'.
上级
6a7b8981
19511a11
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
74 addition
and
4 deletion
+74
-4
core/src/main/java/hudson/model/AbstractProject.java
core/src/main/java/hudson/model/AbstractProject.java
+1
-1
core/src/main/java/hudson/model/JDK.java
core/src/main/java/hudson/model/JDK.java
+13
-2
core/src/main/java/jenkins/model/Jenkins.java
core/src/main/java/jenkins/model/Jenkins.java
+1
-1
core/src/test/java/jenkins/model/JDKNameTest.java
core/src/test/java/jenkins/model/JDKNameTest.java
+59
-0
未找到文件。
core/src/main/java/hudson/model/AbstractProject.java
浏览文件 @
730d6ecb
...
...
@@ -358,7 +358,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
jdkTool
=
jdkTool
.
forNode
(
node
,
listener
);
}
jdkTool
.
buildEnvVars
(
env
);
}
else
if
(
jdk
!=
null
&&
!
jdk
.
equals
(
JDK
.
DEFAULT_NAME
))
{
}
else
if
(
!
JDK
.
isDefaultName
(
jdk
))
{
listener
.
getLogger
().
println
(
"No JDK named ‘"
+
jdk
+
"’ found"
);
}
...
...
core/src/main/java/hudson/model/JDK.java
浏览文件 @
730d6ecb
...
...
@@ -45,6 +45,8 @@ import java.util.Collections;
import
jenkins.model.Jenkins
;
import
org.kohsuke.stapler.DataBoundConstructor
;
import
org.kohsuke.accmod.Restricted
;
import
org.kohsuke.accmod.restrictions.NoExternalUse
;
/**
* Information about JDK installation.
...
...
@@ -54,10 +56,19 @@ import org.kohsuke.stapler.DataBoundConstructor;
public
final
class
JDK
extends
ToolInstallation
implements
NodeSpecific
<
JDK
>,
EnvironmentSpecific
<
JDK
>
{
/**
* Name of the “
default JDK”, meaning no specific JDK selected
.
* Name of the “
System JDK”, which is just the JDK on Jenkins' $PATH
.
* @since 1.577
*/
public
static
final
String
DEFAULT_NAME
=
"(Default)"
;
public
static
final
String
DEFAULT_NAME
=
"(System)"
;
@Restricted
(
NoExternalUse
.
class
)
public
static
boolean
isDefaultName
(
String
name
)
{
if
(
"(Default)"
.
equals
(
name
))
{
// DEFAULT_NAME took this value prior to 1.598.
return
true
;
}
return
DEFAULT_NAME
.
equals
(
name
);
}
/**
* @deprecated since 2009-02-25
...
...
core/src/main/java/jenkins/model/Jenkins.java
浏览文件 @
730d6ecb
...
...
@@ -3670,7 +3670,7 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
* If the user chose the default JDK, make sure we got 'java' in PATH.
*/
public
FormValidation
doDefaultJDKCheck
(
StaplerRequest
request
,
@QueryParameter
String
value
)
{
if
(!
value
.
equals
(
JDK
.
DEFAULT_NAME
))
if
(!
JDK
.
isDefaultName
(
value
))
// assume the user configured named ones properly in system config ---
// or else system config should have reported form field validation errors.
return
FormValidation
.
ok
();
...
...
core/src/test/java/jenkins/model/JDKNameTest.java
0 → 100644
浏览文件 @
730d6ecb
/*
* The MIT License
*
* Copyright (c) 2014
*
* 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
jenkins.model
;
import
static
org
.
hamcrest
.
CoreMatchers
.
equalTo
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
hudson.model.JDK
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.jvnet.hudson.test.Issue
;
import
org.powermock.modules.junit4.PowerMockRunner
;
@RunWith
(
PowerMockRunner
.
class
)
public
class
JDKNameTest
{
@Test
public
void
nullIsNotDefaultName
()
{
assertThat
(
JDK
.
isDefaultName
(
null
),
is
(
false
));
}
@Test
public
void
recognizeOldDefaultName
()
{
// DEFAULT_NAME took this value prior to 1.598.
assertThat
(
JDK
.
isDefaultName
(
"(Default)"
),
is
(
true
));
}
@Test
public
void
recognizeDefaultName
()
{
assertThat
(
JDK
.
isDefaultName
(
JDK
.
DEFAULT_NAME
),
is
(
true
));
}
@Test
public
void
othernameNotDefault
()
{
assertThat
(
JDK
.
isDefaultName
(
"I'm a customized name"
),
is
(
false
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录