Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
466d74d1
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,发现更多精彩内容 >>
提交
466d74d1
编写于
4月 03, 2017
作者:
J
Jesse Glick
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into SSH-CLI-JENKINS-41745
上级
60632c0e
0fac1f84
变更
57
隐藏空白更改
内联
并排
Showing
57 changed file
with
320 addition
and
252 deletion
+320
-252
cli/pom.xml
cli/pom.xml
+1
-1
cli/src/main/java/hudson/cli/PrivateKeyProvider.java
cli/src/main/java/hudson/cli/PrivateKeyProvider.java
+3
-1
core/pom.xml
core/pom.xml
+2
-2
core/src/main/java/hudson/ClassicPluginStrategy.java
core/src/main/java/hudson/ClassicPluginStrategy.java
+5
-9
core/src/main/java/hudson/FilePath.java
core/src/main/java/hudson/FilePath.java
+35
-34
core/src/main/java/hudson/FileSystemProvisioner.java
core/src/main/java/hudson/FileSystemProvisioner.java
+2
-1
core/src/main/java/hudson/Main.java
core/src/main/java/hudson/Main.java
+6
-10
core/src/main/java/hudson/PluginWrapper.java
core/src/main/java/hudson/PluginWrapper.java
+2
-1
core/src/main/java/hudson/Util.java
core/src/main/java/hudson/Util.java
+3
-3
core/src/main/java/hudson/WebAppMain.java
core/src/main/java/hudson/WebAppMain.java
+4
-5
core/src/main/java/hudson/XmlFile.java
core/src/main/java/hudson/XmlFile.java
+5
-4
core/src/main/java/hudson/cli/BuildCommand.java
core/src/main/java/hudson/cli/BuildCommand.java
+2
-1
core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java
.../src/main/java/hudson/lifecycle/WindowsInstallerLink.java
+3
-1
core/src/main/java/hudson/model/FileParameterValue.java
core/src/main/java/hudson/model/FileParameterValue.java
+5
-4
core/src/main/java/hudson/model/Queue.java
core/src/main/java/hudson/model/Queue.java
+2
-1
core/src/main/java/hudson/model/ReconfigurableDescribable.java
...src/main/java/hudson/model/ReconfigurableDescribable.java
+1
-2
core/src/main/java/hudson/model/Run.java
core/src/main/java/hudson/model/Run.java
+4
-2
core/src/main/java/hudson/model/UpdateCenter.java
core/src/main/java/hudson/model/UpdateCenter.java
+2
-1
core/src/main/java/hudson/tools/JDKInstaller.java
core/src/main/java/hudson/tools/JDKInstaller.java
+3
-1
core/src/main/java/hudson/util/AtomicFileWriter.java
core/src/main/java/hudson/util/AtomicFileWriter.java
+2
-1
core/src/main/java/hudson/util/CompressedFile.java
core/src/main/java/hudson/util/CompressedFile.java
+9
-10
core/src/main/java/hudson/util/IOUtils.java
core/src/main/java/hudson/util/IOUtils.java
+3
-8
core/src/main/java/hudson/util/SecretRewriter.java
core/src/main/java/hudson/util/SecretRewriter.java
+3
-1
core/src/main/java/hudson/util/StreamTaskListener.java
core/src/main/java/hudson/util/StreamTaskListener.java
+10
-3
core/src/main/java/hudson/util/TextFile.java
core/src/main/java/hudson/util/TextFile.java
+4
-2
core/src/main/java/hudson/util/io/ReopenableFileOutputStream.java
.../main/java/hudson/util/io/ReopenableFileOutputStream.java
+6
-2
core/src/main/java/hudson/util/io/RewindableFileOutputStream.java
.../main/java/hudson/util/io/RewindableFileOutputStream.java
+5
-2
core/src/main/java/hudson/util/io/TarArchiver.java
core/src/main/java/hudson/util/io/TarArchiver.java
+3
-1
core/src/main/java/hudson/util/io/ZipArchiver.java
core/src/main/java/hudson/util/io/ZipArchiver.java
+3
-4
core/src/main/java/jenkins/diagnosis/HsErrPidList.java
core/src/main/java/jenkins/diagnosis/HsErrPidList.java
+4
-1
core/src/main/java/jenkins/security/DefaultConfidentialStore.java
.../main/java/jenkins/security/DefaultConfidentialStore.java
+7
-4
core/src/main/java/jenkins/util/AntClassLoader.java
core/src/main/java/jenkins/util/AntClassLoader.java
+2
-1
core/src/main/java/jenkins/util/JSONSignatureValidator.java
core/src/main/java/jenkins/util/JSONSignatureValidator.java
+2
-4
core/src/main/java/jenkins/util/VirtualFile.java
core/src/main/java/jenkins/util/VirtualFile.java
+2
-1
core/src/main/java/jenkins/util/io/FileBoolean.java
core/src/main/java/jenkins/util/io/FileBoolean.java
+2
-1
core/src/main/java/jenkins/util/xml/XMLUtils.java
core/src/main/java/jenkins/util/xml/XMLUtils.java
+5
-10
core/src/main/resources/jenkins/install/SetupWizard/authenticate-security-token.jelly
...ins/install/SetupWizard/authenticate-security-token.jelly
+15
-17
core/src/main/resources/jenkins/install/SetupWizard/index.jelly
...rc/main/resources/jenkins/install/SetupWizard/index.jelly
+10
-6
core/src/main/resources/jenkins/install/SetupWizard/proxy-configuration.jelly
...ces/jenkins/install/SetupWizard/proxy-configuration.jelly
+26
-12
core/src/main/resources/jenkins/install/SetupWizard/setupWizardFirstUser.jelly
...es/jenkins/install/SetupWizard/setupWizardFirstUser.jelly
+38
-41
core/src/main/resources/jenkins/management/AdministrativeMonitorsDecorator/resources.css
.../management/AdministrativeMonitorsDecorator/resources.css
+0
-1
core/src/main/resources/lib/layout/html.jelly
core/src/main/resources/lib/layout/html.jelly
+3
-0
core/src/main/resources/lib/layout/layout.jelly
core/src/main/resources/lib/layout/layout.jelly
+12
-2
core/src/test/java/hudson/FilePathTest.java
core/src/test/java/hudson/FilePathTest.java
+9
-8
core/src/test/java/hudson/PluginManagerTest.java
core/src/test/java/hudson/PluginManagerTest.java
+2
-1
core/src/test/java/hudson/UtilTest.java
core/src/test/java/hudson/UtilTest.java
+5
-1
core/src/test/java/hudson/model/LoadStatisticsTest.java
core/src/test/java/hudson/model/LoadStatisticsTest.java
+4
-3
core/src/test/java/hudson/os/SUTester.java
core/src/test/java/hudson/os/SUTester.java
+3
-1
core/src/test/java/hudson/util/io/TarArchiverTest.java
core/src/test/java/hudson/util/io/TarArchiverTest.java
+9
-7
core/src/test/java/hudson/util/io/ZipArchiverTest.java
core/src/test/java/hudson/util/io/ZipArchiverTest.java
+2
-1
core/src/test/java/jenkins/util/VirtualFileTest.java
core/src/test/java/jenkins/util/VirtualFileTest.java
+3
-2
pom.xml
pom.xml
+1
-1
test/pom.xml
test/pom.xml
+1
-1
test/src/test/java/hudson/model/DirectoryBrowserSupportTest.java
...c/test/java/hudson/model/DirectoryBrowserSupportTest.java
+2
-1
test/src/test/java/hudson/tools/JDKInstallerTest.java
test/src/test/java/hudson/tools/JDKInstallerTest.java
+3
-4
war/pom.xml
war/pom.xml
+2
-2
war/src/main/webapp/css/layout-common.css
war/src/main/webapp/css/layout-common.css
+8
-0
未找到文件。
cli/pom.xml
浏览文件 @
466d74d1
...
...
@@ -5,7 +5,7 @@
<parent>
<groupId>
org.jenkins-ci.main
</groupId>
<artifactId>
pom
</artifactId>
<version>
2.5
2
-SNAPSHOT
</version>
<version>
2.5
4
-SNAPSHOT
</version>
</parent>
<artifactId>
cli
</artifactId>
...
...
cli/src/main/java/hudson/cli/PrivateKeyProvider.java
浏览文件 @
466d74d1
...
...
@@ -30,6 +30,8 @@ import java.io.DataInputStream;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.nio.file.Files
;
import
java.security.GeneralSecurityException
;
import
java.security.KeyFactory
;
import
java.security.KeyPair
;
...
...
@@ -127,7 +129,7 @@ public class PrivateKeyProvider {
}
private
static
String
readPemFile
(
File
f
)
throws
IOException
{
try
(
FileInputStream
is
=
new
FileInputStream
(
f
);
try
(
InputStream
is
=
Files
.
newInputStream
(
f
.
toPath
()
);
DataInputStream
dis
=
new
DataInputStream
(
is
))
{
byte
[]
bytes
=
new
byte
[(
int
)
f
.
length
()];
dis
.
readFully
(
bytes
);
...
...
core/pom.xml
浏览文件 @
466d74d1
...
...
@@ -29,7 +29,7 @@ THE SOFTWARE.
<parent>
<groupId>
org.jenkins-ci.main
</groupId>
<artifactId>
pom
</artifactId>
<version>
2.5
2
-SNAPSHOT
</version>
<version>
2.5
4
-SNAPSHOT
</version>
</parent>
<artifactId>
jenkins-core
</artifactId>
...
...
@@ -755,7 +755,7 @@ THE SOFTWARE.
<artifactItem>
<groupId>
com.sun.winsw
</groupId>
<artifactId>
winsw
</artifactId>
<version>
2.0.
2
</version>
<version>
2.0.
3
</version>
<classifier>
bin
</classifier>
<type>
exe
</type>
<outputDirectory>
${project.build.outputDirectory}/windows-service
</outputDirectory>
...
...
core/src/main/java/hudson/ClassicPluginStrategy.java
浏览文件 @
466d74d1
...
...
@@ -23,6 +23,8 @@
*/
package
hudson
;
import
java.io.InputStream
;
import
java.nio.file.Files
;
import
jenkins.util.SystemProperties
;
import
com.google.common.collect.Lists
;
import
hudson.Plugin.DummyImpl
;
...
...
@@ -123,11 +125,8 @@ public class ClassicPluginStrategy implements PluginStrategy {
try
{
// Locate the manifest
String
firstLine
;
FileInputStream
manifestHeaderInput
=
new
FileInputStream
(
archive
);
try
{
try
(
InputStream
manifestHeaderInput
=
Files
.
newInputStream
(
archive
.
toPath
()))
{
firstLine
=
IOUtils
.
readFirstLine
(
manifestHeaderInput
,
"UTF-8"
);
}
finally
{
manifestHeaderInput
.
close
();
}
if
(
firstLine
.
startsWith
(
"Manifest-Version:"
))
{
// this is the manifest already
...
...
@@ -137,11 +136,8 @@ public class ClassicPluginStrategy implements PluginStrategy {
}
// Read the manifest
FileInputStream
manifestInput
=
new
FileInputStream
(
archive
);
try
{
try
(
InputStream
manifestInput
=
Files
.
newInputStream
(
archive
.
toPath
()))
{
return
new
Manifest
(
manifestInput
);
}
finally
{
manifestInput
.
close
();
}
}
catch
(
IOException
e
)
{
throw
new
IOException
(
"Failed to load "
+
archive
,
e
);
...
...
@@ -173,7 +169,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
"Plugin installation failed. No manifest at "
+
manifestFile
);
}
try
(
FileInputStream
fin
=
new
FileInputStream
(
manifestFile
))
{
try
(
InputStream
fin
=
Files
.
newInputStream
(
manifestFile
.
toPath
()
))
{
manifest
=
new
Manifest
(
fin
);
}
}
...
...
core/src/main/java/hudson/FilePath.java
浏览文件 @
466d74d1
...
...
@@ -25,7 +25,6 @@
*/
package
hudson
;
import
jenkins.util.SystemProperties
;
import
com.google.common.annotations.VisibleForTesting
;
import
com.jcraft.jzlib.GZIPInputStream
;
import
com.jcraft.jzlib.GZIPOutputStream
;
...
...
@@ -59,29 +58,9 @@ import hudson.util.IOUtils;
import
hudson.util.NamingThreadFactory
;
import
hudson.util.io.Archiver
;
import
hudson.util.io.ArchiverFactory
;
import
jenkins.FilePathFilter
;
import
jenkins.MasterToSlaveFileCallable
;
import
jenkins.SlaveToMasterFileCallable
;
import
jenkins.SoloFilePathFilter
;
import
jenkins.model.Jenkins
;
import
jenkins.util.ContextResettingExecutorService
;
import
jenkins.util.VirtualFile
;
import
org.apache.commons.fileupload.FileItem
;
import
org.apache.commons.io.input.CountingInputStream
;
import
org.apache.tools.ant.DirectoryScanner
;
import
org.apache.tools.ant.Project
;
import
org.apache.tools.ant.types.FileSet
;
import
org.apache.tools.zip.ZipEntry
;
import
org.apache.tools.zip.ZipFile
;
import
org.kohsuke.accmod.Restricted
;
import
org.kohsuke.accmod.restrictions.NoExternalUse
;
import
org.kohsuke.stapler.Stapler
;
import
javax.annotation.CheckForNull
;
import
java.io.BufferedOutputStream
;
import
java.io.File
;
import
java.io.FileFilter
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.FileWriter
;
import
java.io.IOException
;
...
...
@@ -99,6 +78,7 @@ import java.net.MalformedURLException;
import
java.net.URI
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.nio.file.Files
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Comparator
;
...
...
@@ -116,16 +96,37 @@ import java.util.logging.Level;
import
java.util.logging.Logger
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
static
hudson
.
FilePath
.
TarCompression
.*;
import
static
hudson
.
Util
.*;
import
javax.annotation.CheckForNull
;
import
javax.annotation.Nonnull
;
import
javax.annotation.Nullable
;
import
jenkins.FilePathFilter
;
import
jenkins.MasterToSlaveFileCallable
;
import
jenkins.SlaveToMasterFileCallable
;
import
jenkins.SoloFilePathFilter
;
import
jenkins.model.Jenkins
;
import
jenkins.security.MasterToSlaveCallable
;
import
jenkins.util.ContextResettingExecutorService
;
import
jenkins.util.SystemProperties
;
import
jenkins.util.VirtualFile
;
import
org.apache.commons.compress.archivers.tar.TarArchiveEntry
;
import
org.apache.commons.compress.archivers.tar.TarArchiveInputStream
;
import
org.apache.commons.fileupload.FileItem
;
import
org.apache.commons.io.input.CountingInputStream
;
import
org.apache.tools.ant.DirectoryScanner
;
import
org.apache.tools.ant.Project
;
import
org.apache.tools.ant.types.FileSet
;
import
org.apache.tools.zip.ZipEntry
;
import
org.apache.tools.zip.ZipFile
;
import
org.jenkinsci.remoting.RoleChecker
;
import
org.jenkinsci.remoting.RoleSensitive
;
import
org.kohsuke.accmod.Restricted
;
import
org.kohsuke.accmod.restrictions.NoExternalUse
;
import
org.kohsuke.stapler.Stapler
;
import
static
hudson
.
FilePath
.
TarCompression
.
GZIP
;
import
static
hudson
.
Util
.
deleteFile
;
import
static
hudson
.
Util
.
fixEmpty
;
import
static
hudson
.
Util
.
isSymlink
;
/**
* {@link File} like object with remoting support.
...
...
@@ -1470,7 +1471,7 @@ public final class FilePath implements Serializable {
private
static
final
long
serialVersionUID
=
-
5094638816500738429L
;
public
Void
invoke
(
File
f
,
VirtualChannel
channel
)
throws
IOException
{
if
(!
f
.
exists
())
new
FileOutputStream
(
creating
(
f
)).
close
();
Files
.
newOutputStream
(
creating
(
f
).
toPath
(
)).
close
();
if
(!
stating
(
f
).
setLastModified
(
timestamp
))
throw
new
IOException
(
"Failed to set the timestamp of "
+
f
+
" to "
+
timestamp
);
return
null
;
...
...
@@ -1751,7 +1752,7 @@ public final class FilePath implements Serializable {
*/
public
InputStream
read
()
throws
IOException
,
InterruptedException
{
if
(
channel
==
null
)
return
new
FileInputStream
(
reading
(
new
File
(
remote
)
));
return
Files
.
newInputStream
(
reading
(
new
File
(
remote
)).
toPath
(
));
final
Pipe
p
=
Pipe
.
createRemoteToLocal
();
actAsync
(
new
SecureFileCallable
<
Void
>()
{
...
...
@@ -1759,9 +1760,9 @@ public final class FilePath implements Serializable {
@Override
public
Void
invoke
(
File
f
,
VirtualChannel
channel
)
throws
IOException
,
InterruptedException
{
File
InputStream
fis
=
null
;
InputStream
fis
=
null
;
try
{
fis
=
new
FileInputStream
(
reading
(
f
));
fis
=
Files
.
newInputStream
(
reading
(
f
).
toPath
(
));
Util
.
copyStream
(
fis
,
p
.
getOut
());
}
catch
(
Exception
x
)
{
p
.
error
(
x
);
...
...
@@ -1876,7 +1877,7 @@ public final class FilePath implements Serializable {
if
(
channel
==
null
)
{
File
f
=
new
File
(
remote
).
getAbsoluteFile
();
mkdirs
(
f
.
getParentFile
());
return
new
FileOutputStream
(
writing
(
f
));
return
Files
.
newOutputStream
(
writing
(
f
).
toPath
(
));
}
return
act
(
new
SecureFileCallable
<
OutputStream
>()
{
...
...
@@ -1884,7 +1885,7 @@ public final class FilePath implements Serializable {
public
OutputStream
invoke
(
File
f
,
VirtualChannel
channel
)
throws
IOException
,
InterruptedException
{
f
=
f
.
getAbsoluteFile
();
mkdirs
(
f
.
getParentFile
());
FileOutputStream
fos
=
new
FileOutputStream
(
writing
(
f
));
OutputStream
fos
=
Files
.
newOutputStream
(
writing
(
f
).
toPath
(
));
return
new
RemoteOutputStream
(
fos
);
}
});
...
...
@@ -1902,8 +1903,8 @@ public final class FilePath implements Serializable {
private
static
final
long
serialVersionUID
=
1L
;
public
Void
invoke
(
File
f
,
VirtualChannel
channel
)
throws
IOException
{
mkdirs
(
f
.
getParentFile
());
FileOutputStream
fos
=
new
FileOutputStream
(
writing
(
f
));
try
(
Writer
w
=
encoding
!=
null
?
new
OutputStreamWriter
(
fos
,
encoding
)
:
new
OutputStreamWriter
(
fos
))
{
try
(
OutputStream
fos
=
Files
.
newOutputStream
(
writing
(
f
).
toPath
(
));
Writer
w
=
encoding
!=
null
?
new
OutputStreamWriter
(
fos
,
encoding
)
:
new
OutputStreamWriter
(
fos
))
{
w
.
write
(
content
);
}
return
null
;
...
...
@@ -2005,9 +2006,9 @@ public final class FilePath implements Serializable {
act
(
new
SecureFileCallable
<
Void
>()
{
private
static
final
long
serialVersionUID
=
4088559042349254141L
;
public
Void
invoke
(
File
f
,
VirtualChannel
channel
)
throws
IOException
{
File
InputStream
fis
=
null
;
InputStream
fis
=
null
;
try
{
fis
=
new
FileInputStream
(
reading
(
f
));
fis
=
Files
.
newInputStream
(
reading
(
f
).
toPath
(
));
Util
.
copyStream
(
fis
,
out
);
return
null
;
}
finally
{
...
...
core/src/main/java/hudson/FileSystemProvisioner.java
浏览文件 @
466d74d1
...
...
@@ -31,6 +31,7 @@ import hudson.model.Describable;
import
hudson.model.Job
;
import
hudson.model.TaskListener
;
import
hudson.util.io.ArchiverFactory
;
import
java.nio.file.Files
;
import
jenkins.model.Jenkins
;
import
hudson.model.listeners.RunListener
;
import
hudson.scm.SCM
;
...
...
@@ -215,7 +216,7 @@ public abstract class FileSystemProvisioner implements ExtensionPoint, Describab
*/
public
WorkspaceSnapshot
snapshot
(
AbstractBuild
<?,
?>
build
,
FilePath
ws
,
String
glob
,
TaskListener
listener
)
throws
IOException
,
InterruptedException
{
File
wss
=
new
File
(
build
.
getRootDir
(),
"workspace.tgz"
);
try
(
OutputStream
os
=
new
BufferedOutputStream
(
new
FileOutputStream
(
wss
)))
{
try
(
OutputStream
os
=
new
BufferedOutputStream
(
Files
.
newOutputStream
(
wss
.
toPath
()
)))
{
ws
.
archive
(
ArchiverFactory
.
TARGZ
,
os
,
glob
);
}
return
new
WorkspaceSnapshotImpl
();
...
...
core/src/main/java/hudson/Main.java
浏览文件 @
466d74d1
...
...
@@ -23,6 +23,9 @@
*/
package
hudson
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.nio.file.Files
;
import
jenkins.util.SystemProperties
;
import
hudson.util.DualOutputStream
;
import
hudson.util.EncodingStream
;
...
...
@@ -135,11 +138,9 @@ public class Main {
// write the output to a temporary file first.
File
tmpFile
=
File
.
createTempFile
(
"jenkins"
,
"log"
);
try
{
FileOutputStream
os
=
new
FileOutputStream
(
tmpFile
);
Writer
w
=
new
OutputStreamWriter
(
os
,
"UTF-8"
);
int
ret
;
try
{
try
(
OutputStream
os
=
Files
.
newOutputStream
(
tmpFile
.
toPath
());
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
();
...
...
@@ -156,8 +157,6 @@ public class Main {
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"
);
...
...
@@ -174,11 +173,8 @@ public class Main {
con
.
setFixedLengthStreamingMode
((
int
)
tmpFile
.
length
());
con
.
connect
();
// send the data
FileInputStream
in
=
new
FileInputStream
(
tmpFile
);
try
{
try
(
InputStream
in
=
Files
.
newInputStream
(
tmpFile
.
toPath
()))
{
Util
.
copyStream
(
in
,
con
.
getOutputStream
());
}
finally
{
IOUtils
.
closeQuietly
(
in
);
}
if
(
con
.
getResponseCode
()!=
200
)
{
...
...
core/src/main/java/hudson/PluginWrapper.java
浏览文件 @
466d74d1
...
...
@@ -29,6 +29,7 @@ import hudson.PluginManager.PluginInstanceStore;
import
hudson.model.AdministrativeMonitor
;
import
hudson.model.Api
;
import
hudson.model.ModelObject
;
import
java.nio.file.Files
;
import
jenkins.YesNoMaybe
;
import
jenkins.model.Jenkins
;
import
hudson.model.UpdateCenter
;
...
...
@@ -495,7 +496,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
*/
public
void
disable
()
throws
IOException
{
// creates an empty file
OutputStream
os
=
new
FileOutputStream
(
disableFile
);
OutputStream
os
=
Files
.
newOutputStream
(
disableFile
.
toPath
()
);
os
.
close
();
}
...
...
core/src/main/java/hudson/Util.java
浏览文件 @
466d74d1
...
...
@@ -198,7 +198,7 @@ public class Util {
StringBuilder
str
=
new
StringBuilder
((
int
)
logfile
.
length
());
try
(
BufferedReader
r
=
new
BufferedReader
(
new
InputStreamReader
(
new
FileInputStream
(
logfile
),
charset
)))
{
try
(
BufferedReader
r
=
new
BufferedReader
(
new
InputStreamReader
(
Files
.
newInputStream
(
logfile
.
toPath
()
),
charset
)))
{
char
[]
buf
=
new
char
[
1024
];
int
len
;
while
((
len
=
r
.
read
(
buf
,
0
,
buf
.
length
))
>
0
)
...
...
@@ -800,7 +800,7 @@ public class Util {
*/
@Nonnull
public
static
String
getDigestOf
(
@Nonnull
File
file
)
throws
IOException
{
try
(
InputStream
is
=
new
FileInputStream
(
file
))
{
try
(
InputStream
is
=
Files
.
newInputStream
(
file
.
toPath
()
))
{
return
getDigestOf
(
new
BufferedInputStream
(
is
));
}
}
...
...
@@ -1134,7 +1134,7 @@ public class Util {
* Creates an empty file.
*/
public
static
void
touch
(
@Nonnull
File
file
)
throws
IOException
{
new
FileOutputStream
(
file
).
close
();
Files
.
newOutputStream
(
file
.
toPath
()
).
close
();
}
/**
...
...
core/src/main/java/hudson/WebAppMain.java
浏览文件 @
466d74d1
...
...
@@ -24,6 +24,9 @@
package
hudson
;
import
hudson.security.ACLContext
;
import
java.io.OutputStream
;
import
java.nio.file.Files
;
import
java.nio.file.StandardOpenOption
;
import
jenkins.util.SystemProperties
;
import
com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider
;
import
com.thoughtworks.xstream.core.JVM
;
...
...
@@ -273,14 +276,10 @@ public class WebAppMain implements ServletContextListener {
* @see BootFailure
*/
private
void
recordBootAttempt
(
File
home
)
{
FileOutputStream
o
=
null
;
try
{
o
=
new
FileOutputStream
(
BootFailure
.
getBootFailureFile
(
home
),
true
);
try
(
OutputStream
o
=
Files
.
newOutputStream
(
BootFailure
.
getBootFailureFile
(
home
).
toPath
(),
StandardOpenOption
.
CREATE
,
StandardOpenOption
.
APPEND
))
{
o
.
write
((
new
Date
().
toString
()
+
System
.
getProperty
(
"line.separator"
,
"\n"
)).
toString
().
getBytes
());
}
catch
(
IOException
e
)
{
LOGGER
.
log
(
WARNING
,
"Failed to record boot attempts"
,
e
);
}
finally
{
IOUtils
.
closeQuietly
(
o
);
}
}
...
...
core/src/main/java/hudson/XmlFile.java
浏览文件 @
466d74d1
...
...
@@ -33,6 +33,7 @@ import hudson.diagnosis.OldDataMonitor;
import
hudson.model.Descriptor
;
import
hudson.util.AtomicFileWriter
;
import
hudson.util.XStream2
;
import
java.nio.file.Files
;
import
org.xml.sax.Attributes
;
import
org.xml.sax.InputSource
;
import
org.xml.sax.Locator
;
...
...
@@ -138,7 +139,7 @@ public final class XmlFile {
if
(
LOGGER
.
isLoggable
(
Level
.
FINE
))
{
LOGGER
.
fine
(
"Reading "
+
file
);
}
try
(
InputStream
in
=
new
BufferedInputStream
(
new
FileInputStream
(
file
)))
{
try
(
InputStream
in
=
new
BufferedInputStream
(
Files
.
newInputStream
(
file
.
toPath
()
)))
{
return
xs
.
fromXML
(
in
);
}
catch
(
XStreamException
|
Error
e
)
{
throw
new
IOException
(
"Unable to read "
+
file
,
e
);
...
...
@@ -154,7 +155,7 @@ public final class XmlFile {
*/
public
Object
unmarshal
(
Object
o
)
throws
IOException
{
try
(
InputStream
in
=
new
BufferedInputStream
(
new
FileInputStream
(
file
)))
{
try
(
InputStream
in
=
new
BufferedInputStream
(
Files
.
newInputStream
(
file
.
toPath
()
)))
{
// TODO: expose XStream the driver from XStream
return
xs
.
unmarshal
(
DEFAULT_DRIVER
.
createReader
(
in
),
o
);
}
catch
(
XStreamException
|
Error
e
)
{
...
...
@@ -201,7 +202,7 @@ public final class XmlFile {
* @return Reader for the file. should be close externally once read.
*/
public
Reader
readRaw
()
throws
IOException
{
FileInputStream
fileInputStream
=
new
FileInputStream
(
file
);
InputStream
fileInputStream
=
Files
.
newInputStream
(
file
.
toPath
()
);
try
{
return
new
InputStreamReader
(
fileInputStream
,
sniffEncoding
());
}
catch
(
IOException
ex
)
{
...
...
@@ -247,7 +248,7 @@ public final class XmlFile {
}
}
try
(
InputStream
in
=
new
FileInputStream
(
file
))
{
try
(
InputStream
in
=
Files
.
newInputStream
(
file
.
toPath
()
))
{
InputSource
input
=
new
InputSource
(
file
.
toURI
().
toASCIIString
());
input
.
setByteStream
(
in
);
JAXP
.
newSAXParser
().
parse
(
input
,
new
DefaultHandler
()
{
...
...
core/src/main/java/hudson/cli/BuildCommand.java
浏览文件 @
466d74d1
...
...
@@ -44,6 +44,7 @@ import hudson.model.queue.QueueTaskFuture;
import
hudson.util.EditDistance
;
import
hudson.util.StreamTaskListener
;
import
java.nio.file.NoSuchFileException
;
import
jenkins.scm.SCMDecisionHandler
;
import
org.kohsuke.args4j.Argument
;
import
org.kohsuke.args4j.CmdLineException
;
...
...
@@ -189,7 +190,7 @@ public class BuildCommand extends CLICommand {
b
.
writeWholeLogTo
(
stdout
);
break
;
}
catch
(
FileNotFoundException
e
)
{
catch
(
FileNotFoundException
|
NoSuchFileException
e
)
{
if
(
i
==
retryCnt
)
{
Exception
myException
=
new
AbortException
();
myException
.
initCause
(
e
);
...
...
core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java
浏览文件 @
466d74d1
...
...
@@ -31,6 +31,8 @@ import hudson.model.TaskListener;
import
hudson.util.jna.Kernel32Utils
;
import
hudson.util.jna.SHELLEXECUTEINFO
;
import
hudson.util.jna.Shell32
;
import
java.io.InputStream
;
import
java.nio.file.Files
;
import
jenkins.model.Jenkins
;
import
hudson.AbortException
;
import
hudson.Extension
;
...
...
@@ -306,7 +308,7 @@ public class WindowsInstallerLink extends ManagementLink {
try
{
return
Kernel32Utils
.
waitForExitProcess
(
sei
.
hProcess
);
}
finally
{
try
(
FileInputStream
fin
=
new
FileInputStream
(
new
File
(
pwd
,
"redirect.log"
)))
{
try
(
InputStream
fin
=
Files
.
newInputStream
(
new
File
(
pwd
,
"redirect.log"
).
toPath
(
)))
{
IOUtils
.
copy
(
fin
,
out
.
getLogger
());
}
}
...
...
core/src/main/java/hudson/model/FileParameterValue.java
浏览文件 @
466d74d1
...
...
@@ -36,6 +36,7 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.UnsupportedEncodingException
;
import
java.nio.file.Files
;
import
javax.servlet.ServletException
;
import
org.apache.commons.fileupload.FileItem
;
...
...
@@ -205,7 +206,7 @@ public class FileParameterValue extends ParameterValue {
AbstractBuild
build
=
(
AbstractBuild
)
request
.
findAncestor
(
AbstractBuild
.
class
).
getObject
();
File
fileParameter
=
getLocationUnderBuild
(
build
);
if
(
fileParameter
.
isFile
())
{
InputStream
data
=
new
FileInputStream
(
fileParameter
);
InputStream
data
=
Files
.
newInputStream
(
fileParameter
.
toPath
()
);
try
{
long
lastModified
=
fileParameter
.
lastModified
();
long
contentLength
=
fileParameter
.
length
();
...
...
@@ -245,7 +246,7 @@ public class FileParameterValue extends ParameterValue {
}
public
InputStream
getInputStream
()
throws
IOException
{
return
new
FileInputStream
(
file
);
return
Files
.
newInputStream
(
file
.
toPath
()
);
}
public
String
getContentType
()
{
...
...
@@ -266,7 +267,7 @@ public class FileParameterValue extends ParameterValue {
public
byte
[]
get
()
{
try
{
try
(
FileInputStream
inputStream
=
new
FileInputStream
(
file
))
{
try
(
InputStream
inputStream
=
Files
.
newInputStream
(
file
.
toPath
()
))
{
return
IOUtils
.
toByteArray
(
inputStream
);
}
}
catch
(
IOException
e
)
{
...
...
@@ -306,7 +307,7 @@ public class FileParameterValue extends ParameterValue {
@Deprecated
public
OutputStream
getOutputStream
()
throws
IOException
{
return
new
FileOutputStream
(
file
);
return
Files
.
newOutputStream
(
file
.
toPath
()
);
}
@Override
...
...
core/src/main/java/hudson/model/Queue.java
浏览文件 @
466d74d1
...
...
@@ -63,6 +63,7 @@ import hudson.model.queue.CauseOfBlockage.BecauseNodeIsBusy;
import
hudson.model.queue.WorkUnitContext
;
import
hudson.security.ACL
;
import
hudson.security.AccessControlled
;
import
java.nio.file.Files
;
import
jenkins.security.QueueItemAuthenticatorProvider
;
import
jenkins.util.Timer
;
import
hudson.triggers.SafeTimerTask
;
...
...
@@ -376,7 +377,7 @@ public class Queue extends ResourceController implements Saveable {
// first try the old format
File
queueFile
=
getQueueFile
();
if
(
queueFile
.
exists
())
{
try
(
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
new
FileInputStream
(
queueFile
))))
{
try
(
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
Files
.
newInputStream
(
queueFile
.
toPath
()
))))
{
String
line
;
while
((
line
=
in
.
readLine
())
!=
null
)
{
AbstractProject
j
=
Jenkins
.
getInstance
().
getItemByFullName
(
line
,
AbstractProject
.
class
);
...
...
core/src/main/java/hudson/model/ReconfigurableDescribable.java
浏览文件 @
466d74d1
...
...
@@ -43,8 +43,7 @@ import org.kohsuke.stapler.StaplerRequest;
* <h2>Invisible Property</h2>
* <p>
* This mechanism can be used to create an entirely invisible {@link Describable}, which is handy
* for {@link NodeProperty}, {@link JobProperty}, etc. To do so, define a descriptor with null
* {@linkplain Descriptor#getDisplayName() display name} and empty config.jelly to prevent it from
* for {@link NodeProperty}, {@link JobProperty}, etc. To do so, define an empty config.jelly to prevent it from
* showing up in the config UI, then implement {@link #reconfigure(StaplerRequest, JSONObject)}
* and simply return {@code this}.
*
...
...
core/src/main/java/hudson/model/Run.java
浏览文件 @
466d74d1
...
...
@@ -41,6 +41,8 @@ import hudson.console.ConsoleLogFilter;
import
hudson.console.ConsoleNote
;
import
hudson.console.ModelHyperlinkNote
;
import
hudson.console.PlainTextConsoleOutputStream
;
import
java.nio.file.Files
;
import
java.nio.file.StandardOpenOption
;
import
jenkins.util.SystemProperties
;
import
hudson.Util
;
import
hudson.XmlFile
;
...
...
@@ -1367,7 +1369,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
if
(
logFile
.
exists
()
)
{
// Checking if a ".gz" file was return
FileInputStream
fis
=
new
FileInputStream
(
logFile
);
InputStream
fis
=
Files
.
newInputStream
(
logFile
.
toPath
()
);
if
(
logFile
.
getName
().
endsWith
(
".gz"
))
{
return
new
GZIPInputStream
(
fis
);
}
else
{
...
...
@@ -1807,7 +1809,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
// don't do buffering so that what's written to the listener
// gets reflected to the file immediately, which can then be
// served to the browser immediately
OutputStream
logger
=
new
FileOutputStream
(
getLogFile
(),
true
);
OutputStream
logger
=
Files
.
newOutputStream
(
getLogFile
().
toPath
(),
StandardOpenOption
.
CREATE
,
StandardOpenOption
.
APPEND
);
RunT
build
=
job
.
getBuild
();
// Global log filters
...
...
core/src/main/java/hudson/model/UpdateCenter.java
浏览文件 @
466d74d1
...
...
@@ -31,6 +31,7 @@ import hudson.PluginManager;
import
hudson.PluginWrapper
;
import
hudson.ProxyConfiguration
;
import
hudson.security.ACLContext
;
import
java.nio.file.Files
;
import
jenkins.util.SystemProperties
;
import
hudson.Util
;
import
hudson.XmlFile
;
...
...
@@ -1127,7 +1128,7 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas
File
dst
=
job
.
getDestination
();
File
tmp
=
new
File
(
dst
.
getPath
()+
".tmp"
);
out
=
new
FileOutputStream
(
tmp
);
out
=
Files
.
newOutputStream
(
tmp
.
toPath
()
);
if
(
sha1
!=
null
)
{
out
=
new
DigestOutputStream
(
out
,
sha1
);
}
...
...
core/src/main/java/hudson/tools/JDKInstaller.java
浏览文件 @
466d74d1
...
...
@@ -39,6 +39,8 @@ import hudson.util.ArgumentListBuilder;
import
hudson.util.FormValidation
;
import
hudson.util.HttpResponses
;
import
hudson.util.Secret
;
import
java.io.OutputStream
;
import
java.nio.file.Files
;
import
jenkins.model.Jenkins
;
import
jenkins.security.MasterToSlaveCallable
;
import
net.sf.json.JSONObject
;
...
...
@@ -519,7 +521,7 @@ public class JDKInstaller extends ToolInstaller {
File
tmp
=
new
File
(
cache
.
getPath
()+
".tmp"
);
try
{
tmp
.
getParentFile
().
mkdirs
();
try
(
FileOutputStream
out
=
new
FileOutputStream
(
tmp
))
{
try
(
OutputStream
out
=
Files
.
newOutputStream
(
tmp
.
toPath
()
))
{
IOUtils
.
copy
(
m
.
getResponseBodyAsStream
(),
out
);
}
...
...
core/src/main/java/hudson/util/AtomicFileWriter.java
浏览文件 @
466d74d1
...
...
@@ -32,6 +32,7 @@ import java.io.IOException;
import
java.io.OutputStreamWriter
;
import
java.io.Writer
;
import
java.nio.charset.Charset
;
import
java.nio.file.Files
;
/**
* Buffered {@link FileWriter} that supports atomic operations.
...
...
@@ -70,7 +71,7 @@ public class AtomicFileWriter extends Writer {
destFile
=
f
;
if
(
encoding
==
null
)
encoding
=
Charset
.
defaultCharset
().
name
();
core
=
new
BufferedWriter
(
new
OutputStreamWriter
(
new
FileOutputStream
(
tmpFile
),
encoding
));
core
=
new
BufferedWriter
(
new
OutputStreamWriter
(
Files
.
newOutputStream
(
tmpFile
.
toPath
()
),
encoding
));
}
@Override
...
...
core/src/main/java/hudson/util/CompressedFile.java
浏览文件 @
466d74d1
...
...
@@ -23,25 +23,23 @@
*/
package
hudson.util
;
import
com.jcraft.jzlib.GZIPInputStream
;
import
com.jcraft.jzlib.GZIPOutputStream
;
import
hudson.Util
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.OutputStream
;
import
java.io.Reader
;
import
java.nio.file.Files
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
com.jcraft.jzlib.GZIPInputStream
;
import
com.jcraft.jzlib.GZIPOutputStream
;
/**
* Represents write-once read-many file that can be optionally compressed
...
...
@@ -78,10 +76,10 @@ public class CompressedFile {
/**
* Gets the OutputStream to write to the file.
*/
public
OutputStream
write
()
throws
FileNotFound
Exception
{
public
OutputStream
write
()
throws
IO
Exception
{
if
(
gz
.
exists
())
gz
.
delete
();
return
new
FileOutputStream
(
file
);
return
Files
.
newOutputStream
(
file
.
toPath
()
);
}
/**
...
...
@@ -89,11 +87,11 @@ public class CompressedFile {
*/
public
InputStream
read
()
throws
IOException
{
if
(
file
.
exists
())
return
new
FileInputStream
(
file
);
return
Files
.
newInputStream
(
file
.
toPath
()
);
// check if the compressed file exists
if
(
gz
.
exists
())
return
new
GZIPInputStream
(
new
FileInputStream
(
gz
));
return
new
GZIPInputStream
(
Files
.
newInputStream
(
gz
.
toPath
()
));
// no such file
throw
new
FileNotFoundException
(
file
.
getName
());
...
...
@@ -138,7 +136,8 @@ public class CompressedFile {
compressionThread
.
submit
(
new
Runnable
()
{
public
void
run
()
{
try
{
try
(
InputStream
in
=
read
();
OutputStream
out
=
new
GZIPOutputStream
(
new
FileOutputStream
(
gz
)))
{
try
(
InputStream
in
=
read
();
OutputStream
out
=
new
GZIPOutputStream
(
Files
.
newOutputStream
(
gz
.
toPath
())))
{
Util
.
copyStream
(
in
,
out
);
}
// if the compressed file is created successfully, remove the original
...
...
core/src/main/java/hudson/util/IOUtils.java
浏览文件 @
466d74d1
...
...
@@ -3,6 +3,7 @@ package hudson.util;
import
hudson.Functions
;
import
hudson.os.PosixAPI
;
import
hudson.os.PosixException
;
import
java.nio.file.Files
;
import
org.apache.commons.io.LineIterator
;
import
java.io.*
;
...
...
@@ -26,20 +27,14 @@ public class IOUtils {
}
public
static
void
copy
(
File
src
,
OutputStream
out
)
throws
IOException
{
FileInputStream
in
=
new
FileInputStream
(
src
);
try
{
try
(
InputStream
in
=
Files
.
newInputStream
(
src
.
toPath
()))
{
org
.
apache
.
commons
.
io
.
IOUtils
.
copy
(
in
,
out
);
}
finally
{
org
.
apache
.
commons
.
io
.
IOUtils
.
closeQuietly
(
in
);
}
}
public
static
void
copy
(
InputStream
in
,
File
out
)
throws
IOException
{
FileOutputStream
fos
=
new
FileOutputStream
(
out
);
try
{
try
(
OutputStream
fos
=
Files
.
newOutputStream
(
out
.
toPath
()))
{
org
.
apache
.
commons
.
io
.
IOUtils
.
copy
(
in
,
fos
);
}
finally
{
org
.
apache
.
commons
.
io
.
IOUtils
.
closeQuietly
(
fos
);
}
}
...
...
core/src/main/java/hudson/util/SecretRewriter.java
浏览文件 @
466d74d1
...
...
@@ -4,6 +4,8 @@ import com.trilead.ssh2.crypto.Base64;
import
hudson.Functions
;
import
hudson.model.TaskListener
;
import
java.io.InputStream
;
import
java.nio.file.Files
;
import
javax.crypto.Cipher
;
import
javax.crypto.SecretKey
;
import
java.io.BufferedReader
;
...
...
@@ -84,7 +86,7 @@ public class SecretRewriter {
boolean
modified
=
false
;
// did we actually change anything?
try
(
PrintWriter
out
=
new
PrintWriter
(
new
BufferedWriter
(
w
)))
{
try
(
FileInputStream
fin
=
new
FileInputStream
(
f
))
{
try
(
InputStream
fin
=
Files
.
newInputStream
(
f
.
toPath
()
))
{
BufferedReader
r
=
new
BufferedReader
(
new
InputStreamReader
(
fin
,
"UTF-8"
));
String
line
;
StringBuilder
buf
=
new
StringBuilder
();
...
...
core/src/main/java/hudson/util/StreamTaskListener.java
浏览文件 @
466d74d1
...
...
@@ -30,7 +30,6 @@ import hudson.model.TaskListener;
import
hudson.remoting.RemoteOutputStream
;
import
java.io.Closeable
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.ObjectInputStream
;
import
java.io.ObjectOutputStream
;
...
...
@@ -42,6 +41,9 @@ import java.io.Serializable;
import
java.io.UnsupportedEncodingException
;
import
java.io.Writer
;
import
java.nio.charset.Charset
;
import
java.nio.file.Files
;
import
java.nio.file.OpenOption
;
import
java.nio.file.StandardOpenOption
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
org.kohsuke.stapler.framework.io.WriterOutputStream
;
...
...
@@ -94,7 +96,7 @@ public class StreamTaskListener extends AbstractTaskListener implements Serializ
// don't do buffering so that what's written to the listener
// gets reflected to the file immediately, which can then be
// served to the browser immediately
this
(
new
FileOutputStream
(
out
),
charset
);
this
(
Files
.
newOutputStream
(
out
.
toPath
()
),
charset
);
}
/**
...
...
@@ -110,7 +112,12 @@ public class StreamTaskListener extends AbstractTaskListener implements Serializ
// don't do buffering so that what's written to the listener
// gets reflected to the file immediately, which can then be
// served to the browser immediately
this
(
new
FileOutputStream
(
out
,
append
),
charset
);
this
(
Files
.
newOutputStream
(
out
.
toPath
(),
StandardOpenOption
.
CREATE
,
append
?
StandardOpenOption
.
APPEND
:
StandardOpenOption
.
TRUNCATE_EXISTING
),
charset
);
}
public
StreamTaskListener
(
Writer
w
)
throws
IOException
{
...
...
core/src/main/java/hudson/util/TextFile.java
浏览文件 @
466d74d1
...
...
@@ -25,6 +25,7 @@ package hudson.util;
import
com.google.common.collect.*
;
import
java.nio.file.Files
;
import
javax.annotation.Nonnull
;
import
java.io.BufferedReader
;
import
java.io.File
;
...
...
@@ -67,7 +68,7 @@ public class TextFile {
public
String
read
()
throws
IOException
{
StringWriter
out
=
new
StringWriter
();
PrintWriter
w
=
new
PrintWriter
(
out
);
try
(
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
new
FileInputStream
(
file
),
"UTF-8"
)))
{
try
(
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
Files
.
newInputStream
(
file
.
toPath
()
),
"UTF-8"
)))
{
String
line
;
while
((
line
=
in
.
readLine
())
!=
null
)
w
.
println
(
line
);
...
...
@@ -83,7 +84,8 @@ public class TextFile {
@Override
public
Iterator
<
String
>
iterator
()
{
try
{
final
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
new
FileInputStream
(
file
),
"UTF-8"
));
final
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
Files
.
newInputStream
(
file
.
toPath
()),
"UTF-8"
));
return
new
AbstractIterator
<
String
>()
{
@Override
...
...
core/src/main/java/hudson/util/io/ReopenableFileOutputStream.java
浏览文件 @
466d74d1
...
...
@@ -28,6 +28,9 @@ import java.io.FileNotFoundException;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.nio.file.Files
;
import
java.nio.file.NoSuchFileException
;
import
java.nio.file.StandardOpenOption
;
/**
* {@link OutputStream} that writes to a file.
...
...
@@ -52,8 +55,9 @@ import java.io.OutputStream;
private
synchronized
OutputStream
current
()
throws
IOException
{
if
(
current
==
null
)
try
{
current
=
new
FileOutputStream
(
out
,
appendOnNextOpen
);
}
catch
(
FileNotFoundException
e
)
{
current
=
Files
.
newOutputStream
(
out
.
toPath
(),
StandardOpenOption
.
CREATE
,
appendOnNextOpen
?
StandardOpenOption
.
APPEND
:
StandardOpenOption
.
TRUNCATE_EXISTING
);
}
catch
(
FileNotFoundException
|
NoSuchFileException
e
)
{
throw
new
IOException
(
"Failed to open "
+
out
,
e
);
}
return
current
;
...
...
core/src/main/java/hudson/util/io/RewindableFileOutputStream.java
浏览文件 @
466d74d1
...
...
@@ -28,6 +28,9 @@ import java.io.FileNotFoundException;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.nio.file.Files
;
import
java.nio.file.NoSuchFileException
;
import
java.nio.file.StandardOpenOption
;
import
org.apache.commons.io.FileUtils
;
/**
...
...
@@ -51,8 +54,8 @@ public class RewindableFileOutputStream extends OutputStream {
if
(!
closed
)
{
FileUtils
.
forceMkdir
(
out
.
getParentFile
());
try
{
current
=
new
FileOutputStream
(
out
,
false
);
}
catch
(
FileNotFoundException
e
)
{
current
=
Files
.
newOutputStream
(
out
.
toPath
(),
StandardOpenOption
.
CREATE
,
StandardOpenOption
.
TRUNCATE_EXISTING
);
}
catch
(
FileNotFoundException
|
NoSuchFileException
e
)
{
throw
new
IOException
(
"Failed to open "
+
out
,
e
);
}
}
...
...
core/src/main/java/hudson/util/io/TarArchiver.java
浏览文件 @
466d74d1
...
...
@@ -32,8 +32,10 @@ import hudson.util.IOUtils;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.nio.file.Files
;
import
org.apache.commons.compress.archivers.tar.TarArchiveEntry
;
import
org.apache.commons.compress.archivers.tar.TarArchiveOutputStream
;
import
org.apache.commons.compress.archivers.tar.TarConstants
;
...
...
@@ -100,7 +102,7 @@ final class TarArchiver extends Archiver {
if
(!
file
.
isDirectory
())
{
// ensure we don't write more bytes than the declared when we created the entry
try
(
FileInputStream
fin
=
new
FileInputStream
(
file
);
try
(
InputStream
fin
=
Files
.
newInputStream
(
file
.
toPath
()
);
BoundedInputStream
in
=
new
BoundedInputStream
(
fin
,
size
))
{
int
len
;
while
((
len
=
in
.
read
(
buf
))
>=
0
)
{
...
...
core/src/main/java/hudson/util/io/ZipArchiver.java
浏览文件 @
466d74d1
...
...
@@ -26,6 +26,8 @@ package hudson.util.io;
import
hudson.util.FileVisitor
;
import
hudson.util.IOUtils
;
import
java.io.InputStream
;
import
java.nio.file.Files
;
import
org.apache.tools.zip.ZipEntry
;
import
org.apache.tools.zip.ZipOutputStream
;
...
...
@@ -69,13 +71,10 @@ final class ZipArchiver extends Archiver {
if
(
mode
!=-
1
)
fileZipEntry
.
setUnixMode
(
mode
);
fileZipEntry
.
setTime
(
f
.
lastModified
());
zip
.
putNextEntry
(
fileZipEntry
);
FileInputStream
in
=
new
FileInputStream
(
f
);
try
{
try
(
InputStream
in
=
Files
.
newInputStream
(
f
.
toPath
()))
{
int
len
;
while
((
len
=
in
.
read
(
buf
))>=
0
)
zip
.
write
(
buf
,
0
,
len
);
}
finally
{
in
.
close
();
}
zip
.
closeEntry
();
}
...
...
core/src/main/java/jenkins/diagnosis/HsErrPidList.java
浏览文件 @
466d74d1
...
...
@@ -6,6 +6,9 @@ import hudson.Functions;
import
hudson.Util
;
import
hudson.model.AdministrativeMonitor
;
import
hudson.util.jna.Kernel32Utils
;
import
java.nio.file.Files
;
import
java.nio.file.OpenOption
;
import
java.nio.file.StandardOpenOption
;
import
jenkins.model.Jenkins
;
import
org.apache.tools.ant.DirectoryScanner
;
import
org.apache.tools.ant.Project
;
...
...
@@ -49,7 +52,7 @@ public class HsErrPidList extends AdministrativeMonitor {
return
;
}
try
{
try
(
FileChannel
ch
=
new
FileInputStream
(
getSecretKeyFile
()).
getChannel
(
))
{
try
(
FileChannel
ch
=
FileChannel
.
open
(
getSecretKeyFile
().
toPath
(),
StandardOpenOption
.
READ
))
{
map
=
ch
.
map
(
MapMode
.
READ_ONLY
,
0
,
1
);
}
...
...
core/src/main/java/jenkins/security/DefaultConfidentialStore.java
浏览文件 @
466d74d1
...
...
@@ -4,6 +4,9 @@ import hudson.FilePath;
import
hudson.Util
;
import
hudson.util.Secret
;
import
hudson.util.TextFile
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.nio.file.Files
;
import
jenkins.model.Jenkins
;
import
javax.crypto.Cipher
;
...
...
@@ -72,11 +75,11 @@ public class DefaultConfidentialStore extends ConfidentialStore {
@Override
protected
void
store
(
ConfidentialKey
key
,
byte
[]
payload
)
throws
IOException
{
CipherOutputStream
cos
=
null
;
File
OutputStream
fos
=
null
;
OutputStream
fos
=
null
;
try
{
Cipher
sym
=
Secret
.
getCipher
(
"AES"
);
sym
.
init
(
Cipher
.
ENCRYPT_MODE
,
masterKey
);
cos
=
new
CipherOutputStream
(
fos
=
new
FileOutputStream
(
getFileFor
(
key
)),
sym
);
cos
=
new
CipherOutputStream
(
fos
=
Files
.
newOutputStream
(
getFileFor
(
key
).
toPath
(
)),
sym
);
cos
.
write
(
payload
);
cos
.
write
(
MAGIC
);
}
catch
(
GeneralSecurityException
e
)
{
...
...
@@ -96,14 +99,14 @@ public class DefaultConfidentialStore extends ConfidentialStore {
@Override
protected
byte
[]
load
(
ConfidentialKey
key
)
throws
IOException
{
CipherInputStream
cis
=
null
;
File
InputStream
fis
=
null
;
InputStream
fis
=
null
;
try
{
File
f
=
getFileFor
(
key
);
if
(!
f
.
exists
())
return
null
;
Cipher
sym
=
Secret
.
getCipher
(
"AES"
);
sym
.
init
(
Cipher
.
DECRYPT_MODE
,
masterKey
);
cis
=
new
CipherInputStream
(
fis
=
new
FileInputStream
(
f
),
sym
);
cis
=
new
CipherInputStream
(
fis
=
Files
.
newInputStream
(
f
.
toPath
()
),
sym
);
byte
[]
bytes
=
IOUtils
.
toByteArray
(
cis
);
return
verifyMagic
(
bytes
);
}
catch
(
GeneralSecurityException
e
)
{
...
...
core/src/main/java/jenkins/util/AntClassLoader.java
浏览文件 @
466d74d1
...
...
@@ -17,6 +17,7 @@
*/
package
jenkins.util
;
import
java.nio.file.Files
;
import
org.apache.tools.ant.BuildEvent
;
import
org.apache.tools.ant.BuildException
;
import
org.apache.tools.ant.Project
;
...
...
@@ -790,7 +791,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener {
if
(
jarFile
==
null
&&
file
.
isDirectory
())
{
File
resource
=
new
File
(
file
,
resourceName
);
if
(
resource
.
exists
())
{
return
new
FileInputStream
(
resource
);
return
Files
.
newInputStream
(
resource
.
toPath
()
);
}
}
else
{
if
(
jarFile
==
null
)
{
...
...
core/src/main/java/jenkins/util/JSONSignatureValidator.java
浏览文件 @
466d74d1
...
...
@@ -2,6 +2,7 @@ package jenkins.util;
import
com.trilead.ssh2.crypto.Base64
;
import
hudson.util.FormValidation
;
import
java.nio.file.Files
;
import
jenkins.model.Jenkins
;
import
net.sf.json.JSONObject
;
import
org.apache.commons.io.output.NullOutputStream
;
...
...
@@ -173,9 +174,8 @@ public class JSONSignatureValidator {
if
(
cert
.
isDirectory
()
||
cert
.
getName
().
endsWith
(
".txt"
))
{
continue
;
// skip directories also any text files that are meant to be documentation
}
FileInputStream
in
=
new
FileInputStream
(
cert
);
Certificate
certificate
;
try
{
try
(
InputStream
in
=
Files
.
newInputStream
(
cert
.
toPath
()))
{
certificate
=
cf
.
generateCertificate
(
in
);
}
catch
(
CertificateException
e
)
{
LOGGER
.
log
(
Level
.
WARNING
,
String
.
format
(
"Files in %s are expected to be either "
...
...
@@ -184,8 +184,6 @@ public class JSONSignatureValidator {
cert
.
getParentFile
().
getAbsolutePath
(),
cert
.
getAbsolutePath
()),
e
);
continue
;
}
finally
{
in
.
close
();
}
try
{
TrustAnchor
certificateAuthority
=
new
TrustAnchor
((
X509Certificate
)
certificate
,
null
);
...
...
core/src/main/java/jenkins/util/VirtualFile.java
浏览文件 @
466d74d1
...
...
@@ -38,6 +38,7 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.io.Serializable
;
import
java.net.URI
;
import
java.nio.file.Files
;
import
java.nio.file.InvalidPathException
;
import
java.nio.file.LinkOption
;
import
java.util.ArrayList
;
...
...
@@ -295,7 +296,7 @@ public abstract class VirtualFile implements Comparable<VirtualFile>, Serializab
if
(
isIllegalSymlink
())
{
throw
new
FileNotFoundException
(
f
.
getPath
());
}
return
new
FileInputStream
(
f
);
return
Files
.
newInputStream
(
f
.
toPath
()
);
}
private
boolean
isIllegalSymlink
()
{
// TODO JENKINS-26838
try
{
...
...
core/src/main/java/jenkins/util/io/FileBoolean.java
浏览文件 @
466d74d1
package
jenkins.util.io
;
import
java.nio.file.Files
;
import
jenkins.model.Jenkins
;
import
java.io.File
;
...
...
@@ -56,7 +57,7 @@ public class FileBoolean {
public
void
on
()
{
try
{
file
.
getParentFile
().
mkdirs
();
new
FileOutputStream
(
file
).
close
();
Files
.
newOutputStream
(
file
.
toPath
()
).
close
();
get
();
// update state
}
catch
(
IOException
e
)
{
LOGGER
.
log
(
Level
.
WARNING
,
"Failed to touch "
+
file
);
...
...
core/src/main/java/jenkins/util/xml/XMLUtils.java
浏览文件 @
466d74d1
package
jenkins.util.xml
;
import
java.io.InputStream
;
import
java.nio.file.Files
;
import
jenkins.util.SystemProperties
;
import
org.apache.commons.io.IOUtils
;
import
org.kohsuke.accmod.Restricted
;
...
...
@@ -137,16 +139,9 @@ public final class XMLUtils {
throw
new
IllegalArgumentException
(
String
.
format
(
"File %s does not exist or is not a 'normal' file."
,
file
.
getAbsolutePath
()));
}
FileInputStream
fileInputStream
=
new
FileInputStream
(
file
);
try
{
InputStreamReader
fileReader
=
new
InputStreamReader
(
fileInputStream
,
encoding
);
try
{
return
parse
(
fileReader
);
}
finally
{
IOUtils
.
closeQuietly
(
fileReader
);
}
}
finally
{
IOUtils
.
closeQuietly
(
fileInputStream
);
try
(
InputStream
fileInputStream
=
Files
.
newInputStream
(
file
.
toPath
());
InputStreamReader
fileReader
=
new
InputStreamReader
(
fileInputStream
,
encoding
))
{
return
parse
(
fileReader
);
}
}
...
...
core/src/main/resources/jenkins/install/SetupWizard/authenticate-security-token.jelly
浏览文件 @
466d74d1
<?jelly escape-by-default='true'?>
<l:html norefresh="true" title="${app.instance.displayName}" xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:s="/lib/form">
<l:layout norefresh="true" type="full-screen" title="${app.instance.displayName}">
<l:main-panel>
<st:include page="client-scripts" />
<form action="${app.instance.securityRealm.authenticationGatewayUrl}" method="POST">
<st:include page="client-scripts" />
<form action="${app.instance.securityRealm.authenticationGatewayUrl}" method="POST">
<input type="hidden" name="from" value="${request.getParameter('from')}" />
<div class="plugin-setup-wizard bootstrap-3">
<div class="modal fade in" style="display: block;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">${%authenticate-security-token.getting.started}</h4>
</div>
<div class="modal-body">
<i class="water-mark icon-service"></i>
<div class="jumbotron welcome-panel offline">
<h1>${%authenticate-security-token.unlock.jenkins}</h1>
<p>
${%jenkins.install.findSecurityTokenMessage(it.initialAdminPasswordFile)}
</p>
<p>${%jenkins.install.findSecurityTokenMessage(it.initialAdminPasswordFile)}</p>
<p>${%authenticate-security-token.copy.password}</p>
<j:if test="${error}">
<div class="alert alert-danger">
<strong>${%authenticate-security-token.error} </strong>
${%authenticate-security-token.password.incorrect}
<strong>${%authenticate-security-token.error}</strong> ${%authenticate-security-token.password.incorrect}
</div>
</j:if>
<div class="form-group ${error ? 'has-error' : ''}">
<label class="control-label" for="security-token">${%authenticate-security-token.password.administrator}</label>
<input name="j_username" value="${app.setupWizard.initialSetupAdminUserName}" type="hidden"/>
<input id="security-token" class="form-control" type="password" name="j_password"/>
<label class="control-label" for="security-token">${%authenticate-security-token.password.administrator}</label>
<input name="j_username" value="${app.setupWizard.initialSetupAdminUserName}" type="hidden"/>
<input id="security-token" class="form-control" type="password" name="j_password"/>
</div>
</div>
</div>
<div class="modal-footer">
...
...
@@ -42,6 +38,8 @@
</div>
</div>
</div>
</form>
</l:main-panel>
</l:html>
</form>
</l:main-panel>
</l:layout>
</j:jelly>
\ No newline at end of file
core/src/main/resources/jenkins/install/SetupWizard/index.jelly
浏览文件 @
466d74d1
<?jelly escape-by-default='true'?>
<l:html norefresh="true" title="${it.displayName}" xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<l:main-panel>
<div class="plugin-setup-wizard-container"></div>
<st:include page="wizard-ui"/>
</l:main-panel>
</l:html>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<l:layout norefresh="true" type="full-screen" title="${it.displayName}">
<l:main-panel>
<div class="plugin-setup-wizard-container"></div>
<st:include page="wizard-ui"/>
</l:main-panel>
</l:layout>
</j:jelly>
core/src/main/resources/jenkins/install/SetupWizard/proxy-configuration.jelly
浏览文件 @
466d74d1
<?jelly escape-by-default='true'?>
<l:html norefresh="true" title="${it.displayName}" xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<l:main-panel>
<h1>${%HTTP Proxy Configuration}</h1>
<f:form method="post" action="/pluginManager/proxyConfigure" name="proxyConfigure">
<j:scope>
<j:set var="instance" value="${app.proxy}"/>
<j:set var="descriptor" value="${app.pluginManager.proxyDescriptor}"/>
<st:include from="${descriptor}" page="${descriptor.configPage}" />
</j:scope>
</f:form>
</l:main-panel>
</l:html>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<l:layout norefresh="true" type="full-screen" title="${it.displayName}">
<l:main-panel>
<style type="text/css">
#proxy-configuration {
margin: 8px;
}
</style>
<div id="proxy-configuration">
<h1>${%HTTP Proxy Configuration}</h1>
<f:form method="post" action="/pluginManager/proxyConfigure" name="proxyConfigure">
<j:scope>
<j:set var="instance" value="${app.proxy}"/>
<j:set var="descriptor" value="${app.pluginManager.proxyDescriptor}"/>
<st:include from="${descriptor}" page="${descriptor.configPage}" />
</j:scope>
</f:form>
</div>
</l:main-panel>
</l:layout>
</j:jelly>
core/src/main/resources/jenkins/install/SetupWizard/setupWizardFirstUser.jelly
浏览文件 @
466d74d1
<!--
This is used to create the first user.
-->
<?jelly escape-by-default='true'?>
<
l:html norefresh="true" title="${it.displayName}" xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f
="/lib/form">
<
j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:s
="/lib/form">
<l:main-panel>
<l:layout norefresh="true" type="full-screen" title="${it.displayName}">
<l:main-panel>
<link rel="stylesheet" href="${resURL}/css/google-fonts/roboto/css/roboto.css" type="text/css" />
<style type="text/css">
<link rel="stylesheet" href="${resURL}/css/google-fonts/roboto/css/roboto.css" type="text/css" />
<style type="text/css">
#main-panel {
margin: 0;
padding: 0;
}
tr td {
padding-bottom: 2px;
}
body {
#create-admin-user {
padding: 20px 20px 20px 100px;
font-family: 'roboto';
}
form > div {
margin: 8px;
}
#create-admin-user form > div {
margin: 0 !important;
}
h1 {
}
#create-admin-user h1 {
font-family: 'roboto', sans-serif;
font-size: 48px;
margin-top: 30px;
font-weight: 500;
}
h1 img {
position: absolute;
right: -80
px;
top: 38px;
}
tr td,
input {
}
#create-admin-user tr td {
padding-bottom: 2
px;
}
#create-admin-user tr td, #create-admin-user
input {
line-height: 25px;
margin-bottom: 6px;
}
input[type=text], input[type=password] {
}
#create-admin-user input[type=text], input[type=password] {
border: 1px solid #ddd;
border-radius: 2px;
padding: 1px 8px;
}
</style>
<form action="${rootURL}/setupWizard/createAdminUser" method="post">
<local:_entryForm it="${app.securityRealm}" host="${app.securityRealm}" title="${%Create First Admin User}" captcha="${false}" xmlns:local="/hudson/security/HudsonPrivateSecurityRealm" />
<script>
$('username').focus();
</script>
</form>
</l:main-panel>
</l:html>
}
</style>
<div id="create-admin-user">
<form action="${rootURL}/setupWizard/createAdminUser" method="post">
<local:_entryForm it="${app.securityRealm}" host="${app.securityRealm}" title="${%Create First Admin User}" captcha="${false}" xmlns:local="/hudson/security/HudsonPrivateSecurityRealm" />
<script>
$('username').focus();
</script>
</form>
</div>
</l:main-panel>
</l:layout>
</j:jelly>
\ No newline at end of file
core/src/main/resources/jenkins/management/AdministrativeMonitorsDecorator/resources.css
浏览文件 @
466d74d1
...
...
@@ -29,7 +29,6 @@
height
:
auto
;
z-index
:
0
;
padding
:
2em
;
border
:
1px
solid
#aa
;
text-align
:
left
;
display
:
block
;
background-color
:
#fff
;
...
...
core/src/main/resources/lib/layout/html.jelly
浏览文件 @
466d74d1
...
...
@@ -26,6 +26,9 @@ THE SOFTWARE.
<?jelly escape-by-default='true'?>
<j:jelly
xmlns:j=
"jelly:core"
xmlns:st=
"jelly:stapler"
xmlns:d=
"jelly:define"
xmlns:l=
"/lib/layout"
xmlns:i=
"jelly:fmt"
xmlns:x=
"jelly:xml"
>
<st:documentation>
This Jelly tag is deprecated, use
<l:layout
/>
tag instead. Defined on layout.jelly.
Outer-most tag for a normal (non-AJAX) HTML rendering.
This is used with nested
<
header>,
<
side-panel>, and
<
main-panel>
to form Jenkins's basic HTML layout.
...
...
core/src/main/resources/lib/layout/layout.jelly
浏览文件 @
466d74d1
...
...
@@ -53,7 +53,7 @@ THE SOFTWARE.
(The permission will be checked against the "it" object.)
</st:attribute>
<st:attribute
name=
"type"
use=
"optional"
>
Available values: two-column (by default)
or one-column (full-width size
).
Available values: two-column (by default)
, one-column (full-width size) or full-screen (since TODO
).
</st:attribute>
</st:documentation>
<st:setHeader
name=
"Expires"
value=
"0"
/>
...
...
@@ -69,9 +69,14 @@ ${h.initPageVariables(context)}
this also allows us to configure HttpSessionContextIntegrationFilter not to create sessions,
which I suspect can end up creating sessions for wrong resource types (such as static resources.)
-->
<j:if
test=
"${attrs.type==null}"
>
<j:set
var=
"layoutType"
value=
"two-column"
/>
</j:if>
<j:if
test=
"${attrs.type!=null}"
>
<j:set
var=
"layoutType"
value=
"${attrs.type}"
/>
</j:if>
<j:set
var=
"isMSIE"
value=
"${userAgent.contains('MSIE')}"
/>
<j:set
var=
"_"
value=
"${request.getSession()}"
/>
<j:set
var=
"_"
value=
"${h.configureAutoRefresh(request, response, attrs.norefresh!=null and !attrs.norefresh.equals(false))}"
/>
...
...
@@ -169,7 +174,9 @@ ${h.initPageVariables(context)}
<
script
src
=
"
${resURL}/jsbundles/page-init.js
"
type
=
"
text/javascript
"
/>
<
/head
>
<
body
id
=
"
jenkins
"
class
=
"
yui-skin-sam jenkins-${h.version} ${layoutType}
"
data
-
version
=
"
${h.version}
"
data
-
model
-
type
=
"
${it.class.name}
"
>
<
body
id
=
"
jenkins
"
class
=
"
yui-skin-sam ${layoutType} jenkins-${h.version}
"
data
-
version
=
"
${h.version}
"
data
-
model
-
type
=
"
${it.class.name}
"
>
<
j
:
if
test
=
"
${layoutType!='full-screen'}
"
>
<!--
for
accessibility
,
skip
the
entire
navigation
bar
and
etc
and
go
straight
to
the
head
of
the
content
-->
<
a
href
=
"
#skip2content
"
class
=
"
skiplink
"
>
Skip
to
content
<
/a
>
...
...
@@ -235,6 +242,7 @@ ${h.initPageVariables(context)}
</l:breadcrumbBar>
</div>
</div>
</j:if>
<div
id=
"page-body"
class=
"clear"
>
<j:if
test=
"${layoutType=='two-column'}"
>
...
...
@@ -260,6 +268,7 @@ ${h.initPageVariables(context)}
</div>
</div>
<j:if
test=
"${layoutType!='full-screen'}"
>
<footer>
<div
class=
"container-fluid"
>
<div
class=
"row"
>
...
...
@@ -279,6 +288,7 @@ ${h.initPageVariables(context)}
</div>
</div>
</footer>
</j:if>
</body>
</html>
...
...
core/src/test/java/hudson/FilePathTest.java
浏览文件 @
466d74d1
...
...
@@ -43,6 +43,7 @@ import java.net.URL;
import
java.net.URLConnection
;
import
java.net.URLStreamHandler
;
import
java.net.URLStreamHandlerFactory
;
import
java.nio.file.Files
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashSet
;
...
...
@@ -134,12 +135,12 @@ public class FilePathTest {
}
private
void
givenSomeContentInFile
(
File
file
,
int
size
)
throws
IOException
{
FileOutputStream
os
=
new
FileOutputStream
(
file
);
byte
[]
buf
=
new
byte
[
size
];
for
(
int
i
=
0
;
i
<
buf
.
length
;
i
++)
buf
[
i
]
=
(
byte
)(
i
%
256
);
os
.
write
(
buf
);
os
.
close
();
try
(
OutputStream
os
=
Files
.
newOutputStream
(
file
.
toPath
()))
{
byte
[]
buf
=
new
byte
[
size
];
for
(
int
i
=
0
;
i
<
buf
.
length
;
i
++)
buf
[
i
]
=
(
byte
)
(
i
%
256
);
os
.
write
(
buf
);
}
}
private
List
<
Future
<
Integer
>>
whenFileIsCopied100TimesConcurrently
(
final
File
file
)
throws
InterruptedException
{
...
...
@@ -369,7 +370,7 @@ public class FilePathTest {
// Compress archive
final
FilePath
tmpDirPath
=
new
FilePath
(
tmpDir
);
int
tar
=
tmpDirPath
.
tar
(
new
FileOutputStream
(
tarFile
),
tempFile
.
getName
());
int
tar
=
tmpDirPath
.
tar
(
Files
.
newOutputStream
(
tarFile
.
toPath
()
),
tempFile
.
getName
());
assertEquals
(
"One file should have been compressed"
,
1
,
tar
);
// Decompress
...
...
@@ -725,7 +726,7 @@ public class FilePathTest {
// Compress archive
final
FilePath
tmpDirPath
=
new
FilePath
(
srcFolder
);
int
tarred
=
tmpDirPath
.
tar
(
new
FileOutputStream
(
archive
),
"**"
);
int
tarred
=
tmpDirPath
.
tar
(
Files
.
newOutputStream
(
archive
.
toPath
()
),
"**"
);
assertEquals
(
"One file should have been compressed"
,
3
,
tarred
);
// Decompress
...
...
core/src/test/java/hudson/PluginManagerTest.java
浏览文件 @
466d74d1
...
...
@@ -26,6 +26,7 @@ package hudson;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.nio.file.Files
;
import
org.apache.tools.ant.filters.StringInputStream
;
import
org.junit.Test
;
import
org.xml.sax.SAXException
;
...
...
@@ -151,7 +152,7 @@ public class PluginManagerTest {
FileUtils
.
write
(
new
File
(
newFolder
,
manifestPath
),
SAMPLE_MANIFEST_FILE
);
final
File
f
=
new
File
(
tmp
.
getRoot
(),
"my.hpi"
);
try
(
ZipOutputStream
out
=
new
ZipOutputStream
(
new
FileOutputStream
(
f
)))
{
try
(
ZipOutputStream
out
=
new
ZipOutputStream
(
Files
.
newOutputStream
(
f
.
toPath
()
)))
{
ZipEntry
e
=
new
ZipEntry
(
manifestPath
);
out
.
putNextEntry
(
e
);
byte
[]
data
=
SAMPLE_MANIFEST_FILE
.
getBytes
();
...
...
core/src/test/java/hudson/UtilTest.java
浏览文件 @
466d74d1
...
...
@@ -488,9 +488,13 @@ public class UtilTest {
// On unix, can't use "chmod a-w" on the dir as the code-under-test undoes that.
// On unix, can't use "chattr +i" because that needs root.
// On unix, can't use "chattr +u" because ext fs ignores it.
// On Windows, can't use FileChannel.lock() because that doesn't block deletion
// On Windows, we can't delete files that are open for reading, so we use that.
// NOTE: This is a hack in any case as there is no guarantee that all Windows filesystems
// will enforce blocking deletion on open files... just that the ones we normally
// test with seem to block.
assert
Functions
.
isWindows
();
final
InputStream
s
=
new
FileInputStream
(
f
);
final
InputStream
s
=
new
FileInputStream
(
f
);
// intentional use of FileInputStream
unlockFileCallables
.
put
(
f
,
new
Callable
<
Void
>()
{
public
Void
call
()
throws
IOException
{
s
.
close
();
return
null
;
};
});
...
...
core/src/test/java/hudson/model/LoadStatisticsTest.java
浏览文件 @
466d74d1
...
...
@@ -26,6 +26,9 @@ package hudson.model;
import
hudson.model.MultiStageTimeSeries.TimeScale
;
import
hudson.model.queue.SubTask
;
import
java.io.OutputStream
;
import
java.nio.file.Files
;
import
java.nio.file.StandardOpenOption
;
import
org.apache.commons.io.IOUtils
;
import
org.jfree.chart.JFreeChart
;
import
org.junit.Test
;
...
...
@@ -87,11 +90,9 @@ public class LoadStatisticsTest {
BufferedImage
image
=
chart
.
createBufferedImage
(
400
,
200
);
File
tempFile
=
File
.
createTempFile
(
"chart-"
,
"png"
);
FileOutputStream
os
=
new
FileOutputStream
(
tempFile
);
try
{
try
(
OutputStream
os
=
Files
.
newOutputStream
(
tempFile
.
toPath
(),
StandardOpenOption
.
DELETE_ON_CLOSE
))
{
ImageIO
.
write
(
image
,
"PNG"
,
os
);
}
finally
{
IOUtils
.
closeQuietly
(
os
);
tempFile
.
delete
();
}
}
...
...
core/src/test/java/hudson/os/SUTester.java
浏览文件 @
466d74d1
package
hudson.os
;
import
hudson.util.StreamTaskListener
;
import
java.io.File
;
import
java.nio.file.Files
;
import
jenkins.security.MasterToSlaveCallable
;
import
java.io.FileOutputStream
;
...
...
@@ -13,7 +15,7 @@ public class SUTester {
SU
.
execute
(
StreamTaskListener
.
fromStdout
(),
"kohsuke"
,
"bogus"
,
new
MasterToSlaveCallable
<
Object
,
Throwable
>()
{
public
Object
call
()
throws
Throwable
{
System
.
out
.
println
(
"Touching /tmp/x"
);
new
FileOutputStream
(
"/tmp/x"
).
close
();
Files
.
newOutputStream
(
new
File
(
"/tmp/x"
).
toPath
()
).
close
();
return
null
;
}
});
...
...
core/src/test/java/hudson/util/io/TarArchiverTest.java
浏览文件 @
466d74d1
...
...
@@ -33,6 +33,8 @@ import hudson.util.StreamTaskListener;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.nio.file.Files
;
import
java.util.Arrays
;
import
static
org
.
junit
.
Assert
.*;
import
org.junit.Assume
;
...
...
@@ -71,8 +73,8 @@ public class TarArchiverTest {
f
.
chmod
(
0644
);
int
dirMode
=
dir
.
child
(
"subdir"
).
mode
();
dir
.
tar
(
new
FileOutputStream
(
tar
),
"**/*"
);
dir
.
zip
(
new
FileOutputStream
(
zip
));
dir
.
tar
(
Files
.
newOutputStream
(
tar
.
toPath
()
),
"**/*"
);
dir
.
zip
(
Files
.
newOutputStream
(
zip
.
toPath
()
));
FilePath
e
=
dir
.
child
(
"extract"
);
...
...
@@ -149,12 +151,12 @@ public class TarArchiverTest {
File
openFile
=
file
;
try
{
openFile
.
createNewFile
();
FileOutputStream
fos
=
new
FileOutputStream
(
openFile
);
for
(
int
i
=
0
;
!
finish
&&
i
<
5000000
;
i
++)
{
// limit the max size, just in case.
fos
.
write
(
0
);
// Thread.sleep(5);
try
(
OutputStream
fos
=
Files
.
newOutputStream
(
openFile
.
toPath
()))
{
for
(
int
i
=
0
;
!
finish
&&
i
<
5000000
;
i
++)
{
// limit the max size, just in case.
fos
.
write
(
0
);
// Thread.sleep(5);
}
}
fos
.
close
();
}
catch
(
Exception
e
)
{
ex
=
e
;
}
...
...
core/src/test/java/hudson/util/io/ZipArchiverTest.java
浏览文件 @
466d74d1
...
...
@@ -5,6 +5,7 @@ import static org.junit.Assert.assertEquals;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
java.util.zip.ZipEntry
;
...
...
@@ -62,7 +63,7 @@ public class ZipArchiverTest {
try
{
zipFile
=
File
.
createTempFile
(
"test"
,
".zip"
);
archiver
=
new
ZipArchiver
(
new
FileOutputStream
(
zipFile
));
archiver
=
new
ZipArchiver
(
Files
.
newOutputStream
(
zipFile
.
toPath
()
));
archiver
.
visit
(
tmpFile
,
"foo\\bar\\baz\\Test.txt"
);
}
catch
(
Exception
e
)
{
...
...
core/src/test/java/jenkins/util/VirtualFileTest.java
浏览文件 @
466d74d1
...
...
@@ -29,6 +29,7 @@ import hudson.Util;
import
hudson.model.TaskListener
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.nio.file.NoSuchFileException
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.IOUtils
;
import
org.junit.Test
;
...
...
@@ -63,9 +64,9 @@ public class VirtualFileTest {
try
{
hack
.
open
();
fail
();
}
catch
(
FileNotFoundException
x
)
{
}
catch
(
FileNotFoundException
|
NoSuchFileException
x
)
{
// OK
}
}
}
\ No newline at end of file
}
pom.xml
浏览文件 @
466d74d1
...
...
@@ -33,7 +33,7 @@ THE SOFTWARE.
<groupId>
org.jenkins-ci.main
</groupId>
<artifactId>
pom
</artifactId>
<version>
2.5
2
-SNAPSHOT
</version>
<version>
2.5
4
-SNAPSHOT
</version>
<packaging>
pom
</packaging>
<name>
Jenkins main module
</name>
...
...
test/pom.xml
浏览文件 @
466d74d1
...
...
@@ -28,7 +28,7 @@ THE SOFTWARE.
<parent>
<groupId>
org.jenkins-ci.main
</groupId>
<artifactId>
pom
</artifactId>
<version>
2.5
2
-SNAPSHOT
</version>
<version>
2.5
4
-SNAPSHOT
</version>
</parent>
<artifactId>
test
</artifactId>
...
...
test/src/test/java/hudson/model/DirectoryBrowserSupportTest.java
浏览文件 @
466d74d1
...
...
@@ -38,6 +38,7 @@ import java.io.File;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.nio.file.Files
;
import
java.util.zip.ZipFile
;
import
org.junit.Assume
;
...
...
@@ -204,7 +205,7 @@ public class DirectoryBrowserSupportTest {
File
file
=
File
.
createTempFile
(
"DirectoryBrowserSupport"
,
"zipDownload"
);
file
.
delete
();
Util
.
copyStreamAndClose
(
page
.
getInputStream
(),
new
FileOutputStream
(
file
));
Util
.
copyStreamAndClose
(
page
.
getInputStream
(),
Files
.
newOutputStream
(
file
.
toPath
()
));
return
file
;
}
...
...
test/src/test/java/hudson/tools/JDKInstallerTest.java
浏览文件 @
466d74d1
...
...
@@ -8,6 +8,8 @@ import com.gargoylesoftware.htmlunit.html.HtmlFormUtil;
import
com.gargoylesoftware.htmlunit.html.HtmlPage
;
import
hudson.tools.JDKInstaller.DescriptorImpl
;
import
java.io.InputStream
;
import
java.nio.file.Files
;
import
org.junit.Assume
;
import
org.junit.Before
;
import
org.junit.Rule
;
...
...
@@ -54,8 +56,7 @@ public class JDKInstallerTest {
LOGGER
.
warning
(
f
+
" doesn't exist. Skipping JDK installation tests"
);
}
else
{
Properties
prop
=
new
Properties
();
FileInputStream
in
=
new
FileInputStream
(
f
);
try
{
try
(
InputStream
in
=
Files
.
newInputStream
(
f
.
toPath
()))
{
prop
.
load
(
in
);
String
u
=
prop
.
getProperty
(
"oracle.userName"
);
String
p
=
prop
.
getProperty
(
"oracle.password"
);
...
...
@@ -65,8 +66,6 @@ public class JDKInstallerTest {
DescriptorImpl
d
=
j
.
jenkins
.
getDescriptorByType
(
DescriptorImpl
.
class
);
d
.
doPostCredential
(
u
,
p
);
}
}
finally
{
in
.
close
();
}
}
}
...
...
war/pom.xml
浏览文件 @
466d74d1
...
...
@@ -28,7 +28,7 @@ THE SOFTWARE.
<parent>
<groupId>
org.jenkins-ci.main
</groupId>
<artifactId>
pom
</artifactId>
<version>
2.5
2
-SNAPSHOT
</version>
<version>
2.5
4
-SNAPSHOT
</version>
</parent>
<artifactId>
jenkins-war
</artifactId>
...
...
@@ -114,7 +114,7 @@ THE SOFTWARE.
<dependency>
<groupId>
org.jenkins-ci.modules
</groupId>
<artifactId>
windows-slave-installer
</artifactId>
<version>
1.
7
</version>
<version>
1.
8
</version>
</dependency>
<dependency>
<groupId>
org.jenkins-ci.modules
</groupId>
...
...
war/src/main/webapp/css/layout-common.css
浏览文件 @
466d74d1
...
...
@@ -95,6 +95,14 @@ body.two-column #main-panel {
margin-left
:
320px
;
}
body
.full-screen
{
padding
:
0
;
}
body
.full-screen
#main-panel
{
padding
:
0
;
}
@media
(
max-width
:
970px
)
{
body
.two-column
#side-panel
{
width
:
100%
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录