Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
eedf2a4e
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,发现更多精彩内容 >>
未验证
提交
eedf2a4e
编写于
11月 22, 2019
作者:
O
Oleg Nenashev
提交者:
GitHub
11月 22, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4262 from StefanSpieker/replace_getActiveInstance
Replaced deprecated getActiveInstance() with get()
上级
8bc435f3
5e275dbc
变更
39
隐藏空白更改
内联
并排
Showing
39 changed file
with
57 addition
and
60 deletion
+57
-60
core/src/main/java/hudson/PluginManager.java
core/src/main/java/hudson/PluginManager.java
+4
-4
core/src/main/java/hudson/PluginWrapper.java
core/src/main/java/hudson/PluginWrapper.java
+1
-1
core/src/main/java/hudson/cli/CLIAction.java
core/src/main/java/hudson/cli/CLIAction.java
+1
-1
core/src/main/java/hudson/cli/CLICommand.java
core/src/main/java/hudson/cli/CLICommand.java
+3
-3
core/src/main/java/hudson/cli/CancelQuietDownCommand.java
core/src/main/java/hudson/cli/CancelQuietDownCommand.java
+1
-1
core/src/main/java/hudson/cli/ClearQueueCommand.java
core/src/main/java/hudson/cli/ClearQueueCommand.java
+1
-1
core/src/main/java/hudson/cli/CopyJobCommand.java
core/src/main/java/hudson/cli/CopyJobCommand.java
+1
-1
core/src/main/java/hudson/cli/CreateJobCommand.java
core/src/main/java/hudson/cli/CreateJobCommand.java
+1
-1
core/src/main/java/hudson/cli/CreateNodeCommand.java
core/src/main/java/hudson/cli/CreateNodeCommand.java
+1
-1
core/src/main/java/hudson/cli/CreateViewCommand.java
core/src/main/java/hudson/cli/CreateViewCommand.java
+1
-1
core/src/main/java/hudson/cli/DeleteJobCommand.java
core/src/main/java/hudson/cli/DeleteJobCommand.java
+1
-1
core/src/main/java/hudson/cli/DeleteNodeCommand.java
core/src/main/java/hudson/cli/DeleteNodeCommand.java
+1
-1
core/src/main/java/hudson/cli/DisconnectNodeCommand.java
core/src/main/java/hudson/cli/DisconnectNodeCommand.java
+1
-1
core/src/main/java/hudson/cli/GroovyCommand.java
core/src/main/java/hudson/cli/GroovyCommand.java
+2
-2
core/src/main/java/hudson/cli/GroovyshCommand.java
core/src/main/java/hudson/cli/GroovyshCommand.java
+4
-4
core/src/main/java/hudson/cli/HelpCommand.java
core/src/main/java/hudson/cli/HelpCommand.java
+1
-1
core/src/main/java/hudson/cli/ListJobsCommand.java
core/src/main/java/hudson/cli/ListJobsCommand.java
+1
-1
core/src/main/java/hudson/cli/QuietDownCommand.java
core/src/main/java/hudson/cli/QuietDownCommand.java
+1
-1
core/src/main/java/hudson/cli/ReloadJobCommand.java
core/src/main/java/hudson/cli/ReloadJobCommand.java
+1
-1
core/src/main/java/hudson/cli/handlers/ViewOptionHandler.java
.../src/main/java/hudson/cli/handlers/ViewOptionHandler.java
+1
-1
core/src/main/java/hudson/model/AsyncAperiodicWork.java
core/src/main/java/hudson/model/AsyncAperiodicWork.java
+1
-1
core/src/main/java/hudson/model/AsyncPeriodicWork.java
core/src/main/java/hudson/model/AsyncPeriodicWork.java
+1
-1
core/src/main/java/hudson/model/Computer.java
core/src/main/java/hudson/model/Computer.java
+1
-1
core/src/main/java/hudson/model/Descriptor.java
core/src/main/java/hudson/model/Descriptor.java
+2
-2
core/src/main/java/hudson/model/DownloadService.java
core/src/main/java/hudson/model/DownloadService.java
+2
-2
core/src/main/java/hudson/model/Job.java
core/src/main/java/hudson/model/Job.java
+1
-1
core/src/main/java/hudson/model/OverallLoadStatistics.java
core/src/main/java/hudson/model/OverallLoadStatistics.java
+1
-1
core/src/main/java/jenkins/model/Jenkins.java
core/src/main/java/jenkins/model/Jenkins.java
+1
-1
core/src/main/java/jenkins/model/UnlabeledLoadStatistics.java
.../src/main/java/jenkins/model/UnlabeledLoadStatistics.java
+1
-1
core/src/main/java/jenkins/util/groovy/GroovyHookScript.java
core/src/main/java/jenkins/util/groovy/GroovyHookScript.java
+1
-1
core/src/test/java/hudson/cli/ListJobsCommandTest.java
core/src/test/java/hudson/cli/ListJobsCommandTest.java
+0
-1
core/src/test/java/hudson/cli/handlers/ViewOptionHandlerTest.java
.../test/java/hudson/cli/handlers/ViewOptionHandlerTest.java
+0
-1
test/src/test/java/hudson/cli/CancelQuietDownCommandTest.java
.../src/test/java/hudson/cli/CancelQuietDownCommandTest.java
+3
-3
test/src/test/java/hudson/cli/ConnectNodeCommandTest.java
test/src/test/java/hudson/cli/ConnectNodeCommandTest.java
+1
-1
test/src/test/java/hudson/cli/DisconnectNodeCommandTest.java
test/src/test/java/hudson/cli/DisconnectNodeCommandTest.java
+1
-1
test/src/test/java/hudson/cli/OfflineNodeCommandTest.java
test/src/test/java/hudson/cli/OfflineNodeCommandTest.java
+2
-2
test/src/test/java/hudson/cli/OnlineNodeCommandTest.java
test/src/test/java/hudson/cli/OnlineNodeCommandTest.java
+1
-1
test/src/test/java/hudson/cli/QuietDownCommandTest.java
test/src/test/java/hudson/cli/QuietDownCommandTest.java
+5
-5
test/src/test/java/hudson/model/UsageStatisticsTest.java
test/src/test/java/hudson/model/UsageStatisticsTest.java
+3
-4
未找到文件。
core/src/main/java/hudson/PluginManager.java
浏览文件 @
eedf2a4e
...
...
@@ -633,7 +633,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
protected
@Nonnull
Set
<
String
>
loadPluginsFromWar
(
@Nonnull
String
fromPath
,
@CheckForNull
FilenameFilter
filter
)
{
Set
<
String
>
names
=
new
HashSet
();
ServletContext
context
=
Jenkins
.
get
ActiveInstance
().
servletContext
;
ServletContext
context
=
Jenkins
.
get
().
servletContext
;
Set
<
String
>
plugins
=
Util
.
fixNull
(
context
.
getResourcePaths
(
fromPath
));
Set
<
URL
>
copiedPlugins
=
new
HashSet
<>();
Set
<
URL
>
dependencies
=
new
HashSet
<>();
...
...
@@ -697,7 +697,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
String
dependencySpec
=
manifest
.
getMainAttributes
().
getValue
(
"Plugin-Dependencies"
);
if
(
dependencySpec
!=
null
)
{
String
[]
dependencyTokens
=
dependencySpec
.
split
(
","
);
ServletContext
context
=
Jenkins
.
get
ActiveInstance
().
servletContext
;
ServletContext
context
=
Jenkins
.
get
().
servletContext
;
for
(
String
dependencyToken
:
dependencyTokens
)
{
if
(
dependencyToken
.
endsWith
(
";resolution:=optional"
))
{
...
...
@@ -709,7 +709,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
String
artifactId
=
artifactIdVersionPair
[
0
];
VersionNumber
dependencyVersion
=
new
VersionNumber
(
artifactIdVersionPair
[
1
]);
PluginManager
manager
=
Jenkins
.
get
ActiveInstance
().
getPluginManager
();
PluginManager
manager
=
Jenkins
.
get
().
getPluginManager
();
VersionNumber
installedVersion
=
manager
.
getPluginVersion
(
manager
.
rootDir
,
artifactId
);
if
(
installedVersion
!=
null
&&
!
installedVersion
.
isOlderThan
(
dependencyVersion
))
{
// Do not downgrade dependencies that are already installed.
...
...
@@ -1376,7 +1376,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
}
response
.
add
(
pluginInfo
);
}
for
(
UpdateSite
site
:
Jenkins
.
get
ActiveInstance
().
getUpdateCenter
().
getSiteList
())
{
for
(
UpdateSite
site
:
Jenkins
.
get
().
getUpdateCenter
().
getSiteList
())
{
for
(
UpdateSite
.
Plugin
plugin:
site
.
getAvailables
())
{
JSONObject
pluginInfo
=
allPlugins
.
get
(
plugin
.
name
);
if
(
pluginInfo
==
null
)
{
...
...
core/src/main/java/hudson/PluginWrapper.java
浏览文件 @
eedf2a4e
...
...
@@ -1251,7 +1251,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
@RequirePOST
public
HttpResponse
doDoUninstall
()
throws
IOException
{
Jenkins
jenkins
=
Jenkins
.
get
ActiveInstance
();
Jenkins
jenkins
=
Jenkins
.
get
();
jenkins
.
checkPermission
(
Jenkins
.
ADMINISTER
);
archive
.
delete
();
...
...
core/src/main/java/hudson/cli/CLIAction.java
浏览文件 @
eedf2a4e
...
...
@@ -85,7 +85,7 @@ public class CLIAction implements UnprotectedRootAction, StaplerProxy {
}
public
void
doCommand
(
StaplerRequest
req
,
StaplerResponse
rsp
)
throws
ServletException
,
IOException
{
final
Jenkins
jenkins
=
Jenkins
.
get
ActiveInstance
();
final
Jenkins
jenkins
=
Jenkins
.
get
();
jenkins
.
checkPermission
(
Jenkins
.
READ
);
// Strip trailing slash
...
...
core/src/main/java/hudson/cli/CLICommand.java
浏览文件 @
eedf2a4e
...
...
@@ -242,10 +242,10 @@ public abstract class CLICommand implements ExtensionPoint, Cloneable {
sc
.
setAuthentication
(
auth
=
getTransportAuthentication
());
if
(!(
this
instanceof
HelpCommand
||
this
instanceof
WhoAmICommand
))
Jenkins
.
get
ActiveInstance
().
checkPermission
(
Jenkins
.
READ
);
Jenkins
.
get
().
checkPermission
(
Jenkins
.
READ
);
p
.
parseArgument
(
args
.
toArray
(
new
String
[
0
]));
if
(!(
this
instanceof
HelpCommand
||
this
instanceof
WhoAmICommand
))
Jenkins
.
get
ActiveInstance
().
checkPermission
(
Jenkins
.
READ
);
Jenkins
.
get
().
checkPermission
(
Jenkins
.
READ
);
LOGGER
.
log
(
Level
.
FINE
,
"Invoking CLI command {0}, with {1} arguments, as user {2}."
,
new
Object
[]
{
getName
(),
args
.
size
(),
auth
.
getName
()});
int
res
=
run
();
...
...
@@ -502,7 +502,7 @@ public abstract class CLICommand implements ExtensionPoint, Cloneable {
*/
protected
void
registerOptionHandlers
()
{
try
{
for
(
Class
c
:
Index
.
list
(
OptionHandlerExtension
.
class
,
Jenkins
.
get
ActiveInstance
().
pluginManager
.
uberClassLoader
,
Class
.
class
))
{
for
(
Class
c
:
Index
.
list
(
OptionHandlerExtension
.
class
,
Jenkins
.
get
().
pluginManager
.
uberClassLoader
,
Class
.
class
))
{
Type
t
=
Types
.
getBaseClass
(
c
,
OptionHandler
.
class
);
CmdLineParser
.
registerHandler
(
Types
.
erasure
(
Types
.
getTypeArgument
(
t
,
0
)),
c
);
}
...
...
core/src/main/java/hudson/cli/CancelQuietDownCommand.java
浏览文件 @
eedf2a4e
...
...
@@ -47,7 +47,7 @@ public class CancelQuietDownCommand extends CLICommand {
@Override
protected
int
run
()
throws
Exception
{
Jenkins
.
get
ActiveInstance
().
doCancelQuietDown
();
Jenkins
.
get
().
doCancelQuietDown
();
return
0
;
}
}
core/src/main/java/hudson/cli/ClearQueueCommand.java
浏览文件 @
eedf2a4e
...
...
@@ -47,7 +47,7 @@ public class ClearQueueCommand extends CLICommand {
@Override
protected
int
run
()
throws
Exception
{
Jenkins
.
get
ActiveInstance
().
getQueue
().
clear
();
Jenkins
.
get
().
getQueue
().
clear
();
return
0
;
}
...
...
core/src/main/java/hudson/cli/CopyJobCommand.java
浏览文件 @
eedf2a4e
...
...
@@ -50,7 +50,7 @@ public class CopyJobCommand extends CLICommand {
public
String
dst
;
protected
int
run
()
throws
Exception
{
Jenkins
jenkins
=
Jenkins
.
get
ActiveInstance
();
Jenkins
jenkins
=
Jenkins
.
get
();
if
(
jenkins
.
getItemByFullName
(
dst
)!=
null
)
{
throw
new
IllegalStateException
(
"Job '"
+
dst
+
"' already exists"
);
...
...
core/src/main/java/hudson/cli/CreateJobCommand.java
浏览文件 @
eedf2a4e
...
...
@@ -45,7 +45,7 @@ public class CreateJobCommand extends CLICommand {
public
String
name
;
protected
int
run
()
throws
Exception
{
Jenkins
h
=
Jenkins
.
get
ActiveInstance
();
Jenkins
h
=
Jenkins
.
get
();
if
(
h
.
getItemByFullName
(
name
)!=
null
)
{
throw
new
IllegalStateException
(
"Job '"
+
name
+
"' already exists"
);
...
...
core/src/main/java/hudson/cli/CreateNodeCommand.java
浏览文件 @
eedf2a4e
...
...
@@ -52,7 +52,7 @@ public class CreateNodeCommand extends CLICommand {
@Override
protected
int
run
()
throws
Exception
{
final
Jenkins
jenkins
=
Jenkins
.
get
ActiveInstance
();
final
Jenkins
jenkins
=
Jenkins
.
get
();
jenkins
.
checkPermission
(
Computer
.
CREATE
);
final
Node
newNode
=
(
Node
)
Jenkins
.
XSTREAM2
.
fromXML
(
stdin
);
...
...
core/src/main/java/hudson/cli/CreateViewCommand.java
浏览文件 @
eedf2a4e
...
...
@@ -49,7 +49,7 @@ public class CreateViewCommand extends CLICommand {
@Override
protected
int
run
()
throws
Exception
{
final
Jenkins
jenkins
=
Jenkins
.
get
ActiveInstance
();
final
Jenkins
jenkins
=
Jenkins
.
get
();
jenkins
.
checkPermission
(
View
.
CREATE
);
View
newView
;
...
...
core/src/main/java/hudson/cli/DeleteJobCommand.java
浏览文件 @
eedf2a4e
...
...
@@ -54,7 +54,7 @@ public class DeleteJobCommand extends CLICommand {
protected
int
run
()
throws
Exception
{
boolean
errorOccurred
=
false
;
final
Jenkins
jenkins
=
Jenkins
.
get
ActiveInstance
();
final
Jenkins
jenkins
=
Jenkins
.
get
();
final
HashSet
<
String
>
hs
=
new
HashSet
<>(
jobs
);
...
...
core/src/main/java/hudson/cli/DeleteNodeCommand.java
浏览文件 @
eedf2a4e
...
...
@@ -54,7 +54,7 @@ public class DeleteNodeCommand extends CLICommand {
protected
int
run
()
throws
Exception
{
boolean
errorOccurred
=
false
;
final
Jenkins
jenkins
=
Jenkins
.
get
ActiveInstance
();
final
Jenkins
jenkins
=
Jenkins
.
get
();
final
HashSet
<
String
>
hs
=
new
HashSet
<>(
nodes
);
...
...
core/src/main/java/hudson/cli/DisconnectNodeCommand.java
浏览文件 @
eedf2a4e
...
...
@@ -59,7 +59,7 @@ public class DisconnectNodeCommand extends CLICommand {
@Override
protected
int
run
()
throws
Exception
{
boolean
errorOccurred
=
false
;
final
Jenkins
jenkins
=
Jenkins
.
get
ActiveInstance
();
final
Jenkins
jenkins
=
Jenkins
.
get
();
final
HashSet
<
String
>
hs
=
new
HashSet
<>(
nodes
);
...
...
core/src/main/java/hudson/cli/GroovyCommand.java
浏览文件 @
eedf2a4e
...
...
@@ -59,7 +59,7 @@ public class GroovyCommand extends CLICommand {
protected
int
run
()
throws
Exception
{
// this allows the caller to manipulate the JVM state, so require the execute script privilege.
Jenkins
.
get
ActiveInstance
().
checkPermission
(
Jenkins
.
RUN_SCRIPTS
);
Jenkins
.
get
().
checkPermission
(
Jenkins
.
RUN_SCRIPTS
);
Binding
binding
=
new
Binding
();
binding
.
setProperty
(
"out"
,
new
PrintWriter
(
stdout
,
true
));
...
...
@@ -67,7 +67,7 @@ public class GroovyCommand extends CLICommand {
binding
.
setProperty
(
"stdout"
,
stdout
);
binding
.
setProperty
(
"stderr"
,
stderr
);
GroovyShell
groovy
=
new
GroovyShell
(
Jenkins
.
get
ActiveInstance
().
getPluginManager
().
uberClassLoader
,
binding
);
GroovyShell
groovy
=
new
GroovyShell
(
Jenkins
.
get
().
getPluginManager
().
uberClassLoader
,
binding
);
groovy
.
run
(
loadScript
(),
"RemoteClass"
,
remaining
.
toArray
(
new
String
[
0
]));
return
0
;
}
...
...
core/src/main/java/hudson/cli/GroovyshCommand.java
浏览文件 @
eedf2a4e
...
...
@@ -60,7 +60,7 @@ public class GroovyshCommand extends CLICommand {
@Override
protected
int
run
()
{
// this allows the caller to manipulate the JVM state, so require the admin privilege.
Jenkins
.
get
ActiveInstance
().
checkPermission
(
Jenkins
.
RUN_SCRIPTS
);
Jenkins
.
get
().
checkPermission
(
Jenkins
.
RUN_SCRIPTS
);
// this being remote means no jline capability is available
System
.
setProperty
(
"jline.terminal"
,
UnsupportedTerminal
.
class
.
getName
());
...
...
@@ -85,12 +85,12 @@ public class GroovyshCommand extends CLICommand {
Binding
binding
=
new
Binding
();
// redirect "println" to the CLI
binding
.
setProperty
(
"out"
,
new
PrintWriter
(
stdout
,
true
));
binding
.
setProperty
(
"hudson"
,
Jenkins
.
get
ActiveInstance
());
// backward compatibility
binding
.
setProperty
(
"jenkins"
,
Jenkins
.
get
ActiveInstance
());
binding
.
setProperty
(
"hudson"
,
Jenkins
.
get
());
// backward compatibility
binding
.
setProperty
(
"jenkins"
,
Jenkins
.
get
());
IO
io
=
new
IO
(
new
BufferedInputStream
(
stdin
),
stdout
,
stderr
);
final
ClassLoader
cl
=
Jenkins
.
get
ActiveInstance
().
pluginManager
.
uberClassLoader
;
final
ClassLoader
cl
=
Jenkins
.
get
().
pluginManager
.
uberClassLoader
;
Closure
registrar
=
new
Closure
(
null
,
null
)
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
core/src/main/java/hudson/cli/HelpCommand.java
浏览文件 @
eedf2a4e
...
...
@@ -51,7 +51,7 @@ public class HelpCommand extends CLICommand {
@Override
protected
int
run
()
throws
Exception
{
if
(!
Jenkins
.
get
ActiveInstance
().
hasPermission
(
Jenkins
.
READ
))
{
if
(!
Jenkins
.
get
().
hasPermission
(
Jenkins
.
READ
))
{
throw
new
AccessDeniedException
(
"You must authenticate to access this Jenkins.\n"
+
CLI
.
usage
());
}
...
...
core/src/main/java/hudson/cli/ListJobsCommand.java
浏览文件 @
eedf2a4e
...
...
@@ -49,7 +49,7 @@ public class ListJobsCommand extends CLICommand {
public
String
name
;
protected
int
run
()
throws
Exception
{
Jenkins
h
=
Jenkins
.
get
ActiveInstance
();
Jenkins
h
=
Jenkins
.
get
();
final
Collection
<
TopLevelItem
>
jobs
;
// If name is given retrieve jobs for the given view.
...
...
core/src/main/java/hudson/cli/QuietDownCommand.java
浏览文件 @
eedf2a4e
...
...
@@ -54,7 +54,7 @@ public class QuietDownCommand extends CLICommand {
@Override
protected
int
run
()
throws
Exception
{
Jenkins
.
get
ActiveInstance
().
doQuietDown
(
block
,
timeout
);
Jenkins
.
get
().
doQuietDown
(
block
,
timeout
);
return
0
;
}
}
core/src/main/java/hudson/cli/ReloadJobCommand.java
浏览文件 @
eedf2a4e
...
...
@@ -60,7 +60,7 @@ public class ReloadJobCommand extends CLICommand {
protected
int
run
()
throws
Exception
{
boolean
errorOccurred
=
false
;
final
Jenkins
jenkins
=
Jenkins
.
get
ActiveInstance
();
final
Jenkins
jenkins
=
Jenkins
.
get
();
final
HashSet
<
String
>
hs
=
new
HashSet
<>(
jobs
);
...
...
core/src/main/java/hudson/cli/handlers/ViewOptionHandler.java
浏览文件 @
eedf2a4e
...
...
@@ -94,7 +94,7 @@ public class ViewOptionHandler extends OptionHandler<View> {
@CheckForNull
public
View
getView
(
final
String
name
)
{
ViewGroup
group
=
Jenkins
.
get
ActiveInstance
();
ViewGroup
group
=
Jenkins
.
get
();
View
view
=
null
;
final
StringTokenizer
tok
=
new
StringTokenizer
(
name
,
"/"
);
...
...
core/src/main/java/hudson/model/AsyncAperiodicWork.java
浏览文件 @
eedf2a4e
...
...
@@ -172,7 +172,7 @@ public abstract class AsyncAperiodicWork extends AperiodicWork {
}
else
{
lastRotateMillis
=
System
.
currentTimeMillis
();
// migrate old log files the first time we start-up
File
oldFile
=
new
File
(
Jenkins
.
get
ActiveInstance
().
getRootDir
(),
f
.
getName
());
File
oldFile
=
new
File
(
Jenkins
.
get
().
getRootDir
(),
f
.
getName
());
if
(
oldFile
.
isFile
())
{
File
newFile
=
new
File
(
f
.
getParentFile
(),
f
.
getName
()
+
".1"
);
if
(!
newFile
.
isFile
())
{
...
...
core/src/main/java/hudson/model/AsyncPeriodicWork.java
浏览文件 @
eedf2a4e
...
...
@@ -157,7 +157,7 @@ public abstract class AsyncPeriodicWork extends PeriodicWork {
}
else
{
lastRotateMillis
=
System
.
currentTimeMillis
();
// migrate old log files the first time we start-up
File
oldFile
=
new
File
(
Jenkins
.
get
ActiveInstance
().
getRootDir
(),
f
.
getName
());
File
oldFile
=
new
File
(
Jenkins
.
get
().
getRootDir
(),
f
.
getName
());
if
(
oldFile
.
isFile
())
{
File
newFile
=
new
File
(
f
.
getParentFile
(),
f
.
getName
()
+
".1"
);
if
(!
newFile
.
isFile
())
{
...
...
core/src/main/java/hudson/model/Computer.java
浏览文件 @
eedf2a4e
...
...
@@ -1475,7 +1475,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
if
((!
proposedName
.
equals
(
nodeName
))
&&
Jenkins
.
get
ActiveInstance
().
getNode
(
proposedName
)
!=
null
)
{
&&
Jenkins
.
get
().
getNode
(
proposedName
)
!=
null
)
{
throw
new
FormException
(
Messages
.
ComputerSet_SlaveAlreadyExists
(
proposedName
),
"name"
);
}
...
...
core/src/main/java/hudson/model/Descriptor.java
浏览文件 @
eedf2a4e
...
...
@@ -645,7 +645,7 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable,
if
(
isApplicable
(
actualType
,
json
))
{
LOGGER
.
log
(
Level
.
FINE
,
"switching to newInstance {0} {1}"
,
new
Object
[]
{
actualType
.
getName
(),
json
});
try
{
final
Descriptor
descriptor
=
Jenkins
.
get
ActiveInstance
().
getDescriptor
(
actualType
);
final
Descriptor
descriptor
=
Jenkins
.
get
().
getDescriptor
(
actualType
);
if
(
descriptor
!=
null
)
{
return
descriptor
.
newInstance
(
Stapler
.
getCurrentRequest
(),
json
);
}
else
{
...
...
@@ -671,7 +671,7 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable,
if
(
isApplicable
(
targetTypeErasure
,
json
))
{
LOGGER
.
log
(
Level
.
FINE
,
"switching to newInstance {0} {1}"
,
new
Object
[]
{
targetTypeErasure
.
getName
(),
json
});
try
{
return
Jenkins
.
get
ActiveInstance
().
getDescriptor
(
targetTypeErasure
).
newInstance
(
Stapler
.
getCurrentRequest
(),
json
);
return
Jenkins
.
get
().
getDescriptor
(
targetTypeErasure
).
newInstance
(
Stapler
.
getCurrentRequest
(),
json
);
}
catch
(
Exception
x
)
{
LOGGER
.
log
(
Level
.
WARNING
,
"falling back to default instantiation "
+
targetTypeErasure
.
getName
()
+
" "
+
json
,
x
);
}
...
...
core/src/main/java/hudson/model/DownloadService.java
浏览文件 @
eedf2a4e
...
...
@@ -257,7 +257,7 @@ public class DownloadService {
*/
public
List
<
String
>
getUrls
()
{
List
<
String
>
updateSites
=
new
ArrayList
<>();
for
(
UpdateSite
site
:
Jenkins
.
get
ActiveInstance
().
getUpdateCenter
().
getSiteList
())
{
for
(
UpdateSite
site
:
Jenkins
.
get
().
getUpdateCenter
().
getSiteList
())
{
String
siteUrl
=
site
.
getUrl
();
int
baseUrlEnd
=
siteUrl
.
indexOf
(
"update-center.json"
);
if
(
baseUrlEnd
!=
-
1
)
{
...
...
@@ -327,7 +327,7 @@ public class DownloadService {
public
FormValidation
updateNow
()
throws
IOException
{
List
<
JSONObject
>
jsonList
=
new
ArrayList
<>();
boolean
toolInstallerMetadataExists
=
false
;
for
(
UpdateSite
updatesite
:
Jenkins
.
get
ActiveInstance
().
getUpdateCenter
().
getSiteList
())
{
for
(
UpdateSite
updatesite
:
Jenkins
.
get
().
getUpdateCenter
().
getSiteList
())
{
String
site
=
updatesite
.
getMetadataUrlForDownloadable
(
url
);
if
(
site
==
null
)
{
return
FormValidation
.
warning
(
"The update site "
+
updatesite
.
getId
()
+
" does not look like an update center"
);
...
...
core/src/main/java/hudson/model/Job.java
浏览文件 @
eedf2a4e
...
...
@@ -548,7 +548,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
public
Map
<
JobPropertyDescriptor
,
JobProperty
<?
super
JobT
>>
getProperties
()
{
Map
result
=
Descriptor
.
toMap
((
Iterable
)
properties
);
if
(
logRotator
!=
null
)
{
result
.
put
(
Jenkins
.
get
ActiveInstance
().
getDescriptorByType
(
BuildDiscarderProperty
.
DescriptorImpl
.
class
),
new
BuildDiscarderProperty
(
logRotator
));
result
.
put
(
Jenkins
.
get
().
getDescriptorByType
(
BuildDiscarderProperty
.
DescriptorImpl
.
class
),
new
BuildDiscarderProperty
(
logRotator
));
}
return
result
;
}
...
...
core/src/main/java/hudson/model/OverallLoadStatistics.java
浏览文件 @
eedf2a4e
...
...
@@ -72,7 +72,7 @@ public class OverallLoadStatistics extends LoadStatistics {
@Override
protected
Iterable
<
Node
>
getNodes
()
{
return
Jenkins
.
get
ActiveInstance
().
getNodes
();
return
Jenkins
.
get
().
getNodes
();
}
@Override
...
...
core/src/main/java/jenkins/model/Jenkins.java
浏览文件 @
eedf2a4e
...
...
@@ -5140,7 +5140,7 @@ public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLeve
*/
@Restricted
(
NoExternalUse
.
class
)
public
@CheckForNull
static
VersionNumber
getStoredVersion
()
{
return
toVersion
(
Jenkins
.
get
ActiveInstance
().
version
);
return
toVersion
(
Jenkins
.
get
().
version
);
}
/**
...
...
core/src/main/java/jenkins/model/UnlabeledLoadStatistics.java
浏览文件 @
eedf2a4e
...
...
@@ -102,7 +102,7 @@ public class UnlabeledLoadStatistics extends LoadStatistics {
private
static
class
UnlabeledNodesIterator
extends
Iterators
.
FilterIterator
<
Node
>
{
protected
UnlabeledNodesIterator
()
{
super
(
Jenkins
.
get
ActiveInstance
().
getNodes
().
iterator
());
super
(
Jenkins
.
get
().
getNodes
().
iterator
());
}
@Override
...
...
core/src/main/java/jenkins/util/groovy/GroovyHookScript.java
浏览文件 @
eedf2a4e
...
...
@@ -46,7 +46,7 @@ public class GroovyHookScript {
@Deprecated
public
GroovyHookScript
(
String
hook
)
{
this
(
hook
,
Jenkins
.
get
ActiveInstance
());
this
(
hook
,
Jenkins
.
get
());
}
private
GroovyHookScript
(
String
hook
,
Jenkins
j
)
{
...
...
core/src/test/java/hudson/cli/ListJobsCommandTest.java
浏览文件 @
eedf2a4e
...
...
@@ -50,7 +50,6 @@ public class ListJobsCommandTest {
jenkins
=
mock
(
Jenkins
.
class
);
mockStatic
(
Jenkins
.
class
);
when
(
Jenkins
.
get
()).
thenReturn
(
jenkins
);
when
(
Jenkins
.
getActiveInstance
()).
thenReturn
(
jenkins
);
command
=
mock
(
ListJobsCommand
.
class
,
Mockito
.
CALLS_REAL_METHODS
);
command
.
stdout
=
new
PrintStream
(
stdout
);
command
.
stderr
=
new
PrintStream
(
stderr
);
...
...
core/src/test/java/hudson/cli/handlers/ViewOptionHandlerTest.java
浏览文件 @
eedf2a4e
...
...
@@ -84,7 +84,6 @@ public class ViewOptionHandlerTest {
PowerMockito
.
mockStatic
(
Jenkins
.
class
);
PowerMockito
.
when
(
Jenkins
.
get
()).
thenReturn
(
jenkins
);
PowerMockito
.
when
(
Jenkins
.
getActiveInstance
()).
thenReturn
(
jenkins
);
when
(
jenkins
.
getView
(
"outer"
)).
thenReturn
(
outer
);
when
(
jenkins
.
getDisplayName
()).
thenReturn
(
"Jenkins"
);
when
(
jenkins
.
getACL
()).
thenReturn
(
new
ACL
()
{
...
...
test/src/test/java/hudson/cli/CancelQuietDownCommandTest.java
浏览文件 @
eedf2a4e
...
...
@@ -79,7 +79,7 @@ public class CancelQuietDownCommandTest {
@Test
public
void
cancelQuietDownShouldSuccessOnQuietDownedJenkins
()
throws
Exception
{
j
.
jenkins
.
getActiveInstance
().
doQuietDown
();
j
.
jenkins
.
doQuietDown
();
QuietDownCommandTest
.
assertJenkinsInQuietMode
(
j
);
final
CLICommandInvoker
.
Result
result
=
command
.
authorizedTo
(
Jenkins
.
READ
,
Jenkins
.
ADMINISTER
)
...
...
@@ -132,7 +132,7 @@ public class CancelQuietDownCommandTest {
Future
<
FreeStyleBuild
>
build
=
OnlineNodeCommandTest
.
startBlockingAndFinishingBuild
(
project
,
finish
);
assertThat
(((
FreeStyleProject
)
j
.
jenkins
.
getItem
(
"aProject"
)).
getBuilds
(),
hasSize
(
1
));
assertThat
(
project
.
isBuilding
(),
equalTo
(
true
));
j
.
jenkins
.
getActiveInstance
().
doQuietDown
();
j
.
jenkins
.
doQuietDown
();
QuietDownCommandTest
.
assertJenkinsInQuietMode
(
j
);
final
CLICommandInvoker
.
Result
result
=
command
...
...
@@ -156,4 +156,4 @@ public class CancelQuietDownCommandTest {
j
.
assertBuildStatusSuccess
(
build
);
QuietDownCommandTest
.
assertJenkinsNotInQuietMode
(
j
);
}
}
\ No newline at end of file
}
test/src/test/java/hudson/cli/ConnectNodeCommandTest.java
浏览文件 @
eedf2a4e
...
...
@@ -173,7 +173,7 @@ public class ConnectNodeCommandTest {
}
@Test
public
void
connectNodeShouldSucceedOnMaster
()
throws
Exception
{
final
Computer
masterComputer
=
j
.
jenkins
.
get
ActiveInstance
().
get
Computer
(
""
);
final
Computer
masterComputer
=
j
.
jenkins
.
getComputer
(
""
);
CLICommandInvoker
.
Result
result
=
command
.
authorizedTo
(
Computer
.
CONNECT
,
Jenkins
.
READ
)
...
...
test/src/test/java/hudson/cli/DisconnectNodeCommandTest.java
浏览文件 @
eedf2a4e
...
...
@@ -265,7 +265,7 @@ public class DisconnectNodeCommandTest {
}
public
void
disconnectNodeShouldSucceedOnMaster
()
throws
Exception
{
final
Computer
masterComputer
=
j
.
jenkins
.
get
ActiveInstance
().
get
Computer
(
""
);
final
Computer
masterComputer
=
j
.
jenkins
.
getComputer
(
""
);
assertThat
(
masterComputer
.
isOnline
(),
equalTo
(
true
));
assertThat
(
masterComputer
.
getOfflineCause
(),
equalTo
(
null
));
...
...
test/src/test/java/hudson/cli/OfflineNodeCommandTest.java
浏览文件 @
eedf2a4e
...
...
@@ -453,7 +453,7 @@ public class OfflineNodeCommandTest {
@Test
public
void
offlineNodeShouldSucceedOnMaster
()
throws
Exception
{
final
Computer
masterComputer
=
Jenkins
.
get
ActiveInstance
().
getComputer
(
""
);
final
Computer
masterComputer
=
Jenkins
.
get
().
getComputer
(
""
);
final
CLICommandInvoker
.
Result
result
=
command
.
authorizedTo
(
Computer
.
DISCONNECT
,
Jenkins
.
READ
)
...
...
@@ -467,7 +467,7 @@ public class OfflineNodeCommandTest {
@Test
public
void
offlineNodeShouldSucceedOnMasterWithCause
()
throws
Exception
{
final
Computer
masterComputer
=
Jenkins
.
get
ActiveInstance
().
getComputer
(
""
);
final
Computer
masterComputer
=
Jenkins
.
get
().
getComputer
(
""
);
final
CLICommandInvoker
.
Result
result
=
command
.
authorizedTo
(
Computer
.
DISCONNECT
,
Jenkins
.
READ
)
...
...
test/src/test/java/hudson/cli/OnlineNodeCommandTest.java
浏览文件 @
eedf2a4e
...
...
@@ -286,7 +286,7 @@ public class OnlineNodeCommandTest {
}
@Test
public
void
onlineNodeShouldSucceedOnMaster
()
throws
Exception
{
final
Computer
masterComputer
=
j
.
jenkins
.
get
ActiveInstance
().
get
Computer
(
""
);
final
Computer
masterComputer
=
j
.
jenkins
.
getComputer
(
""
);
CLICommandInvoker
.
Result
result
=
command
.
authorizedTo
(
Computer
.
CONNECT
,
Jenkins
.
READ
)
...
...
test/src/test/java/hudson/cli/QuietDownCommandTest.java
浏览文件 @
eedf2a4e
...
...
@@ -128,7 +128,7 @@ public class QuietDownCommandTest {
@Test
public
void
quietDownShouldSuccessOnAlreadyQuietDownedJenkins
()
throws
Exception
{
j
.
jenkins
.
getActiveInstance
().
doQuietDown
();
j
.
jenkins
.
doQuietDown
();
assertJenkinsInQuietMode
();
final
CLICommandInvoker
.
Result
result
=
command
.
authorizedTo
(
Jenkins
.
READ
,
Jenkins
.
ADMINISTER
)
...
...
@@ -139,7 +139,7 @@ public class QuietDownCommandTest {
@Test
public
void
quietDownShouldSuccessWithBlockOnAlreadyQuietDownedJenkins
()
throws
Exception
{
j
.
jenkins
.
getActiveInstance
().
doQuietDown
(
true
,
0
);
j
.
jenkins
.
doQuietDown
(
true
,
0
);
assertJenkinsInQuietMode
();
final
CLICommandInvoker
.
Result
result
=
command
.
authorizedTo
(
Jenkins
.
READ
,
Jenkins
.
ADMINISTER
)
...
...
@@ -150,7 +150,7 @@ public class QuietDownCommandTest {
@Test
public
void
quietDownShouldSuccessWithBlockAndTimeoutOnAlreadyQuietDownedJenkins
()
throws
Exception
{
j
.
jenkins
.
getActiveInstance
().
doQuietDown
(
true
,
0
);
j
.
jenkins
.
doQuietDown
(
true
,
0
);
assertJenkinsInQuietMode
();
final
long
time_before
=
System
.
currentTimeMillis
();
final
CLICommandInvoker
.
Result
result
=
command
...
...
@@ -483,7 +483,7 @@ public class QuietDownCommandTest {
public
static
final
void
assertJenkinsInQuietMode
(
final
JenkinsRule
j
)
{
await
().
pollInterval
(
250
,
TimeUnit
.
MILLISECONDS
)
.
atMost
(
10
,
TimeUnit
.
SECONDS
)
.
until
(()
->
j
.
jenkins
.
get
ActiveInstance
().
get
Queue
().
isBlockedByShutdown
(
task
));
.
until
(()
->
j
.
jenkins
.
getQueue
().
isBlockedByShutdown
(
task
));
}
/**
...
...
@@ -493,6 +493,6 @@ public class QuietDownCommandTest {
public
static
final
void
assertJenkinsNotInQuietMode
(
final
JenkinsRule
j
)
{
await
().
pollInterval
(
250
,
TimeUnit
.
MILLISECONDS
)
.
atMost
(
10
,
TimeUnit
.
SECONDS
)
.
until
(()
->
!
j
.
jenkins
.
get
ActiveInstance
().
get
Queue
().
isBlockedByShutdown
(
task
));
.
until
(()
->
!
j
.
jenkins
.
getQueue
().
isBlockedByShutdown
(
task
));
}
}
test/src/test/java/hudson/model/UsageStatisticsTest.java
浏览文件 @
eedf2a4e
...
...
@@ -90,7 +90,7 @@ public class UsageStatisticsTest {
InputStreamReader
r
=
new
InputStreamReader
(
new
GZIPInputStream
(
new
CombinedCipherInputStream
(
new
ByteArrayInputStream
(
cipherText
),
priv
,
"AES"
)),
"UTF-8"
);
JSONObject
o
=
JSONObject
.
fromObject
(
IOUtils
.
toString
(
r
));
Jenkins
jenkins
=
Jenkins
.
getActiveInstance
()
;
Jenkins
jenkins
=
j
.
jenkins
;
// A bit intrusive with UsageStatistics internals, but done to prevent undetected changes
// that would cause issues with parsing/analyzing uploaded usage statistics
assertEquals
(
1
,
o
.
getInt
(
"stat"
));
...
...
@@ -136,13 +136,12 @@ public class UsageStatisticsTest {
* @throws InterruptedException
*/
private
void
warmUpNodeMonitorCache
()
throws
InterruptedException
{
Jenkins
j
=
Jenkins
.
getActiveInstance
();
ArchitectureMonitor
.
DescriptorImpl
descriptor
=
j
.
getDescriptorByType
(
ArchitectureMonitor
.
DescriptorImpl
.
class
);
ArchitectureMonitor
.
DescriptorImpl
descriptor
=
j
.
jenkins
.
getDescriptorByType
(
ArchitectureMonitor
.
DescriptorImpl
.
class
);
String
value
=
null
;
int
count
=
1
;
while
(
value
==
null
&&
count
++
<=
5
)
// If for some reason the cache doesn't get populated, don't loop forever
{
final
Computer
master
=
j
.
getComputers
()[
0
];
final
Computer
master
=
j
.
jenkins
.
getComputers
()[
0
];
value
=
descriptor
.
get
(
master
);
Thread
.
sleep
(
200
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录