Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
86da98c3
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,发现更多精彩内容 >>
未验证
提交
86da98c3
编写于
1月 27, 2019
作者:
B
Baptiste Mathus
提交者:
GitHub
1月 27, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3208 from oleg-nenashev/cleanup/cli
Bulk cleanup of code in hudson.cli.
上级
cb84ecf4
1af82a42
变更
26
隐藏空白更改
内联
并排
Showing
26 changed file
with
43 addition
and
53 deletion
+43
-53
core/src/main/java/hudson/cli/BuildCommand.java
core/src/main/java/hudson/cli/BuildCommand.java
+2
-2
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/ClearQueueCommand.java
core/src/main/java/hudson/cli/ClearQueueCommand.java
+0
-1
core/src/main/java/hudson/cli/CliManagerImpl.java
core/src/main/java/hudson/cli/CliManagerImpl.java
+2
-2
core/src/main/java/hudson/cli/ConnectNodeCommand.java
core/src/main/java/hudson/cli/ConnectNodeCommand.java
+1
-1
core/src/main/java/hudson/cli/CreateNodeCommand.java
core/src/main/java/hudson/cli/CreateNodeCommand.java
+0
-1
core/src/main/java/hudson/cli/DeleteBuildsCommand.java
core/src/main/java/hudson/cli/DeleteBuildsCommand.java
+1
-1
core/src/main/java/hudson/cli/DeleteJobCommand.java
core/src/main/java/hudson/cli/DeleteJobCommand.java
+1
-2
core/src/main/java/hudson/cli/DeleteNodeCommand.java
core/src/main/java/hudson/cli/DeleteNodeCommand.java
+1
-2
core/src/main/java/hudson/cli/DeleteViewCommand.java
core/src/main/java/hudson/cli/DeleteViewCommand.java
+1
-2
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
+1
-1
core/src/main/java/hudson/cli/GroovyshCommand.java
core/src/main/java/hudson/cli/GroovyshCommand.java
+1
-1
core/src/main/java/hudson/cli/HelpCommand.java
core/src/main/java/hudson/cli/HelpCommand.java
+1
-1
core/src/main/java/hudson/cli/InstallPluginCommand.java
core/src/main/java/hudson/cli/InstallPluginCommand.java
+1
-2
core/src/main/java/hudson/cli/InstallToolCommand.java
core/src/main/java/hudson/cli/InstallToolCommand.java
+2
-2
core/src/main/java/hudson/cli/ListJobsCommand.java
core/src/main/java/hudson/cli/ListJobsCommand.java
+0
-1
core/src/main/java/hudson/cli/OfflineNodeCommand.java
core/src/main/java/hudson/cli/OfflineNodeCommand.java
+2
-3
core/src/main/java/hudson/cli/OnlineNodeCommand.java
core/src/main/java/hudson/cli/OnlineNodeCommand.java
+1
-1
core/src/main/java/hudson/cli/ReloadConfigurationCommand.java
.../src/main/java/hudson/cli/ReloadConfigurationCommand.java
+1
-1
core/src/main/java/hudson/cli/ReloadJobCommand.java
core/src/main/java/hudson/cli/ReloadJobCommand.java
+1
-3
core/src/main/java/hudson/cli/RemoveJobFromViewCommand.java
core/src/main/java/hudson/cli/RemoveJobFromViewCommand.java
+0
-1
core/src/main/java/hudson/cli/declarative/CLIRegisterer.java
core/src/main/java/hudson/cli/declarative/CLIRegisterer.java
+16
-15
core/src/main/java/hudson/cli/handlers/GenericItemOptionHandler.java
...in/java/hudson/cli/handlers/GenericItemOptionHandler.java
+1
-1
core/src/main/java/hudson/cli/handlers/NodeOptionHandler.java
.../src/main/java/hudson/cli/handlers/NodeOptionHandler.java
+1
-1
未找到文件。
core/src/main/java/hudson/cli/BuildCommand.java
浏览文件 @
86da98c3
...
...
@@ -89,7 +89,7 @@ public class BuildCommand extends CLICommand {
public
boolean
checkSCM
=
false
;
@Option
(
name
=
"-p"
,
usage
=
"Specify the build parameters in the key=value format."
)
public
Map
<
String
,
String
>
parameters
=
new
HashMap
<
String
,
String
>();
public
Map
<
String
,
String
>
parameters
=
new
HashMap
<>();
@Option
(
name
=
"-v"
,
usage
=
"Prints out the console output of the build. Use with -s"
)
public
boolean
consoleOutput
=
false
;
...
...
@@ -109,7 +109,7 @@ public class BuildCommand extends CLICommand {
throw
new
IllegalStateException
(
job
.
getFullDisplayName
()+
" is not parameterized but the -p option was specified."
);
//TODO: switch to type annotations after the migration to Java 1.8
List
<
ParameterValue
>
values
=
new
ArrayList
<
ParameterValue
>();
List
<
ParameterValue
>
values
=
new
ArrayList
<>();
for
(
Entry
<
String
,
String
>
e
:
parameters
.
entrySet
())
{
String
name
=
e
.
getKey
();
...
...
core/src/main/java/hudson/cli/CLIAction.java
浏览文件 @
86da98c3
...
...
@@ -250,7 +250,7 @@ public class CLIAction implements UnprotectedRootAction, StaplerProxy {
// do not require any permission to establish a CLI connection
// the actual authentication for the connecting Channel is done by CLICommand
return
new
FullDuplexHttpChannel
(
uuid
,
!
Jenkins
.
get
Instance
().
hasPermission
(
Jenkins
.
ADMINISTER
))
{
return
new
FullDuplexHttpChannel
(
uuid
,
!
Jenkins
.
get
().
hasPermission
(
Jenkins
.
ADMINISTER
))
{
@SuppressWarnings
(
"deprecation"
)
@Override
protected
void
main
(
Channel
channel
)
throws
IOException
,
InterruptedException
{
...
...
core/src/main/java/hudson/cli/CLICommand.java
浏览文件 @
86da98c3
...
...
@@ -636,9 +636,9 @@ public abstract class CLICommand implements ExtensionPoint, Cloneable {
* Key for {@link Channel#getProperty(Object)} that links to the {@link Authentication} object
* which captures the identity of the client given by the transport layer.
*/
public
static
final
ChannelProperty
<
Authentication
>
TRANSPORT_AUTHENTICATION
=
new
ChannelProperty
<
Authentication
>(
Authentication
.
class
,
"transportAuthentication"
);
public
static
final
ChannelProperty
<
Authentication
>
TRANSPORT_AUTHENTICATION
=
new
ChannelProperty
<
>(
Authentication
.
class
,
"transportAuthentication"
);
private
static
final
ThreadLocal
<
CLICommand
>
CURRENT_COMMAND
=
new
ThreadLocal
<
CLICommand
>();
private
static
final
ThreadLocal
<
CLICommand
>
CURRENT_COMMAND
=
new
ThreadLocal
<>();
/*package*/
static
CLICommand
setCurrent
(
CLICommand
cmd
)
{
CLICommand
old
=
getCurrent
();
...
...
@@ -656,7 +656,7 @@ public abstract class CLICommand implements ExtensionPoint, Cloneable {
static
{
// register option handlers that are defined
ClassLoaders
cls
=
new
ClassLoaders
();
Jenkins
j
=
Jenkins
.
get
ActiveInstance
();
Jenkins
j
=
Jenkins
.
get
InstanceOrNull
();
if
(
j
!=
null
)
{
// only when running on the master
cls
.
put
(
j
.
getPluginManager
().
uberClassLoader
);
...
...
core/src/main/java/hudson/cli/ClearQueueCommand.java
浏览文件 @
86da98c3
...
...
@@ -26,7 +26,6 @@ package hudson.cli;
import
hudson.Extension
;
import
jenkins.model.Jenkins
;
import
org.acegisecurity.AccessDeniedException
;
import
java.util.logging.Logger
;
...
...
core/src/main/java/hudson/cli/CliManagerImpl.java
浏览文件 @
86da98c3
...
...
@@ -90,7 +90,7 @@ public class CliManagerImpl implements CliEntryPoint, Serializable {
cmd
.
channel
=
Channel
.
current
();
final
CLICommand
old
=
CLICommand
.
setCurrent
(
cmd
);
try
{
transportAuth
=
Channel
.
current
().
getProperty
(
CLICommand
.
TRANSPORT_AUTHENTICATION
);
transportAuth
=
Channel
.
current
OrFail
().
getProperty
(
CLICommand
.
TRANSPORT_AUTHENTICATION
);
cmd
.
setTransportAuth
(
transportAuth
);
return
cmd
.
main
(
args
.
subList
(
1
,
args
.
size
()),
locale
,
stdin
,
out
,
err
);
}
finally
{
...
...
@@ -99,7 +99,7 @@ public class CliManagerImpl implements CliEntryPoint, Serializable {
}
err
.
println
(
"No such command: "
+
subCmd
);
new
HelpCommand
().
main
(
Collections
.
<
String
>
emptyList
(),
locale
,
stdin
,
out
,
err
);
new
HelpCommand
().
main
(
Collections
.
emptyList
(),
locale
,
stdin
,
out
,
err
);
return
-
1
;
}
...
...
core/src/main/java/hudson/cli/ConnectNodeCommand.java
浏览文件 @
86da98c3
...
...
@@ -62,7 +62,7 @@ public class ConnectNodeCommand extends CLICommand {
boolean
errorOccurred
=
false
;
final
Jenkins
jenkins
=
Jenkins
.
getActiveInstance
();
final
HashSet
<
String
>
hs
=
new
HashSet
<
String
>();
final
HashSet
<
String
>
hs
=
new
HashSet
<>();
hs
.
addAll
(
nodes
);
List
<
String
>
names
=
null
;
...
...
core/src/main/java/hudson/cli/CreateNodeCommand.java
浏览文件 @
86da98c3
...
...
@@ -32,7 +32,6 @@ import hudson.model.User;
import
jenkins.model.Jenkins
;
import
org.kohsuke.args4j.Argument
;
import
org.kohsuke.args4j.CmdLineException
;
/**
* @author ogondza
...
...
core/src/main/java/hudson/cli/DeleteBuildsCommand.java
浏览文件 @
86da98c3
...
...
@@ -57,7 +57,7 @@ public class DeleteBuildsCommand extends RunRangeCommand {
protected
int
act
(
List
<
Run
<?,
?>>
builds
)
throws
IOException
{
job
.
checkPermission
(
Run
.
DELETE
);
final
HashSet
<
Integer
>
hsBuilds
=
new
HashSet
<
Integer
>();
final
HashSet
<
Integer
>
hsBuilds
=
new
HashSet
<>();
for
(
Run
<?,
?>
build
:
builds
)
{
if
(!
hsBuilds
.
contains
(
build
.
number
))
{
...
...
core/src/main/java/hudson/cli/DeleteJobCommand.java
浏览文件 @
86da98c3
...
...
@@ -31,7 +31,6 @@ import org.kohsuke.args4j.Argument;
import
java.util.List
;
import
java.util.HashSet
;
import
java.util.logging.Logger
;
/**
* CLI command, which deletes a job or multiple jobs.
...
...
@@ -56,7 +55,7 @@ public class DeleteJobCommand extends CLICommand {
boolean
errorOccurred
=
false
;
final
Jenkins
jenkins
=
Jenkins
.
getActiveInstance
();
final
HashSet
<
String
>
hs
=
new
HashSet
<
String
>();
final
HashSet
<
String
>
hs
=
new
HashSet
<>();
hs
.
addAll
(
jobs
);
for
(
String
job_s:
hs
)
{
...
...
core/src/main/java/hudson/cli/DeleteNodeCommand.java
浏览文件 @
86da98c3
...
...
@@ -31,7 +31,6 @@ import org.kohsuke.args4j.Argument;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.logging.Logger
;
/**
* CLI command, which deletes Jenkins nodes.
...
...
@@ -56,7 +55,7 @@ public class DeleteNodeCommand extends CLICommand {
boolean
errorOccurred
=
false
;
final
Jenkins
jenkins
=
Jenkins
.
getActiveInstance
();
final
HashSet
<
String
>
hs
=
new
HashSet
<
String
>();
final
HashSet
<
String
>
hs
=
new
HashSet
<>();
hs
.
addAll
(
nodes
);
for
(
String
node_s
:
hs
)
{
...
...
core/src/main/java/hudson/cli/DeleteViewCommand.java
浏览文件 @
86da98c3
...
...
@@ -33,7 +33,6 @@ import org.kohsuke.args4j.Argument;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.logging.Logger
;
/**
* @author ogondza, pjanouse
...
...
@@ -57,7 +56,7 @@ public class DeleteViewCommand extends CLICommand {
boolean
errorOccurred
=
false
;
// Remove duplicates
final
HashSet
<
String
>
hs
=
new
HashSet
<
String
>();
final
HashSet
<
String
>
hs
=
new
HashSet
<>();
hs
.
addAll
(
views
);
ViewOptionHandler
voh
=
new
ViewOptionHandler
(
null
,
null
,
null
);
...
...
core/src/main/java/hudson/cli/DisconnectNodeCommand.java
浏览文件 @
86da98c3
...
...
@@ -61,7 +61,7 @@ public class DisconnectNodeCommand extends CLICommand {
boolean
errorOccurred
=
false
;
final
Jenkins
jenkins
=
Jenkins
.
getActiveInstance
();
final
HashSet
<
String
>
hs
=
new
HashSet
<
String
>();
final
HashSet
<
String
>
hs
=
new
HashSet
<>();
hs
.
addAll
(
nodes
);
List
<
String
>
names
=
null
;
...
...
core/src/main/java/hudson/cli/GroovyCommand.java
浏览文件 @
86da98c3
...
...
@@ -59,7 +59,7 @@ public class GroovyCommand extends CLICommand {
* Remaining arguments.
*/
@Argument
(
metaVar
=
"ARGUMENTS"
,
index
=
1
,
usage
=
"Command line arguments to pass into script."
)
public
List
<
String
>
remaining
=
new
ArrayList
<
String
>();
public
List
<
String
>
remaining
=
new
ArrayList
<>();
protected
int
run
()
throws
Exception
{
// this allows the caller to manipulate the JVM state, so require the execute script privilege.
...
...
core/src/main/java/hudson/cli/GroovyshCommand.java
浏览文件 @
86da98c3
...
...
@@ -56,7 +56,7 @@ public class GroovyshCommand extends CLICommand {
return
Messages
.
GroovyshCommand_ShortDescription
();
}
@Argument
(
metaVar
=
"ARGS"
)
public
List
<
String
>
args
=
new
ArrayList
<
String
>();
@Argument
(
metaVar
=
"ARGS"
)
public
List
<
String
>
args
=
new
ArrayList
<>();
@Override
protected
int
run
()
{
...
...
core/src/main/java/hudson/cli/HelpCommand.java
浏览文件 @
86da98c3
...
...
@@ -65,7 +65,7 @@ public class HelpCommand extends CLICommand {
}
private
int
showAllCommands
()
{
Map
<
String
,
CLICommand
>
commands
=
new
TreeMap
<
String
,
CLICommand
>();
Map
<
String
,
CLICommand
>
commands
=
new
TreeMap
<>();
for
(
CLICommand
c
:
CLICommand
.
all
())
commands
.
put
(
c
.
getName
(),
c
);
...
...
core/src/main/java/hudson/cli/InstallPluginCommand.java
浏览文件 @
86da98c3
...
...
@@ -36,7 +36,6 @@ import org.kohsuke.args4j.Argument;
import
org.kohsuke.args4j.Option
;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.URL
;
import
java.net.MalformedURLException
;
import
java.util.HashSet
;
...
...
@@ -166,7 +165,7 @@ public class InstallPluginCommand extends CLICommand {
if
(
h
.
getUpdateCenter
().
getSites
().
isEmpty
())
{
stdout
.
println
(
Messages
.
InstallPluginCommand_NoUpdateCenterDefined
());
}
else
{
Set
<
String
>
candidates
=
new
HashSet
<
String
>();
Set
<
String
>
candidates
=
new
HashSet
<>();
for
(
UpdateSite
s
:
h
.
getUpdateCenter
().
getSites
())
{
Data
dt
=
s
.
getData
();
if
(
dt
==
null
)
...
...
core/src/main/java/hudson/cli/InstallToolCommand.java
浏览文件 @
86da98c3
...
...
@@ -78,11 +78,11 @@ public class InstallToolCommand extends CLICommand {
throw
new
IllegalStateException
(
"No such job found: "
+
id
.
job
);
p
.
checkPermission
(
Item
.
CONFIGURE
);
List
<
String
>
toolTypes
=
new
ArrayList
<
String
>();
List
<
String
>
toolTypes
=
new
ArrayList
<>();
for
(
ToolDescriptor
<?>
d
:
ToolInstallation
.
all
())
{
toolTypes
.
add
(
d
.
getDisplayName
());
if
(
d
.
getDisplayName
().
equals
(
toolType
))
{
List
<
String
>
toolNames
=
new
ArrayList
<
String
>();
List
<
String
>
toolNames
=
new
ArrayList
<>();
for
(
ToolInstallation
t
:
d
.
getInstallations
())
{
toolNames
.
add
(
t
.
getName
());
if
(
t
.
getName
().
equals
(
toolName
))
...
...
core/src/main/java/hudson/cli/ListJobsCommand.java
浏览文件 @
86da98c3
...
...
@@ -26,7 +26,6 @@ package hudson.cli;
import
java.util.Collection
;
import
hudson.model.Item
;
import
hudson.model.Items
;
import
hudson.model.TopLevelItem
;
import
hudson.model.View
;
import
hudson.Extension
;
...
...
core/src/main/java/hudson/cli/OfflineNodeCommand.java
浏览文件 @
86da98c3
...
...
@@ -34,7 +34,6 @@ import jenkins.model.Jenkins;
import
org.kohsuke.args4j.Argument
;
import
org.kohsuke.args4j.Option
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
...
...
@@ -60,8 +59,8 @@ public class OfflineNodeCommand extends CLICommand {
@Override
protected
int
run
()
throws
Exception
{
boolean
errorOccurred
=
false
;
final
Jenkins
jenkins
=
Jenkins
.
get
Instance
();
final
HashSet
<
String
>
hs
=
new
HashSet
<
String
>(
nodes
);
final
Jenkins
jenkins
=
Jenkins
.
get
();
final
HashSet
<
String
>
hs
=
new
HashSet
<>(
nodes
);
List
<
String
>
names
=
null
;
for
(
String
node_s
:
hs
)
{
...
...
core/src/main/java/hudson/cli/OnlineNodeCommand.java
浏览文件 @
86da98c3
...
...
@@ -56,7 +56,7 @@ public class OnlineNodeCommand extends CLICommand {
protected
int
run
()
throws
Exception
{
boolean
errorOccurred
=
false
;
final
Jenkins
jenkins
=
Jenkins
.
getActiveInstance
();
final
HashSet
<
String
>
hs
=
new
HashSet
<
String
>(
nodes
);
final
HashSet
<
String
>
hs
=
new
HashSet
<>(
nodes
);
List
<
String
>
names
=
null
;
for
(
String
node_s
:
hs
)
{
...
...
core/src/main/java/hudson/cli/ReloadConfigurationCommand.java
浏览文件 @
86da98c3
...
...
@@ -46,7 +46,7 @@ public class ReloadConfigurationCommand extends CLICommand {
@Override
protected
int
run
()
throws
Exception
{
Jenkins
j
=
Jenkins
.
get
Instance
();
Jenkins
j
=
Jenkins
.
get
();
// Or perhaps simpler to inline the thread body of doReload?
j
.
doReload
();
Object
app
;
...
...
core/src/main/java/hudson/cli/ReloadJobCommand.java
浏览文件 @
86da98c3
...
...
@@ -26,11 +26,9 @@ package hudson.cli;
import
hudson.AbortException
;
import
hudson.Extension
;
import
hudson.model.AbstractItem
;
import
hudson.model.AbstractProject
;
import
hudson.model.Item
;
import
hudson.model.Items
;
import
hudson.model.TopLevelItem
;
import
jenkins.model.Jenkins
;
import
org.kohsuke.args4j.Argument
;
...
...
@@ -64,7 +62,7 @@ public class ReloadJobCommand extends CLICommand {
boolean
errorOccurred
=
false
;
final
Jenkins
jenkins
=
Jenkins
.
getActiveInstance
();
final
HashSet
<
String
>
hs
=
new
HashSet
<
String
>();
final
HashSet
<
String
>
hs
=
new
HashSet
<>();
hs
.
addAll
(
jobs
);
for
(
String
job_s:
hs
)
{
...
...
core/src/main/java/hudson/cli/RemoveJobFromViewCommand.java
浏览文件 @
86da98c3
...
...
@@ -31,7 +31,6 @@ import hudson.model.DirectlyModifiableView;
import
hudson.model.View
;
import
org.kohsuke.args4j.Argument
;
import
org.kohsuke.args4j.CmdLineException
;
/**
* @author ogondza
...
...
core/src/main/java/hudson/cli/declarative/CLIRegisterer.java
浏览文件 @
86da98c3
...
...
@@ -47,6 +47,7 @@ import org.kohsuke.args4j.ClassParser;
import
org.kohsuke.args4j.CmdLineParser
;
import
org.kohsuke.args4j.CmdLineException
;
import
javax.annotation.Nonnull
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.PrintStream
;
...
...
@@ -90,7 +91,7 @@ public class CLIRegisterer extends ExtensionFinder {
* Finds a resolved method annotated with {@link CLIResolver}.
*/
private
Method
findResolver
(
Class
type
)
throws
IOException
{
List
<
Method
>
resolvers
=
Util
.
filter
(
Index
.
list
(
CLIResolver
.
class
,
Jenkins
.
get
Instance
().
getPluginManager
().
uberClassLoader
),
Method
.
class
);
List
<
Method
>
resolvers
=
Util
.
filter
(
Index
.
list
(
CLIResolver
.
class
,
Jenkins
.
get
().
getPluginManager
().
uberClassLoader
),
Method
.
class
);
for
(
;
type
!=
null
;
type
=
type
.
getSuperclass
())
for
(
Method
m
:
resolvers
)
if
(
m
.
getReturnType
()==
type
)
...
...
@@ -98,12 +99,12 @@ public class CLIRegisterer extends ExtensionFinder {
return
null
;
}
private
List
<
ExtensionComponent
<
CLICommand
>>
discover
(
final
Jenkins
hudson
)
{
private
List
<
ExtensionComponent
<
CLICommand
>>
discover
(
@Nonnull
final
Jenkins
jenkins
)
{
LOGGER
.
fine
(
"Listing up @CLIMethod"
);
List
<
ExtensionComponent
<
CLICommand
>>
r
=
new
ArrayList
<
ExtensionComponent
<
CLICommand
>
>();
List
<
ExtensionComponent
<
CLICommand
>>
r
=
new
ArrayList
<>();
try
{
for
(
final
Method
m
:
Util
.
filter
(
Index
.
list
(
CLIMethod
.
class
,
hudson
.
getPluginManager
().
uberClassLoader
),
Method
.
class
))
{
for
(
final
Method
m
:
Util
.
filter
(
Index
.
list
(
CLIMethod
.
class
,
jenkins
.
getPluginManager
().
uberClassLoader
),
Method
.
class
))
{
try
{
// command name
final
String
name
=
m
.
getAnnotation
(
CLIMethod
.
class
).
name
();
...
...
@@ -111,7 +112,7 @@ public class CLIRegisterer extends ExtensionFinder {
final
ResourceBundleHolder
res
=
loadMessageBundle
(
m
);
res
.
format
(
"CLI."
+
name
+
".shortDescription"
);
// make sure we have the resource, to fail early
r
.
add
(
new
ExtensionComponent
<
CLICommand
>(
new
CloneableCLICommand
()
{
r
.
add
(
new
ExtensionComponent
<>(
new
CloneableCLICommand
()
{
@Override
public
String
getName
()
{
return
name
;
...
...
@@ -120,12 +121,12 @@ public class CLIRegisterer extends ExtensionFinder {
@Override
public
String
getShortDescription
()
{
// format by using the right locale
return
res
.
format
(
"CLI."
+
name
+
".shortDescription"
);
return
res
.
format
(
"CLI."
+
name
+
".shortDescription"
);
}
@Override
protected
CmdLineParser
getCmdLineParser
()
{
return
bindMethod
(
new
ArrayList
<
MethodBinder
>());
return
bindMethod
(
new
ArrayList
<>());
}
private
CmdLineParser
bindMethod
(
List
<
MethodBinder
>
binders
)
{
...
...
@@ -134,7 +135,7 @@ public class CLIRegisterer extends ExtensionFinder {
CmdLineParser
parser
=
new
CmdLineParser
(
null
);
// build up the call sequence
Stack
<
Method
>
chains
=
new
Stack
<
Method
>();
Stack
<
Method
>
chains
=
new
Stack
<>();
Method
method
=
m
;
while
(
true
)
{
chains
.
push
(
method
);
...
...
@@ -146,15 +147,15 @@ public class CLIRegisterer extends ExtensionFinder {
try
{
method
=
findResolver
(
type
);
}
catch
(
IOException
ex
)
{
throw
new
RuntimeException
(
"Unable to find the resolver method annotated with @CLIResolver for "
+
type
,
ex
);
throw
new
RuntimeException
(
"Unable to find the resolver method annotated with @CLIResolver for "
+
type
,
ex
);
}
if
(
method
==
null
)
{
throw
new
RuntimeException
(
"Unable to find the resolver method annotated with @CLIResolver for "
+
type
);
if
(
method
==
null
)
{
throw
new
RuntimeException
(
"Unable to find the resolver method annotated with @CLIResolver for "
+
type
);
}
}
while
(!
chains
.
isEmpty
())
binders
.
add
(
new
MethodBinder
(
chains
.
pop
(),
this
,
parser
));
binders
.
add
(
new
MethodBinder
(
chains
.
pop
(),
this
,
parser
));
return
parser
;
}
...
...
@@ -199,7 +200,7 @@ public class CLIRegisterer extends ExtensionFinder {
this
.
stderr
=
stderr
;
this
.
locale
=
locale
;
List
<
MethodBinder
>
binders
=
new
ArrayList
<
MethodBinder
>();
List
<
MethodBinder
>
binders
=
new
ArrayList
<>();
CmdLineParser
parser
=
bindMethod
(
binders
);
try
{
...
...
@@ -207,7 +208,7 @@ public class CLIRegisterer extends ExtensionFinder {
Authentication
old
=
sc
.
getAuthentication
();
try
{
// authentication
CliAuthenticator
authenticator
=
Jenkins
.
get
Instance
().
getSecurityRealm
().
createCliAuthenticator
(
this
);
CliAuthenticator
authenticator
=
Jenkins
.
get
().
getSecurityRealm
().
createCliAuthenticator
(
this
);
new
ClassParser
().
parse
(
authenticator
,
parser
);
// fill up all the binders
...
...
@@ -217,7 +218,7 @@ public class CLIRegisterer extends ExtensionFinder {
if
(
auth
==
Jenkins
.
ANONYMOUS
)
auth
=
loadStoredAuthentication
();
sc
.
setAuthentication
(
auth
);
// run the CLI with the right credential
hudson
.
checkPermission
(
Jenkins
.
READ
);
jenkins
.
checkPermission
(
Jenkins
.
READ
);
// resolve them
Object
instance
=
null
;
...
...
core/src/main/java/hudson/cli/handlers/GenericItemOptionHandler.java
浏览文件 @
86da98c3
...
...
@@ -57,7 +57,7 @@ public abstract class GenericItemOptionHandler<T extends Item> extends OptionHan
protected
abstract
Class
<
T
>
type
();
@Override
public
int
parseArguments
(
Parameters
params
)
throws
CmdLineException
{
final
Jenkins
j
=
Jenkins
.
get
Instance
();
final
Jenkins
j
=
Jenkins
.
get
();
final
String
src
=
params
.
getParameter
(
0
);
T
s
=
j
.
getItemByFullName
(
src
,
type
());
if
(
s
==
null
)
{
...
...
core/src/main/java/hudson/cli/handlers/NodeOptionHandler.java
浏览文件 @
86da98c3
...
...
@@ -53,7 +53,7 @@ public class NodeOptionHandler extends OptionHandler<Node> {
String
nodeName
=
params
.
getParameter
(
0
);
final
Node
node
=
Jenkins
.
get
Instance
().
getNode
(
nodeName
);
final
Node
node
=
Jenkins
.
get
().
getNode
(
nodeName
);
if
(
node
==
null
)
throw
new
IllegalArgumentException
(
"No such node '"
+
nodeName
+
"'"
);
setter
.
addValue
(
node
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录