Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
52b25711
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,发现更多精彩内容 >>
提交
52b25711
编写于
4月 19, 2014
作者:
K
Kohsuke Kawaguchi
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #737
Conflicts: core/src/main/java/hudson/model/UpdateCenter.java
上级
1d5653a9
d1fb126b
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
120 addition
and
68 deletion
+120
-68
core/src/main/java/hudson/Main.java
core/src/main/java/hudson/Main.java
+26
-19
core/src/main/java/hudson/console/ConsoleNote.java
core/src/main/java/hudson/console/ConsoleNote.java
+12
-6
core/src/main/java/hudson/lifecycle/WindowsServiceLifecycle.java
...c/main/java/hudson/lifecycle/WindowsServiceLifecycle.java
+5
-2
core/src/main/java/hudson/model/FileParameterValue.java
core/src/main/java/hudson/model/FileParameterValue.java
+10
-6
core/src/main/java/hudson/model/Run.java
core/src/main/java/hudson/model/Run.java
+3
-2
core/src/main/java/hudson/model/UpdateCenter.java
core/src/main/java/hudson/model/UpdateCenter.java
+10
-6
core/src/main/java/hudson/model/UsageStatistics.java
core/src/main/java/hudson/model/UsageStatistics.java
+6
-2
core/src/main/java/hudson/scm/SCM.java
core/src/main/java/hudson/scm/SCM.java
+5
-1
core/src/main/java/hudson/tools/JDKInstaller.java
core/src/main/java/hudson/tools/JDKInstaller.java
+5
-2
core/src/main/java/hudson/triggers/SCMTrigger.java
core/src/main/java/hudson/triggers/SCMTrigger.java
+6
-2
core/src/main/java/hudson/util/CompressedFile.java
core/src/main/java/hudson/util/CompressedFile.java
+8
-5
core/src/main/java/hudson/util/io/ZipArchiver.java
core/src/main/java/hudson/util/io/ZipArchiver.java
+7
-4
core/src/main/java/jenkins/model/Jenkins.java
core/src/main/java/jenkins/model/Jenkins.java
+5
-1
core/src/test/java/hudson/util/io/ZipArchiverTest.java
core/src/test/java/hudson/util/io/ZipArchiverTest.java
+12
-10
未找到文件。
core/src/main/java/hudson/Main.java
浏览文件 @
52b25711
...
...
@@ -137,23 +137,27 @@ public class Main {
FileOutputStream
os
=
new
FileOutputStream
(
tmpFile
);
Writer
w
=
new
OutputStreamWriter
(
os
,
"UTF-8"
);
w
.
write
(
"<?xml version='1.0' encoding='UTF-8'?>"
);
w
.
write
(
"<run><log encoding='hexBinary' content-encoding='"
+
Charset
.
defaultCharset
().
name
()+
"'>"
);
w
.
flush
();
// run the command
long
start
=
System
.
currentTimeMillis
();
List
<
String
>
cmd
=
new
ArrayList
<
String
>();
for
(
int
i
=
1
;
i
<
args
.
length
;
i
++
)
cmd
.
add
(
args
[
i
]);
Proc
proc
=
new
Proc
.
LocalProc
(
cmd
.
toArray
(
new
String
[
0
]),(
String
[])
null
,
System
.
in
,
new
DualOutputStream
(
System
.
out
,
new
EncodingStream
(
os
)));
int
ret
=
proc
.
join
();
w
.
write
(
"</log><result>"
+
ret
+
"</result><duration>"
+(
System
.
currentTimeMillis
()-
start
)+
"</duration></run>"
);
w
.
close
();
int
ret
;
try
{
w
.
write
(
"<?xml version='1.0' encoding='UTF-8'?>"
);
w
.
write
(
"<run><log encoding='hexBinary' content-encoding='"
+
Charset
.
defaultCharset
().
name
()+
"'>"
);
w
.
flush
();
// run the command
long
start
=
System
.
currentTimeMillis
();
List
<
String
>
cmd
=
new
ArrayList
<
String
>();
for
(
int
i
=
1
;
i
<
args
.
length
;
i
++
)
cmd
.
add
(
args
[
i
]);
Proc
proc
=
new
Proc
.
LocalProc
(
cmd
.
toArray
(
new
String
[
0
]),(
String
[])
null
,
System
.
in
,
new
DualOutputStream
(
System
.
out
,
new
EncodingStream
(
os
)));
ret
=
proc
.
join
();
w
.
write
(
"</log><result>"
+
ret
+
"</result><duration>"
+(
System
.
currentTimeMillis
()-
start
)+
"</duration></run>"
);
}
finally
{
IOUtils
.
closeQuietly
(
w
);
}
URL
location
=
new
URL
(
jobURL
,
"postBuildResult"
);
while
(
true
)
{
...
...
@@ -170,8 +174,11 @@ public class Main {
con
.
connect
();
// send the data
FileInputStream
in
=
new
FileInputStream
(
tmpFile
);
Util
.
copyStream
(
in
,
con
.
getOutputStream
());
in
.
close
();
try
{
Util
.
copyStream
(
in
,
con
.
getOutputStream
());
}
finally
{
IOUtils
.
closeQuietly
(
in
);
}
if
(
con
.
getResponseCode
()!=
200
)
{
Util
.
copyStream
(
con
.
getErrorStream
(),
System
.
err
);
...
...
core/src/main/java/hudson/console/ConsoleNote.java
浏览文件 @
52b25711
...
...
@@ -171,16 +171,22 @@ public abstract class ConsoleNote<T> implements Serializable, Describable<Consol
private
ByteArrayOutputStream
encodeToBytes
()
throws
IOException
{
ByteArrayOutputStream
buf
=
new
ByteArrayOutputStream
();
ObjectOutputStream
oos
=
new
ObjectOutputStream
(
new
GZIPOutputStream
(
buf
));
oos
.
writeObject
(
this
);
oos
.
close
();
try
{
oos
.
writeObject
(
this
);
}
finally
{
oos
.
close
();
}
ByteArrayOutputStream
buf2
=
new
ByteArrayOutputStream
();
DataOutputStream
dos
=
new
DataOutputStream
(
new
Base64OutputStream
(
buf2
,
true
,-
1
,
null
));
buf2
.
write
(
PREAMBLE
);
dos
.
writeInt
(
buf
.
size
());
buf
.
writeTo
(
dos
);
dos
.
close
();
try
{
buf2
.
write
(
PREAMBLE
);
dos
.
writeInt
(
buf
.
size
());
buf
.
writeTo
(
dos
);
}
finally
{
dos
.
close
();
}
buf2
.
write
(
POSTAMBLE
);
return
buf2
;
}
...
...
core/src/main/java/hudson/lifecycle/WindowsServiceLifecycle.java
浏览文件 @
52b25711
...
...
@@ -111,8 +111,11 @@ public class WindowsServiceLifecycle extends Lifecycle {
File
copyFiles
=
new
File
(
rootDir
,
baseName
+
".copies"
);
FileWriter
w
=
new
FileWriter
(
copyFiles
,
true
);
w
.
write
(
by
.
getAbsolutePath
()+
'>'
+
getHudsonWar
().
getAbsolutePath
()+
'\n'
);
w
.
close
();
try
{
w
.
write
(
by
.
getAbsolutePath
()+
'>'
+
getHudsonWar
().
getAbsolutePath
()+
'\n'
);
}
finally
{
w
.
close
();
}
}
@Override
...
...
core/src/main/java/hudson/model/FileParameterValue.java
浏览文件 @
52b25711
...
...
@@ -197,12 +197,16 @@ public class FileParameterValue extends ParameterValue {
File
fileParameter
=
getLocationUnderBuild
(
build
);
if
(
fileParameter
.
isFile
())
{
InputStream
data
=
new
FileInputStream
(
fileParameter
);
long
lastModified
=
fileParameter
.
lastModified
();
long
contentLength
=
fileParameter
.
length
();
if
(
request
.
hasParameter
(
"view"
))
{
response
.
serveFile
(
request
,
data
,
lastModified
,
contentLength
,
"plain.txt"
);
}
else
{
response
.
serveFile
(
request
,
data
,
lastModified
,
contentLength
,
originalFileName
);
try
{
long
lastModified
=
fileParameter
.
lastModified
();
long
contentLength
=
fileParameter
.
length
();
if
(
request
.
hasParameter
(
"view"
))
{
response
.
serveFile
(
request
,
data
,
lastModified
,
contentLength
,
"plain.txt"
);
}
else
{
response
.
serveFile
(
request
,
data
,
lastModified
,
contentLength
,
originalFileName
);
}
}
finally
{
IOUtils
.
closeQuietly
(
data
);
}
}
}
...
...
core/src/main/java/hudson/model/Run.java
浏览文件 @
52b25711
...
...
@@ -2082,8 +2082,9 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
}
finally
{
IOUtils
.
closeQuietly
(
input
);
}
}
out
.
close
();
}
finally
{
IOUtils
.
closeQuietly
(
out
);
}
}
/**
...
...
core/src/main/java/hudson/model/UpdateCenter.java
浏览文件 @
52b25711
...
...
@@ -45,6 +45,8 @@ import hudson.util.DaemonThreadFactory;
import
hudson.util.FormValidation
;
import
hudson.util.HttpResponses
;
import
hudson.util.NamingThreadFactory
;
import
hudson.util.IOException2
;
import
hudson.util.IOUtils
;
import
hudson.util.PersistedList
;
import
hudson.util.XStream2
;
import
jenkins.RestartRequiredException
;
...
...
@@ -745,16 +747,18 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas
* @see DownloadJob
*/
public
File
download
(
DownloadJob
job
,
URL
src
)
throws
IOException
{
CountingInputStream
in
=
null
;
OutputStream
out
=
null
;
try
{
URLConnection
con
=
connect
(
job
,
src
);
int
total
=
con
.
getContentLength
();
CountingInputStream
in
=
new
CountingInputStream
(
con
.
getInputStream
());
in
=
new
CountingInputStream
(
con
.
getInputStream
());
byte
[]
buf
=
new
byte
[
8192
];
int
len
;
File
dst
=
job
.
getDestination
();
File
tmp
=
new
File
(
dst
.
getPath
()+
".tmp"
);
OutputStream
out
=
new
FileOutputStream
(
tmp
);
out
=
new
FileOutputStream
(
tmp
);
LOGGER
.
info
(
"Downloading "
+
job
.
getName
());
try
{
...
...
@@ -766,9 +770,6 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas
throw
new
IOException
(
"Failed to load "
+
src
+
" to "
+
tmp
,
e
);
}
in
.
close
();
out
.
close
();
if
(
total
!=-
1
&&
total
!=
tmp
.
length
())
{
// don't know exactly how this happens, but report like
// http://www.ashlux.com/wordpress/2009/08/14/hudson-and-the-sonar-plugin-fail-maveninstallation-nosuchmethoderror/
...
...
@@ -778,7 +779,10 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas
return
tmp
;
}
catch
(
IOException
e
)
{
throw
new
IOException
(
"Failed to download from "
+
src
,
e
);
throw
new
IOException2
(
"Failed to download from "
+
src
,
e
);
}
finally
{
IOUtils
.
closeQuietly
(
in
);
IOUtils
.
closeQuietly
(
out
);
}
}
...
...
core/src/main/java/hudson/model/UsageStatistics.java
浏览文件 @
52b25711
...
...
@@ -28,6 +28,7 @@ import hudson.PluginWrapper;
import
hudson.Util
;
import
hudson.Extension
;
import
hudson.node_monitors.ArchitectureMonitor.DescriptorImpl
;
import
hudson.util.IOUtils
;
import
hudson.util.Secret
;
import
static
hudson
.
util
.
TimeUnit2
.
DAYS
;
...
...
@@ -172,8 +173,11 @@ public class UsageStatistics extends PageDecorator {
// json -> UTF-8 encode -> gzip -> encrypt -> base64 -> string
OutputStreamWriter
w
=
new
OutputStreamWriter
(
new
GZIPOutputStream
(
new
CombinedCipherOutputStream
(
baos
,
getKey
(),
"AES"
)),
"UTF-8"
);
o
.
write
(
w
);
w
.
close
();
try
{
o
.
write
(
w
);
}
finally
{
IOUtils
.
closeQuietly
(
w
);
}
return
new
String
(
Base64
.
encode
(
baos
.
toByteArray
()));
}
catch
(
GeneralSecurityException
e
)
{
...
...
core/src/main/java/hudson/scm/SCM.java
浏览文件 @
52b25711
...
...
@@ -41,6 +41,7 @@ import hudson.model.Describable;
import
hudson.model.TaskListener
;
import
hudson.model.Node
;
import
hudson.model.WorkspaceCleanupThread
;
import
hudson.util.IOUtils
;
import
jenkins.model.Jenkins
;
import
hudson.model.Descriptor
;
import
hudson.model.Api
;
...
...
@@ -578,14 +579,17 @@ public abstract class SCM implements Describable<SCM>, ExtensionPoint {
//
protected
final
boolean
createEmptyChangeLog
(
File
changelogFile
,
BuildListener
listener
,
String
rootTag
)
{
FileWriter
w
=
null
;
try
{
FileWriter
w
=
new
FileWriter
(
changelogFile
);
w
=
new
FileWriter
(
changelogFile
);
w
.
write
(
"<"
+
rootTag
+
"/>"
);
w
.
close
();
return
true
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
(
listener
.
error
(
e
.
getMessage
()));
return
false
;
}
finally
{
IOUtils
.
closeQuietly
(
w
);
}
}
...
...
core/src/main/java/hudson/tools/JDKInstaller.java
浏览文件 @
52b25711
...
...
@@ -178,8 +178,11 @@ public class JDKInstaller extends ToolInstaller {
byte
[]
header
=
new
byte
[
2
];
{
DataInputStream
in
=
new
DataInputStream
(
fs
.
read
(
jdkBundle
));
in
.
readFully
(
header
);
in
.
close
();
try
{
in
.
readFully
(
header
);
}
finally
{
IOUtils
.
closeQuietly
(
in
);
}
}
ProcStarter
starter
;
...
...
core/src/main/java/hudson/triggers/SCMTrigger.java
浏览文件 @
52b25711
...
...
@@ -31,6 +31,7 @@ import hudson.model.AbstractBuild;
import
hudson.model.AbstractProject
;
import
hudson.model.Action
;
import
hudson.model.Cause
;
import
hudson.util.IOUtils
;
import
jenkins.model.Jenkins
;
import
hudson.model.Item
;
import
hudson.model.Project
;
...
...
@@ -337,8 +338,11 @@ public class SCMTrigger extends Trigger<SCMedItem> {
rsp
.
setContentType
(
"text/plain;charset=UTF-8"
);
// Prevent jelly from flushing stream so Content-Length header can be added afterwards
FlushProofOutputStream
out
=
new
FlushProofOutputStream
(
rsp
.
getCompressedOutputStream
(
req
));
getPollingLogText
().
writeLogTo
(
0
,
out
);
out
.
close
();
try
{
getPollingLogText
().
writeLogTo
(
0
,
out
);
}
finally
{
IOUtils
.
closeQuietly
(
out
);
}
}
public
AnnotatedLargeText
getPollingLogText
()
{
...
...
core/src/main/java/hudson/util/CompressedFile.java
浏览文件 @
52b25711
...
...
@@ -115,11 +115,14 @@ public class CompressedFile {
StringBuilder
str
=
new
StringBuilder
((
int
)
sizeGuess
);
Reader
r
=
new
InputStreamReader
(
read
());
char
[]
buf
=
new
char
[
8192
];
int
len
;
while
((
len
=
r
.
read
(
buf
,
0
,
buf
.
length
))>
0
)
str
.
append
(
buf
,
0
,
len
);
r
.
close
();
try
{
char
[]
buf
=
new
char
[
8192
];
int
len
;
while
((
len
=
r
.
read
(
buf
,
0
,
buf
.
length
))>
0
)
str
.
append
(
buf
,
0
,
len
);
}
finally
{
IOUtils
.
closeQuietly
(
r
);
}
return
str
.
toString
();
}
...
...
core/src/main/java/hudson/util/io/ZipArchiver.java
浏览文件 @
52b25711
...
...
@@ -70,10 +70,13 @@ final class ZipArchiver extends Archiver {
fileZipEntry
.
setTime
(
f
.
lastModified
());
zip
.
putNextEntry
(
fileZipEntry
);
FileInputStream
in
=
new
FileInputStream
(
f
);
int
len
;
while
((
len
=
in
.
read
(
buf
))>=
0
)
zip
.
write
(
buf
,
0
,
len
);
in
.
close
();
try
{
int
len
;
while
((
len
=
in
.
read
(
buf
))>=
0
)
zip
.
write
(
buf
,
0
,
len
);
}
finally
{
in
.
close
();
}
zip
.
closeEntry
();
}
entriesWritten
++;
...
...
core/src/main/java/jenkins/model/Jenkins.java
浏览文件 @
52b25711
...
...
@@ -172,6 +172,7 @@ import hudson.util.FormValidation;
import
hudson.util.Futures
;
import
hudson.util.HudsonIsLoading
;
import
hudson.util.HudsonIsRestarting
;
import
hudson.util.IOUtils
;
import
hudson.util.Iterators
;
import
hudson.util.JenkinsReloadFailed
;
import
hudson.util.Memoizer
;
...
...
@@ -3981,12 +3982,15 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
private
static
void
computeVersion
(
ServletContext
context
)
{
// set the version
Properties
props
=
new
Properties
();
InputStream
is
=
null
;
try
{
InputStream
is
=
Jenkins
.
class
.
getResourceAsStream
(
"jenkins-version.properties"
);
is
=
Jenkins
.
class
.
getResourceAsStream
(
"jenkins-version.properties"
);
if
(
is
!=
null
)
props
.
load
(
is
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
// if the version properties is missing, that's OK.
}
finally
{
IOUtils
.
closeQuietly
(
is
);
}
String
ver
=
props
.
getProperty
(
"version"
);
if
(
ver
==
null
)
ver
=
"?"
;
...
...
core/src/test/java/hudson/util/io/ZipArchiverTest.java
浏览文件 @
52b25711
...
...
@@ -65,13 +65,13 @@ public class ZipArchiverTest extends TestCase {
}
catch
(
Exception
e
)
{
fail
(
"exception driving ZipArchiver"
,
e
);
}
finally
{
try
{
archiver
.
close
();
}
catch
(
IOException
e
)
{
// ignored
if
(
archiver
!=
null
)
{
try
{
archiver
.
close
();
}
catch
(
IOException
e
)
{
// ignored
}
}
archiver
=
null
;
}
// examine zip contents and assert that none of the entry names (paths) have
...
...
@@ -86,10 +86,12 @@ public class ZipArchiverTest extends TestCase {
}
catch
(
Exception
e
)
{
fail
(
"failure enumerating zip entries"
,
e
);
}
finally
{
try
{
zipFileVerify
.
close
();
}
catch
(
IOException
e
)
{
// ignored
if
(
zipFileVerify
!=
null
)
{
try
{
zipFileVerify
.
close
();
}
catch
(
IOException
e
)
{
// ignored
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录