Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
a8f5cd5e
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,发现更多精彩内容 >>
提交
a8f5cd5e
编写于
12月 23, 2011
作者:
K
Kohsuke Kawaguchi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
splitting out a new tag to configure a TCP/IP port for a daemon
上级
8b92f50f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
93 addition
and
40 deletion
+93
-40
core/src/main/groovy/jenkins/util/ServerTcpPort.java
core/src/main/groovy/jenkins/util/ServerTcpPort.java
+35
-0
core/src/main/java/hudson/security/GlobalSecurityConfiguration.java
...ain/java/hudson/security/GlobalSecurityConfiguration.java
+11
-18
core/src/main/resources/hudson/security/GlobalSecurityConfiguration/config.groovy
...hudson/security/GlobalSecurityConfiguration/config.groovy
+1
-22
core/src/main/resources/lib/form/serverTcpPort.groovy
core/src/main/resources/lib/form/serverTcpPort.groovy
+46
-0
未找到文件。
core/src/main/groovy/jenkins/util/ServerTcpPort.java
0 → 100644
浏览文件 @
a8f5cd5e
package
jenkins.util
;
import
net.sf.json.JSONObject
;
import
org.kohsuke.stapler.DataBoundConstructor
;
/**
* Used in conjunction with /lib/form/serverTcpPort tag to parse the submitted JSON back into a port number.
*
* @author Kohsuke Kawaguchi
* @since 1.445
*/
public
class
ServerTcpPort
{
private
int
value
;
private
String
type
;
@DataBoundConstructor
public
ServerTcpPort
(
int
value
,
String
type
)
{
this
.
value
=
value
;
this
.
type
=
type
;
}
public
ServerTcpPort
(
JSONObject
o
)
{
type
=
o
.
getString
(
"type"
);
value
=
o
.
optInt
(
"value"
);
}
/**
* Parses the value back into the port number
*/
public
int
getPort
()
{
if
(
type
.
equals
(
"fixed"
))
return
value
;
if
(
type
.
equals
(
"random"
))
return
0
;
return
-
1
;
}
}
core/src/main/java/hudson/security/GlobalSecurityConfiguration.java
浏览文件 @
a8f5cd5e
...
...
@@ -27,6 +27,7 @@ import hudson.Extension;
import
hudson.markup.MarkupFormatter
;
import
jenkins.model.GlobalConfiguration
;
import
jenkins.model.Jenkins
;
import
jenkins.util.ServerTcpPort
;
import
net.sf.json.JSONObject
;
import
org.kohsuke.stapler.StaplerRequest
;
...
...
@@ -43,34 +44,26 @@ public class GlobalSecurityConfiguration extends GlobalConfiguration {
return
Jenkins
.
getInstance
().
getMarkupFormatter
();
}
public
int
getSlaveAgentPort
()
{
return
Jenkins
.
getInstance
().
getSlaveAgentPort
();
}
@Override
public
boolean
configure
(
StaplerRequest
req
,
JSONObject
json
)
throws
FormException
{
// for compatibility reasons, the actual value is stored in Jenkins
Jenkins
j
=
Jenkins
.
getInstance
();
try
{
String
v
=
req
.
getParameter
(
"slaveAgentPortType"
);
if
(!
j
.
isUseSecurity
()
||
v
==
null
||
v
.
equals
(
"random"
))
j
.
setSlaveAgentPort
(
0
);
else
if
(
v
.
equals
(
"disable"
))
j
.
setSlaveAgentPort
(-
1
);
else
{
try
{
j
.
setSlaveAgentPort
(
Integer
.
parseInt
(
req
.
getParameter
(
"slaveAgentPort"
)));
}
catch
(
NumberFormatException
e
)
{
throw
new
FormException
(
jenkins
.
model
.
Messages
.
Hudson_BadPortNumber
(
req
.
getParameter
(
"slaveAgentPort"
)),
"slaveAgentPort"
);
}
}
}
catch
(
IOException
e
)
{
throw
new
FormException
(
e
,
"slaveAgentPortType"
);
}
if
(
json
.
has
(
"useSecurity"
))
{
JSONObject
security
=
json
.
getJSONObject
(
"useSecurity"
);
j
.
setSecurityRealm
(
SecurityRealm
.
all
().
newInstanceFromRadioList
(
security
,
"realm"
));
j
.
setAuthorizationStrategy
(
AuthorizationStrategy
.
all
().
newInstanceFromRadioList
(
security
,
"authorization"
));
try
{
j
.
setSlaveAgentPort
(
new
ServerTcpPort
(
security
.
getJSONObject
(
"slaveAgentPort"
)).
getPort
());
}
catch
(
IOException
e
)
{
throw
new
FormException
(
e
,
"slaveAgentPortType"
);
}
if
(
security
.
has
(
"markupFormatter"
))
{
j
.
setMarkupFormatter
(
req
.
bindJSON
(
MarkupFormatter
.
class
,
security
.
getJSONObject
(
"markupFormatter"
)));
}
else
{
...
...
core/src/main/resources/hudson/security/GlobalSecurityConfiguration/config.groovy
浏览文件 @
a8f5cd5e
...
...
@@ -7,28 +7,7 @@ def f=namespace(lib.FormTagLib)
f
.
optionalBlock
(
field:
"useSecurity"
,
title:
_
(
"Enable security"
),
checked:
app
.
useSecurity
)
{
f
.
entry
(
title:
_
(
"TCP port for JNLP slave agents"
),
field:
"slaveAgentPort"
)
{
int
port
=
app
.
slaveAgentPort
f
.
radio
(
name:
"slaveAgentPortType"
,
value:
"fixed"
,
id:
"sat.fixed"
,
checked:
port
>
0
,
onclick:
"\$('sat.port').disabled=false"
)
label
(
"for"
:
"sat.fixed"
,
_
(
"Fixed"
))
text
(
" : "
)
input
(
type:
"number"
,
"class"
:
"number"
,
name:
"slaveAgentPort"
,
id:
"sat.port"
,
value:
port
>
0
?
port
:
null
,
disabled:
port
>
0
?
null
:
"true"
,
min:
0
,
max:
65535
,
step:
1
)
raw
(
" "
)
////////////////////////////
f
.
radio
(
name:
"slaveAgentPortType"
,
value:
"random"
,
id:
"sat.random"
,
checked:
port
==
0
,
onclick:
"\$('sat.port').disabled=true"
)
label
(
"for"
:
"sat.random"
,
_
(
"Random"
))
raw
(
" "
)
////////////////////////////
f
.
radio
(
name:
"slaveAgentPortType"
,
value:
"disable"
,
id:
"sat.disabled"
,
checked:
port
==-
1
,
onclick:
"\$('sat.port').disabled=true"
)
label
(
"for"
:
"sat.disabled"
,
_
(
"Disable"
))
f
.
serverTcpPort
()
}
f
.
dropdownDescriptorSelector
(
title:
_
(
"Markup Formatter"
),
field:
"markupFormatter"
)
...
...
core/src/main/resources/lib/form/serverTcpPort.groovy
0 → 100644
浏览文件 @
a8f5cd5e
package
lib.form
/**
* Generates a UI for selecting server TCP/IP port (for some kind of daemon, typically)
*
* The user can specify a fixed port (1-65535), or let Jenkins allocate random port (0), or disable it (-1).
*
* On the databinding side, use {@link jenkins.util.ServerTcpPort} to handle this structure back into a single
* port number. The getter method should just expose the port number integer.
*/
int
port
=
instance
?
instance
[
field
]:
0
;
def
f
=
namespace
(
lib
.
FormTagLib
)
def
type
=
"${field}.type"
def
id
=
"${field}Id"
// TODO: get rid of this
div
(
name:
field
)
{
label
{
f
.
radio
(
name:
type
,
value:
"fixed"
,
checked:
port
>
0
,
onclick:
"\$('${id}').disabled=false"
)
text
(
_
(
"Fixed"
))
text
(
" : "
)
}
input
(
type:
"number"
,
"class"
:
"number"
,
name:
"value"
,
id:
id
,
value:
port
>
0
?
port
:
null
,
disabled:
port
>
0
?
null
:
"true"
,
min:
0
,
max:
65535
,
step:
1
)
raw
(
" "
)
////////////////////////////
label
{
f
.
radio
(
name:
type
,
value:
"random"
,
checked:
port
==
0
,
onclick:
"\$('{id}').disabled=true"
)
text
(
_
(
"Random"
))
}
raw
(
" "
)
////////////////////////////
label
{
f
.
radio
(
name:
type
,
value:
"disable"
,
checked:
port
==-
1
,
onclick:
"\$('{id}').disabled=true"
)
text
(
_
(
"Disable"
))
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录