Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
编程小吉
jenkins
提交
0ffa0327
J
jenkins
项目概览
编程小吉
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
0ffa0327
编写于
1月 30, 2011
作者:
S
Stefan Wolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added autocomplete feature to BuildTrigger
上级
5bd0b989
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
49 addition
and
19 deletion
+49
-19
core/src/main/java/hudson/tasks/BuildTrigger.java
core/src/main/java/hudson/tasks/BuildTrigger.java
+44
-18
core/src/main/resources/hudson/tasks/BuildTrigger/config.jelly
...src/main/resources/hudson/tasks/BuildTrigger/config.jelly
+3
-1
core/src/main/resources/hudson/tasks/Messages.properties
core/src/main/resources/hudson/tasks/Messages.properties
+1
-0
core/src/main/resources/hudson/tasks/Messages_de.properties
core/src/main/resources/hudson/tasks/Messages_de.properties
+1
-0
未找到文件。
core/src/main/java/hudson/tasks/BuildTrigger.java
浏览文件 @
0ffa0327
/*
* The MIT License
*
*
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Brian Westrich, Martin Eigenbrodt
*
*
* 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
...
...
@@ -23,14 +23,15 @@
*/
package
hudson.tasks
;
import
hudson.Launcher
;
import
hudson.Extension
;
import
hudson.Launcher
;
import
hudson.Util
;
import
hudson.security.AccessControlled
;
import
hudson.model.AbstractBuild
;
import
hudson.model.AbstractProject
;
import
hudson.model.Action
;
import
hudson.model.AutoCompletionCandidates
;
import
hudson.model.BuildListener
;
import
hudson.model.Cause.UpstreamCause
;
import
hudson.model.DependecyDeclarer
;
import
hudson.model.DependencyGraph
;
import
hudson.model.DependencyGraph.Dependency
;
...
...
@@ -41,15 +42,16 @@ import hudson.model.Job;
import
hudson.model.Project
;
import
hudson.model.Result
;
import
hudson.model.Run
;
import
hudson.model.Cause.UpstreamCause
;
import
hudson.model.TaskListener
;
import
hudson.model.listeners.ItemListener
;
import
hudson.security.AccessControlled
;
import
hudson.util.FormValidation
;
import
net.sf.json.JSONObject
;
import
org.kohsuke.stapler.DataBoundConstructor
;
import
org.kohsuke.stapler.StaplerRequest
;
import
org.apache.commons.lang.StringUtils
;
import
org.kohsuke.stapler.AncestorInPath
;
import
org.kohsuke.stapler.DataBoundConstructor
;
import
org.kohsuke.stapler.QueryParameter
;
import
org.kohsuke.stapler.StaplerRequest
;
import
java.io.IOException
;
import
java.io.PrintStream
;
...
...
@@ -67,7 +69,7 @@ import java.util.logging.Logger;
*
* <p>
* Despite what the name suggests, this class doesn't actually trigger other jobs
* as a part of {@link #perform} method. Its main job is to simply aug
u
ment
* as a part of {@link #perform} method. Its main job is to simply augment
* {@link DependencyGraph}. Jobs are responsible for triggering downstream jobs
* on its own, because dependencies may come from other sources.
*
...
...
@@ -130,7 +132,7 @@ public class BuildTrigger extends Recorder implements DependecyDeclarer {
public
BuildStepMonitor
getRequiredMonitorService
()
{
return
BuildStepMonitor
.
NONE
;
}
/**
* Checks if this trigger has the exact same set of children as the given list.
*/
...
...
@@ -268,8 +270,12 @@ public class BuildTrigger extends Recorder implements DependecyDeclarer {
@Override
public
Publisher
newInstance
(
StaplerRequest
req
,
JSONObject
formData
)
throws
FormException
{
String
childProjectsString
=
formData
.
getString
(
"childProjects"
).
trim
();
if
(
childProjectsString
.
endsWith
(
","
))
{
childProjectsString
=
childProjectsString
.
substring
(
0
,
childProjectsString
.
length
()
-
1
).
trim
();
}
return
new
BuildTrigger
(
formData
.
getString
(
"childProjects"
)
,
childProjectsString
,
formData
.
has
(
"evenIfUnstable"
)
&&
formData
.
getBoolean
(
"evenIfUnstable"
));
}
...
...
@@ -279,7 +285,7 @@ public class BuildTrigger extends Recorder implements DependecyDeclarer {
}
public
boolean
showEvenIfUnstableOption
(
Class
<?
extends
AbstractProject
>
jobType
)
{
// UGLY: for promotion process, this option doesn't make sense.
// UGLY: for promotion process, this option doesn't make sense.
return
!
jobType
.
getName
().
contains
(
"PromotionProcess"
);
}
...
...
@@ -291,18 +297,38 @@ public class BuildTrigger extends Recorder implements DependecyDeclarer {
if
(!
subject
.
hasPermission
(
Item
.
CONFIGURE
))
return
FormValidation
.
ok
();
StringTokenizer
tokens
=
new
StringTokenizer
(
Util
.
fixNull
(
value
),
","
);
boolean
hasProjects
=
false
;
while
(
tokens
.
hasMoreTokens
())
{
String
projectName
=
tokens
.
nextToken
().
trim
();
Item
item
=
Hudson
.
getInstance
().
getItemByFullName
(
projectName
,
Item
.
class
);
if
(
item
==
null
)
return
FormValidation
.
error
(
Messages
.
BuildTrigger_NoSuchProject
(
projectName
,
AbstractProject
.
findNearest
(
projectName
).
getName
()));
if
(!(
item
instanceof
AbstractProject
))
return
FormValidation
.
error
(
Messages
.
BuildTrigger_NotBuildable
(
projectName
));
if
(
StringUtils
.
isNotBlank
(
projectName
))
{
Item
item
=
Hudson
.
getInstance
().
getItemByFullName
(
projectName
,
Item
.
class
);
if
(
item
==
null
)
return
FormValidation
.
error
(
Messages
.
BuildTrigger_NoSuchProject
(
projectName
,
AbstractProject
.
findNearest
(
projectName
).
getName
()));
if
(!(
item
instanceof
AbstractProject
))
return
FormValidation
.
error
(
Messages
.
BuildTrigger_NotBuildable
(
projectName
));
hasProjects
=
true
;
}
}
if
(!
hasProjects
)
{
return
FormValidation
.
error
(
Messages
.
BuildTrigger_NoProjectSpecified
());
}
return
FormValidation
.
ok
();
}
public
AutoCompletionCandidates
doAutoCompleteChildProjects
(
@QueryParameter
String
value
)
{
AutoCompletionCandidates
candidates
=
new
AutoCompletionCandidates
();
List
<
Job
>
jobs
=
Hudson
.
getInstance
().
getItems
(
Job
.
class
);
for
(
Job
job:
jobs
)
{
if
(
job
.
getFullName
().
startsWith
(
value
))
{
if
(
job
.
hasPermission
(
Item
.
READ
))
{
candidates
.
add
(
job
.
getFullName
());
}
}
}
return
candidates
;
}
@Extension
public
static
class
ItemListenerImpl
extends
ItemListener
{
@Override
...
...
core/src/main/resources/hudson/tasks/BuildTrigger/config.jelly
浏览文件 @
0ffa0327
...
...
@@ -25,7 +25,9 @@ THE SOFTWARE.
<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">
<f:entry title="${%Projects to build}">
<f:textbox name="buildTrigger.childProjects" value="${instance.childProjectsValue}"
checkUrl="'descriptorByName/BuildTrigger/check?value='+encodeURIComponent(this.value)"/>
checkUrl="'descriptorByName/BuildTrigger/check?value='+encodeURIComponent(this.value)"
autoCompleteDelimChar=","
field="childProjects"/>
</f:entry>
<j:if test="${descriptor.showEvenIfUnstableOption(targetType)}">
<f:entry title="">
...
...
core/src/main/resources/hudson/tasks/Messages.properties
浏览文件 @
0ffa0327
...
...
@@ -44,6 +44,7 @@ BuildTrigger.Disabled={0} is disabled. Triggering skipped
BuildTrigger.DisplayName
=
Build other projects
BuildTrigger.InQueue
=
{0} is already in the queue
BuildTrigger.NoSuchProject
=
No such project ''{0}''. Did you mean ''{1}''?
BuildTrigger.NoProjectSpecified
=
No project specified
BuildTrigger.NotBuildable
=
{0} is not buildable
BuildTrigger.Triggering
=
Triggering a new build of {0}
...
...
core/src/main/resources/hudson/tasks/Messages_de.properties
浏览文件 @
0ffa0327
...
...
@@ -44,6 +44,7 @@ BuildTrigger.Disabled={0} ist deaktiviert. Keine Ausl
BuildTrigger.DisplayName
=
Weitere Projekte bauen
BuildTrigger.InQueue
=
{0} ist bereits geplant.
BuildTrigger.NoSuchProject
=
Kein Projekt ''{0}'' gefunden. Meinten Sie ''{1}''?
BuildTrigger.NoProjectSpecified
=
Kein Projekt angegeben
BuildTrigger.NotBuildable
=
{0} kann nicht gebaut werden.
BuildTrigger.Triggering
=
L
\u
00F6se einen neuen Build von {0} aus
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录