Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
3b544120
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
提交
3b544120
编写于
7月 26, 2012
作者:
N
Nicolas De Loof
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support variable expansion to define Java path
上级
2ca12ecb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
58 addition
and
11 deletion
+58
-11
core/src/main/java/hudson/os/windows/ManagedWindowsServiceLauncher.java
...java/hudson/os/windows/ManagedWindowsServiceLauncher.java
+58
-11
未找到文件。
core/src/main/java/hudson/os/windows/ManagedWindowsServiceLauncher.java
浏览文件 @
3b544120
...
...
@@ -25,24 +25,23 @@ package hudson.os.windows;
import
static
hudson
.
Util
.
copyStreamAndClose
;
import
static
org
.
jvnet
.
hudson
.
wmi
.
Win32Service
.
Win32OwnProcess
;
import
hudson.EnvVars
;
import
hudson.Extension
;
import
hudson.Util
;
import
hudson.lifecycle.WindowsSlaveInstaller
;
import
hudson.model.AbstractDescribableImpl
;
import
hudson.model.Computer
;
import
hudson.model.Descriptor
;
import
hudson.model.TaskListener
;
import
hudson.model.*
;
import
hudson.os.windows.ManagedWindowsServiceAccount.AnotherUser
;
import
hudson.os.windows.ManagedWindowsServiceAccount.LocalSystem
;
import
hudson.remoting.Channel
;
import
hudson.remoting.Channel.Listener
;
import
hudson.remoting.SocketInputStream
;
import
hudson.remoting.SocketOutputStream
;
import
hudson.slaves.ComputerLauncher
;
import
hudson.slaves.SlaveComputer
;
import
hudson.slaves.*
;
import
hudson.tools.JDKInstaller
;
import
hudson.tools.JDKInstaller.CPU
;
import
hudson.tools.JDKInstaller.Platform
;
import
hudson.util.DescribableList
;
import
hudson.util.IOUtils
;
import
hudson.util.Secret
;
import
hudson.util.jna.DotNet
;
...
...
@@ -233,10 +232,12 @@ public class ManagedWindowsServiceLauncher extends ComputerLauncher {
if
(!
remoteRoot
.
exists
())
remoteRoot
.
mkdirs
();
String
java
=
resolveJava
(
computer
);
try
{
// does Java exist?
logger
.
println
(
"Checking if Java exists"
);
WindowsRemoteProcessLauncher
wrpl
=
new
WindowsRemoteProcessLauncher
(
name
,
auth
);
Process
proc
=
wrpl
.
launch
(
StringUtils
.
defaultIfEmpty
(
javaPath
,
"java"
)
+
" -fullversion"
,
"c:\\"
);
Process
proc
=
wrpl
.
launch
(
"\""
+
java
+
"\
" -fullversion"
,
"c:\\"
);
proc
.
getOutputStream
().
close
();
IOUtils
.
copy
(
proc
.
getInputStream
(),
logger
);
proc
.
getInputStream
().
close
();
...
...
@@ -304,7 +305,7 @@ public class ManagedWindowsServiceLauncher extends ComputerLauncher {
copySlaveJar
(
logger
,
remoteRoot
);
// copy jenkins-slave.xml
String
xml
=
createAndCopyJenkinsSlaveXml
(
id
,
logger
,
remoteRoot
);
String
xml
=
createAndCopyJenkinsSlaveXml
(
java
,
id
,
logger
,
remoteRoot
);
// install it as a service
logger
.
println
(
Messages
.
ManagedWindowsServiceLauncher_RegisteringService
());
...
...
@@ -338,7 +339,7 @@ public class ManagedWindowsServiceLauncher extends ComputerLauncher {
}
slaveService
=
services
.
getService
(
id
);
}
else
{
createAndCopyJenkinsSlaveXml
(
id
,
logger
,
remoteRoot
);
createAndCopyJenkinsSlaveXml
(
java
,
id
,
logger
,
remoteRoot
);
copySlaveJar
(
logger
,
remoteRoot
);
}
...
...
@@ -385,6 +386,52 @@ public class ManagedWindowsServiceLauncher extends ComputerLauncher {
}
}
private
String
resolveJava
(
SlaveComputer
computer
)
{
if
(
StringUtils
.
isNotBlank
(
javaPath
))
{
return
getEnvVars
(
computer
).
expand
(
javaPath
);
}
return
"java"
;
}
// -- duplicates code from ssh-slaves-plugin
private
EnvVars
getEnvVars
(
SlaveComputer
computer
)
{
final
EnvVars
global
=
getEnvVars
(
Jenkins
.
getInstance
());
final
EnvVars
local
=
getEnvVars
(
computer
.
getNode
());
if
(
global
!=
null
)
{
if
(
local
!=
null
)
{
final
EnvVars
merged
=
new
EnvVars
(
global
);
merged
.
overrideAll
(
local
);
return
merged
;
}
else
{
return
global
;
}
}
else
if
(
local
!=
null
)
{
return
local
;
}
else
{
return
new
EnvVars
();
}
}
private
EnvVars
getEnvVars
(
Hudson
h
)
{
return
getEnvVars
(
h
.
getGlobalNodeProperties
());
}
private
EnvVars
getEnvVars
(
Node
n
)
{
return
getEnvVars
(
n
.
getNodeProperties
());
}
private
EnvVars
getEnvVars
(
DescribableList
<
NodeProperty
<?>,
NodePropertyDescriptor
>
dl
)
{
final
EnvironmentVariablesNodeProperty
evnp
=
dl
.
get
(
EnvironmentVariablesNodeProperty
.
class
);
if
(
evnp
==
null
)
{
return
null
;
}
return
evnp
.
getEnvVars
();
}
private
void
checkPort135Access
(
PrintStream
logger
,
String
name
,
InetAddress
host
)
throws
IOException
{
Socket
s
=
new
Socket
();
try
{
...
...
@@ -409,10 +456,10 @@ public class ManagedWindowsServiceLauncher extends ComputerLauncher {
}
}
private
String
createAndCopyJenkinsSlaveXml
(
String
serviceId
,
PrintStream
logger
,
SmbFile
remoteRoot
)
throws
IOException
{
private
String
createAndCopyJenkinsSlaveXml
(
String
java
,
String
serviceId
,
PrintStream
logger
,
SmbFile
remoteRoot
)
throws
IOException
{
logger
.
println
(
Messages
.
ManagedWindowsServiceLauncher_CopyingSlaveXml
());
String
xml
=
WindowsSlaveInstaller
.
generateSlaveXml
(
serviceId
,
StringUtils
.
defaultIfEmpty
(
javaPath
,
"java"
)
+
"w.exe"
,
vmargs
,
"-tcp %BASE%\\port.txt"
);
java
+
"w.exe"
,
vmargs
,
"-tcp %BASE%\\port.txt"
);
copyStreamAndClose
(
new
ByteArrayInputStream
(
xml
.
getBytes
(
"UTF-8"
)),
new
SmbFile
(
remoteRoot
,
"jenkins-slave.xml"
).
getOutputStream
());
return
xml
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录