Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
6d44f7e0
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,发现更多精彩内容 >>
提交
6d44f7e0
编写于
1月 03, 2018
作者:
O
Oleg Nenashev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[JENKINS-48766] - Create restricted API for getting info about Remoting versions
上级
cf158973
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
163 addition
and
1 deletion
+163
-1
core/src/filter/resources/jenkins/slaves/remoting-info.properties
.../filter/resources/jenkins/slaves/remoting-info.properties
+6
-0
core/src/main/java/hudson/TcpSlaveAgentListener.java
core/src/main/java/hudson/TcpSlaveAgentListener.java
+1
-0
core/src/main/java/jenkins/slaves/RemotingVersionInfo.java
core/src/main/java/jenkins/slaves/RemotingVersionInfo.java
+104
-0
core/src/test/java/jenkins/slaves/RemotingVersionInfoTest.java
...src/test/java/jenkins/slaves/RemotingVersionInfoTest.java
+47
-0
pom.xml
pom.xml
+5
-1
未找到文件。
core/src/filter/resources/jenkins/slaves/remoting-info.properties
0 → 100644
浏览文件 @
6d44f7e0
# Remoting version, which is embedded into the core
# This version MAY differ from what is really classloaded (see the "Pluggable Core Components", JENKINS-41196)
remoting.embedded.version
=
${remoting.version}
# Minimal Remoting version on external agents which is supported by the core
remoting.minimal.supported.version
=
${remoting.minimal.supported.version}
core/src/main/java/hudson/TcpSlaveAgentListener.java
浏览文件 @
6d44f7e0
...
...
@@ -290,6 +290,7 @@ public final class TcpSlaveAgentListener extends Thread {
try
{
Writer
o
=
new
OutputStreamWriter
(
s
.
getOutputStream
(),
"UTF-8"
);
//TODO: expose version about minimal supported Remoting version (JENKINS-48766)
if
(
header
.
startsWith
(
"GET / "
))
{
o
.
write
(
"HTTP/1.0 200 OK\r\n"
);
o
.
write
(
"Content-Type: text/plain;charset=UTF-8\r\n"
);
...
...
core/src/main/java/jenkins/slaves/RemotingVersionInfo.java
0 → 100644
浏览文件 @
6d44f7e0
/*
* The MIT License
*
* Copyright (c) 2018, CloudBees, Inc.
*
* 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.slaves
;
import
hudson.util.VersionNumber
;
import
org.kohsuke.accmod.Restricted
;
import
org.kohsuke.accmod.restrictions.NoExternalUse
;
import
javax.annotation.CheckForNull
;
import
javax.annotation.Nonnull
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.Properties
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
// TODO: Make the API public (JENKINS-48766)
/**
* Provides information about Remoting versions used withing the core.
* @author Oleg Nenashev
* @since TODO
*/
@Restricted
(
NoExternalUse
.
class
)
public
class
RemotingVersionInfo
{
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
RemotingVersionInfo
.
class
.
getName
());
private
static
final
String
RESOURCE_NAME
=
"remoting-info.properties"
;
@CheckForNull
private
static
VersionNumber
EMBEDDED_VERSION
;
@CheckForNull
private
static
VersionNumber
MINIMAL_SUPPORTED_VERSION
;
private
RemotingVersionInfo
()
{}
static
{
Properties
props
=
new
Properties
();
try
(
InputStream
is
=
RemotingVersionInfo
.
class
.
getResourceAsStream
(
RESOURCE_NAME
))
{
if
(
is
!=
null
)
{
props
.
load
(
is
);
}
}
catch
(
IOException
e
)
{
LOGGER
.
log
(
Level
.
WARNING
,
"Failed to load Remoting Info from "
+
RESOURCE_NAME
,
e
);
}
EMBEDDED_VERSION
=
tryExtractVersion
(
props
,
"remoting.embedded.version"
);
MINIMAL_SUPPORTED_VERSION
=
tryExtractVersion
(
props
,
"remoting.minimal.supported.version"
);
}
@CheckForNull
private
static
VersionNumber
tryExtractVersion
(
@Nonnull
Properties
props
,
@Nonnull
String
propertyName
)
{
String
prop
=
props
.
getProperty
(
propertyName
);
if
(
prop
==
null
)
{
LOGGER
.
log
(
Level
.
FINE
,
"Property {0} is not defined in {1}"
,
new
Object
[]
{
propertyName
,
RESOURCE_NAME
});
return
null
;
}
if
(
prop
.
contains
(
"${"
))
{
// Due to whatever reason, Maven does not nullify them
LOGGER
.
log
(
Level
.
WARNING
,
"Property {0} in {1} has unresolved variable(s). Raw value: {2}"
,
new
Object
[]
{
propertyName
,
RESOURCE_NAME
,
prop
});
return
null
;
}
try
{
return
new
VersionNumber
(
prop
);
}
catch
(
RuntimeException
ex
)
{
LOGGER
.
log
(
Level
.
WARNING
,
String
.
format
(
"Failed to parse version for for property %s in %s. Raw Value: %s"
,
propertyName
,
RESOURCE_NAME
,
prop
),
ex
);
return
null
;
}
}
@CheckForNull
public
static
VersionNumber
getEmbeddedVersion
()
{
return
EMBEDDED_VERSION
;
}
@CheckForNull
public
static
VersionNumber
getMinimalSupportedVersion
()
{
return
MINIMAL_SUPPORTED_VERSION
;
}
}
core/src/test/java/jenkins/slaves/RemotingVersionInfoTest.java
0 → 100644
浏览文件 @
6d44f7e0
/*
* The MIT License
*
* Copyright (c) 2018, CloudBees, Inc.
*
* 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.slaves
;
import
org.junit.Test
;
import
static
org
.
hamcrest
.
CoreMatchers
.*;
import
static
org
.
junit
.
Assert
.
assertThat
;
/**
* Tests for {@link RemotingVersionInfo}.
*/
public
class
RemotingVersionInfoTest
{
@Test
public
void
shouldLoadEmbeddedVersionByDefault
()
{
assertThat
(
"Remoting Embedded version is not defined"
,
RemotingVersionInfo
.
getEmbeddedVersion
(),
notNullValue
());
}
@Test
public
void
shouldLoadMinimalSupportedVersionByDefault
()
{
assertThat
(
"Remoting Minimal supported version is not defined"
,
RemotingVersionInfo
.
getMinimalSupportedVersion
(),
notNullValue
());
}
}
pom.xml
浏览文件 @
6d44f7e0
...
...
@@ -104,6 +104,10 @@ THE SOFTWARE.
<maven-war-plugin.version>
3.0.0
</maven-war-plugin.version>
<!-- JENKINS-47127 bump when 3.2.0 is out. Cf. MWAR-407 -->
<!-- Minimal Remoting version, which is tested for API compatibility -->
<remoting.version>
3.15
</remoting.version>
<remoting.minimal.supported.version>
2.60
</remoting.minimal.supported.version>
</properties>
<!-- Note that the 'repositories' and 'pluginRepositories' blocks below are actually copy-pasted
...
...
@@ -175,7 +179,7 @@ THE SOFTWARE.
<dependency>
<groupId>
org.jenkins-ci.main
</groupId>
<artifactId>
remoting
</artifactId>
<version>
3.15
</version>
<version>
${remoting.version}
</version>
</dependency>
<dependency>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录