Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
roginluo
Jenkins
提交
5e8d0b65
J
Jenkins
项目概览
roginluo
/
Jenkins
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
Jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5e8d0b65
编写于
11月 30, 2012
作者:
N
Nicolas De loof
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #614 from mkochofenough/feature-cli-list-jobs
Feature cli list jobs
上级
b8078947
317bd499
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
92 addition
and
0 deletion
+92
-0
core/src/main/java/hudson/cli/ListJobsCommand.java
core/src/main/java/hudson/cli/ListJobsCommand.java
+90
-0
core/src/main/resources/hudson/cli/Messages.properties
core/src/main/resources/hudson/cli/Messages.properties
+2
-0
未找到文件。
core/src/main/java/hudson/cli/ListJobsCommand.java
0 → 100644
浏览文件 @
5e8d0b65
/*
* The MIT License
*
* Copyright (c) 2004-2010, Sun Microsystems, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
hudson.cli
;
import
java.util.Collection
;
import
java.util.Collections
;
import
hudson.model.Item
;
import
hudson.model.ItemGroup
;
import
hudson.model.TopLevelItem
;
import
hudson.model.View
;
import
hudson.Extension
;
import
jenkins.model.Jenkins
;
import
org.kohsuke.args4j.Argument
;
/**
* Lists all jobs (in a specific view).
*
* @author Michael Koch
*/
@Extension
public
class
ListJobsCommand
extends
CLICommand
{
@Override
public
String
getShortDescription
()
{
return
Messages
.
ListJobsCommand_ShortDescription
();
}
@Argument
(
metaVar
=
"NAME"
,
usage
=
"Name of the view"
,
required
=
false
)
public
String
name
;
protected
int
run
()
throws
Exception
{
Jenkins
h
=
Jenkins
.
getInstance
();
final
Collection
<
TopLevelItem
>
jobs
;
// If name is given retrieve jobs for the given view.
if
(
name
!=
null
)
{
View
view
=
h
.
getView
(
name
);
if
(
view
!=
null
)
{
jobs
=
view
.
getItems
();
}
// If no view was found, try with an item group.
else
{
final
Item
item
=
h
.
getItemByFullName
(
name
);
// If item group was found use it's jobs.
if
(
item
instanceof
ItemGroup
)
{
ItemGroup
itemGroup
=
(
ItemGroup
)
item
;
jobs
=
itemGroup
.
getItems
();
}
// No view and no item group with the given name found.
else
{
stderr
.
println
(
"No view or item group with the given name found"
);
jobs
=
Collections
.
emptyList
();
}
}
}
// Fallback to listing all jobs.
else
{
jobs
=
h
.
getItems
();
}
// Print all jobs.
for
(
TopLevelItem
item
:
jobs
)
{
stdout
.
println
(
item
.
getDisplayName
());
}
return
0
;
}
}
core/src/main/resources/hudson/cli/Messages.properties
浏览文件 @
5e8d0b65
...
...
@@ -25,6 +25,8 @@ InstallToolCommand.ShortDescription=\
Performs automatic tool installation, and print its location to stdout. Can be only called from inside a build.
ListChangesCommand.ShortDescription
=
\
Dumps the changelog for the specified build(s).
ListJobsCommand.ShortDescription
=
\
Lists all jobs in a specific view or item group.
LoginCommand.ShortDescription
=
\
Saves the current credential to allow future commands to run without explicit credential information.
LogoutCommand.ShortDescription
=
\
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录