Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
37f91746
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,发现更多精彩内容 >>
提交
37f91746
编写于
5月 15, 2013
作者:
D
Donny Nadolny
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/jenkinsci/jenkins
上级
f566c8ae
5ecbbefb
变更
30
隐藏空白更改
内联
并排
Showing
30 changed file
with
658 addition
and
80 deletion
+658
-80
changelog.html
changelog.html
+20
-7
cli/pom.xml
cli/pom.xml
+1
-1
core/pom.xml
core/pom.xml
+1
-1
core/src/main/java/hudson/PluginManager.java
core/src/main/java/hudson/PluginManager.java
+11
-13
core/src/main/java/hudson/init/impl/GroovyInitScript.java
core/src/main/java/hudson/init/impl/GroovyInitScript.java
+7
-3
core/src/main/java/hudson/matrix/Combination.java
core/src/main/java/hudson/matrix/Combination.java
+9
-1
core/src/main/java/hudson/matrix/DefaultMatrixExecutionStrategyImpl.java
...ava/hudson/matrix/DefaultMatrixExecutionStrategyImpl.java
+78
-14
core/src/main/java/hudson/matrix/MatrixProject.java
core/src/main/java/hudson/matrix/MatrixProject.java
+29
-2
core/src/main/java/hudson/model/Cause.java
core/src/main/java/hudson/model/Cause.java
+33
-0
core/src/main/java/hudson/model/FileParameterDefinition.java
core/src/main/java/hudson/model/FileParameterDefinition.java
+10
-1
core/src/main/java/hudson/model/Node.java
core/src/main/java/hudson/model/Node.java
+6
-5
core/src/main/java/hudson/model/Run.java
core/src/main/java/hudson/model/Run.java
+7
-1
core/src/main/java/hudson/model/UpdateCenter.java
core/src/main/java/hudson/model/UpdateCenter.java
+8
-0
core/src/main/java/hudson/util/CopyOnWriteMap.java
core/src/main/java/hudson/util/CopyOnWriteMap.java
+13
-0
core/src/main/java/jenkins/model/lazy/Boundary.java
core/src/main/java/jenkins/model/lazy/Boundary.java
+1
-1
core/src/test/java/hudson/matrix/CombinationFilterUsingBuildParamsTest.java
.../hudson/matrix/CombinationFilterUsingBuildParamsTest.java
+284
-0
core/src/test/java/hudson/util/CopyOnWriteMapTest.java
core/src/test/java/hudson/util/CopyOnWriteMapTest.java
+20
-4
maven-plugin/pom.xml
maven-plugin/pom.xml
+1
-1
plugins/pom.xml
plugins/pom.xml
+6
-6
pom.xml
pom.xml
+1
-1
test/pom.xml
test/pom.xml
+1
-1
test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java
test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java
+3
-4
test/src/main/java/org/jvnet/hudson/test/JenkinsRule.java
test/src/main/java/org/jvnet/hudson/test/JenkinsRule.java
+3
-1
test/src/test/java/hudson/init/impl/GroovyInitScriptTest.java
.../src/test/java/hudson/init/impl/GroovyInitScriptTest.java
+47
-0
test/src/test/java/hudson/model/RunTest.java
test/src/test/java/hudson/model/RunTest.java
+38
-6
test/src/test/java/org/jvnet/hudson/main/UseRecipesWithJenkinsRuleTest.java
.../org/jvnet/hudson/main/UseRecipesWithJenkinsRuleTest.java
+5
-0
test/src/test/resources/hudson/init/impl/GroovyInitScriptTest/errorsHandled.zip
...s/hudson/init/impl/GroovyInitScriptTest/errorsHandled.zip
+0
-0
ui-samples-plugin/pom.xml
ui-samples-plugin/pom.xml
+1
-1
war/pom.xml
war/pom.xml
+1
-1
war/src/main/webapp/help/parameter/file.html
war/src/main/webapp/help/parameter/file.html
+13
-4
未找到文件。
changelog.html
浏览文件 @
37f91746
...
...
@@ -54,13 +54,29 @@ Upcoming changes</a>
<!-- Record your changes in the trunk here. -->
<div
id=
"trunk"
style=
"display:none"
>
<!--=TRUNK-BEGIN=-->
<ul
class=
image
>
<li
class=
bug
>
NPE from
<code>
Run.getDynamic
</code>
.
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-17935"
>
issue 17935
</a>
)
<li
class=
bug
>
Reworked Upload Plugin gesture to work more like installation from an update center, and in particular to support dynamic load.
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-16652"
>
issue 16652
</a>
)
<li
class=
bug
>
Errors in
<code>
init.groovy
</code>
halted startup; changed to just log a warning.
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-17933"
>
issue 17933
</a>
)
</ul>
</div>
<!--=TRUNK-END=-->
<!-- these changes are controlled by the release process. DO NOT MODIFY -->
<div
id=
"rc"
style=
"display:none;"
>
<!--=BEGIN=-->
<h3><a
name=
v1.515
>
What's new in 1.515
</a>
<!--=DATE=-->
</h3>
<ul
class=
image
>
<li
class=
rfe
>
Windows services now auto-restart in case of abnormal process termination.
<li
class=
rfe
>
<
f:dropdownDescriptorSelector> does not allow defaulting to specifig instance
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-17858"
>
issue 17858
</a>
)
<li
class=
bug
>
<li
class=
rfe
>
mark maven settings / global settings as default for new jobs
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-17723"
>
issue 17723
</a>
)
<li
class=
bug
>
...
...
@@ -78,13 +94,10 @@ Upcoming changes</a>
<li
class=
'major bug'
>
Properly find parent POMs when fingerprinting a Maven project.
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-17775"
>
issue 17775
</a>
)
<li
class=
rfe
>
Allow the combination filter to accept parameter values.
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-7285"
>
issue 7285
</a>
)
</ul>
</div>
<!--=TRUNK-END=-->
<!-- these changes are controlled by the release process. DO NOT MODIFY -->
<div
id=
"rc"
style=
"display:none;"
>
<!--=BEGIN=-->
<h3><a
name=
v1.515
>
What's new in 1.515
</a>
<!--=DATE=-->
</h3>
<!--=RC-CHANGES=-->
</div>
<!--=END=-->
<h3><a
name=
v1.514
>
What's new in 1.514
</a>
(2013/05/01)
</h3>
<ul
class=
image
>
...
...
cli/pom.xml
浏览文件 @
37f91746
...
...
@@ -5,7 +5,7 @@
<parent>
<artifactId>
pom
</artifactId>
<groupId>
org.jenkins-ci.main
</groupId>
<version>
1.51
5
-SNAPSHOT
</version>
<version>
1.51
6
-SNAPSHOT
</version>
</parent>
<artifactId>
cli
</artifactId>
...
...
core/pom.xml
浏览文件 @
37f91746
...
...
@@ -29,7 +29,7 @@ THE SOFTWARE.
<parent>
<groupId>
org.jenkins-ci.main
</groupId>
<artifactId>
pom
</artifactId>
<version>
1.51
5
-SNAPSHOT
</version>
<version>
1.51
6
-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
...
...
core/src/main/java/hudson/PluginManager.java
浏览文件 @
37f91746
...
...
@@ -732,25 +732,23 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
}
// first copy into a temporary file name
File
t
=
File
.
createTempFile
(
"uploaded"
,
"jp_"
,
rootDir
);
fileItem
.
write
(
t
);
// rename all new plugins to *.jpi
File
t
=
File
.
createTempFile
(
"uploaded"
,
".jpi"
);
t
.
deleteOnExit
();
fileItem
.
write
(
t
);
fileItem
.
delete
();
final
String
baseName
=
identifyPluginShortName
(
t
);
// and move the temp file into a proper name
new
File
(
rootDir
,
baseName
+
".hpi"
).
delete
();
// don't keep confusing legacy *.hpi
new
File
(
rootDir
,
baseName
+
".jpi"
).
delete
();
// rename can fail if the file already exists
t
.
renameTo
(
new
File
(
rootDir
,
baseName
+
".jpi"
));
PluginWrapper
existing
=
getPlugin
(
baseName
);
if
(
existing
!=
null
&&
existing
.
isBundled
){
existing
.
doPin
();
}
pluginUploaded
=
true
;
return
new
HttpRedirect
(
"."
);
// Now create a dummy plugin that we can dynamically load (the InstallationJob will force a restart if one is needed):
JSONObject
cfg
=
new
JSONObject
().
element
(
"name"
,
baseName
).
element
(
"version"
,
"0"
).
// unused but mandatory
element
(
"url"
,
t
.
toURI
().
toString
()).
element
(
"dependencies"
,
new
JSONArray
());
new
UpdateSite
(
UpdateCenter
.
ID_UPLOAD
,
null
).
new
Plugin
(
UpdateCenter
.
ID_UPLOAD
,
cfg
).
deploy
(
true
);
return
new
HttpRedirect
(
"../updateCenter"
);
}
catch
(
IOException
e
)
{
throw
e
;
}
catch
(
Exception
e
)
{
// grrr. fileItem.write throws this
...
...
core/src/main/java/hudson/init/impl/GroovyInitScript.java
浏览文件 @
37f91746
...
...
@@ -31,12 +31,12 @@ import java.io.FileFilter;
import
java.io.IOException
;
import
java.net.URL
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.logging.Logger
;
import
jenkins.model.Jenkins
;
import
static
hudson
.
init
.
InitMilestone
.
JOB_LOADED
;
import
hudson.init.Initializer
;
import
java.util.logging.Level
;
/**
* Run the initialization script, if it exists.
...
...
@@ -78,9 +78,13 @@ public class GroovyInitScript {
execute
(
new
GroovyCodeSource
(
initScript
));
}
private
static
void
execute
(
GroovyCodeSource
initScript
)
throws
IOException
{
private
static
void
execute
(
GroovyCodeSource
initScript
)
{
GroovyShell
shell
=
new
GroovyShell
(
Jenkins
.
getInstance
().
getPluginManager
().
uberClassLoader
);
shell
.
evaluate
(
initScript
);
try
{
shell
.
evaluate
(
initScript
);
}
catch
(
RuntimeException
x
)
{
LOGGER
.
log
(
Level
.
WARNING
,
"Failed to run script "
+
initScript
.
getName
(),
x
);
}
}
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
GroovyInitScript
.
class
.
getName
());
...
...
core/src/main/java/hudson/matrix/Combination.java
浏览文件 @
37f91746
...
...
@@ -111,10 +111,18 @@ public final class Combination extends TreeMap<String,String> implements Compara
* true.
*/
public
boolean
evalGroovyExpression
(
AxisList
axes
,
String
expression
)
{
return
evalGroovyExpression
(
axes
,
expression
,
new
Binding
());
}
/**
* @see #evalGroovyExpression(AxisList, String)
* @since 1.515
*/
public
boolean
evalGroovyExpression
(
AxisList
axes
,
String
expression
,
Binding
binding
)
{
if
(
Util
.
fixEmptyAndTrim
(
expression
)==
null
)
return
true
;
Binding
binding
=
new
Binding
();
for
(
Map
.
Entry
<
String
,
String
>
e
:
entrySet
())
binding
.
setVariable
(
e
.
getKey
(),
e
.
getValue
());
...
...
core/src/main/java/hudson/matrix/DefaultMatrixExecutionStrategyImpl.java
浏览文件 @
37f91746
package
hudson.matrix
;
import
groovy.lang.Binding
;
import
groovy.lang.GroovyRuntimeException
;
import
hudson.AbortException
;
import
hudson.Extension
;
import
hudson.Util
;
...
...
@@ -8,6 +10,7 @@ import hudson.matrix.MatrixBuild.MatrixBuildExecution;
import
hudson.matrix.listeners.MatrixBuildListener
;
import
hudson.model.BuildListener
;
import
hudson.model.Cause.UpstreamCause
;
import
hudson.model.ParameterValue
;
import
hudson.model.ParametersAction
;
import
hudson.model.Queue
;
import
hudson.model.ResourceController
;
...
...
@@ -113,27 +116,21 @@ public class DefaultMatrixExecutionStrategyImpl extends MatrixExecutionStrategy
@Override
public
Result
run
(
MatrixBuildExecution
execution
)
throws
InterruptedException
,
IOException
{
MatrixBuild
build
=
execution
.
getBuild
();
MatrixProject
p
=
execution
.
getProject
();
PrintStream
logger
=
execution
.
getListener
().
getLogger
();
Collection
<
MatrixConfiguration
>
touchStoneConfigurations
=
new
HashSet
<
MatrixConfiguration
>();
Collection
<
MatrixConfiguration
>
delayedConfigurations
=
new
HashSet
<
MatrixConfiguration
>();
for
(
MatrixConfiguration
c:
execution
.
getActiveConfigurations
())
{
if
(!
MatrixBuildListener
.
buildConfiguration
(
build
,
c
))
continue
;
// skip rebuild
if
(
touchStoneCombinationFilter
!=
null
&&
c
.
getCombination
().
evalGroovyExpression
(
p
.
getAxes
(),
getTouchStoneCombinationFilter
()))
{
touchStoneConfigurations
.
add
(
c
);
}
else
{
delayedConfigurations
.
add
(
c
);
}
}
filterConfigurations
(
execution
,
touchStoneConfigurations
,
delayedConfigurations
);
if
(
notifyStartBuild
(
execution
.
getAggregators
()))
return
Result
.
FAILURE
;
if
(
sorter
!=
null
)
{
touchStoneConfigurations
=
createTreeSet
(
touchStoneConfigurations
,
sorter
);
delayedConfigurations
=
createTreeSet
(
delayedConfigurations
,
sorter
);
delayedConfigurations
=
createTreeSet
(
delayedConfigurations
,
sorter
);
}
if
(!
runSequentially
)
...
...
@@ -148,7 +145,9 @@ public class DefaultMatrixExecutionStrategyImpl extends MatrixExecutionStrategy
notifyEndBuild
(
run
,
execution
.
getAggregators
());
r
=
r
.
combine
(
getResult
(
run
));
}
PrintStream
logger
=
execution
.
getListener
().
getLogger
();
if
(
touchStoneResultCondition
!=
null
&&
r
.
isWorseThan
(
touchStoneResultCondition
))
{
logger
.
printf
(
"Touchstone configurations resulted in %s, so aborting...%n"
,
r
);
return
r
;
...
...
@@ -170,6 +169,71 @@ public class DefaultMatrixExecutionStrategyImpl extends MatrixExecutionStrategy
return
r
;
}
private
void
filterConfigurations
(
final
MatrixBuildExecution
execution
,
final
Collection
<
MatrixConfiguration
>
touchStoneConfigurations
,
final
Collection
<
MatrixConfiguration
>
delayedConfigurations
)
throws
AbortException
{
final
MatrixBuild
build
=
execution
.
getBuild
();
final
String
combinationFilter
=
execution
.
getProject
().
getCombinationFilter
();
final
String
touchStoneFilter
=
getTouchStoneCombinationFilter
();
try
{
for
(
MatrixConfiguration
c:
execution
.
getActiveConfigurations
())
{
if
(!
MatrixBuildListener
.
buildConfiguration
(
build
,
c
))
continue
;
// skip rebuild
final
Combination
combination
=
c
.
getCombination
();
if
(
touchStoneFilter
!=
null
&&
satisfies
(
execution
,
combination
,
touchStoneFilter
))
{
touchStoneConfigurations
.
add
(
c
);
}
else
if
(
satisfies
(
execution
,
combination
,
combinationFilter
))
{
delayedConfigurations
.
add
(
c
);
}
}
}
catch
(
GroovyRuntimeException
ex
)
{
PrintStream
logger
=
execution
.
getListener
().
getLogger
();
logger
.
println
(
ex
.
getMessage
());
ex
.
printStackTrace
(
logger
);
throw
new
AbortException
(
"Failed executing combination filter"
);
}
}
private
boolean
satisfies
(
final
MatrixBuildExecution
execution
,
final
Combination
combination
,
final
String
filter
)
{
return
combination
.
evalGroovyExpression
(
execution
.
getProject
().
getAxes
(),
filter
,
getConfiguredBinding
(
execution
)
);
}
private
Binding
getConfiguredBinding
(
final
MatrixBuildExecution
execution
)
{
final
Binding
binding
=
new
Binding
();
final
ParametersAction
parameters
=
execution
.
getBuild
().
getAction
(
ParametersAction
.
class
);
if
(
parameters
==
null
)
return
binding
;
for
(
final
ParameterValue
pv:
parameters
)
{
if
(
pv
==
null
)
continue
;
final
String
name
=
pv
.
getName
();
final
String
value
=
pv
.
createVariableResolver
(
null
).
resolve
(
name
);;
binding
.
setVariable
(
name
,
value
);
}
return
binding
;
}
private
Result
getResult
(
@Nullable
MatrixRun
run
)
{
// null indicates that the run was cancelled before it even gets going
return
run
!=
null
?
run
.
getResult
()
:
Result
.
ABORTED
;
...
...
core/src/main/java/hudson/matrix/MatrixProject.java
浏览文件 @
37f91746
...
...
@@ -48,6 +48,8 @@ import hudson.model.Items;
import
hudson.model.JDK
;
import
hudson.model.Job
;
import
hudson.model.Label
;
import
hudson.model.ParameterDefinition
;
import
hudson.model.ParametersDefinitionProperty
;
import
hudson.model.Queue.FlyweightTask
;
import
hudson.model.Result
;
import
hudson.model.SCMedItem
;
...
...
@@ -89,6 +91,8 @@ import java.util.Map.Entry;
import
java.util.Set
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
/**
* {@link Job} that allows you to run multiple different configurations
...
...
@@ -603,9 +607,11 @@ public class MatrixProject extends AbstractProject<MatrixProject,MatrixBuild> im
}
// find all active configurations
Set
<
MatrixConfiguration
>
active
=
new
LinkedHashSet
<
MatrixConfiguration
>();
final
Set
<
MatrixConfiguration
>
active
=
new
LinkedHashSet
<
MatrixConfiguration
>();
final
boolean
isDynamicFilter
=
isDynamicFilter
(
getCombinationFilter
());
for
(
Combination
c
:
activeCombinations
)
{
if
(
c
.
evalGroovyExpression
(
axes
,
combinationFilter
))
{
if
(
isDynamicFilter
||
c
.
evalGroovyExpression
(
axes
,
getCombinationFilter
()
))
{
LOGGER
.
fine
(
"Adding configuration: "
+
c
);
MatrixConfiguration
config
=
configurations
.
get
(
c
);
if
(
config
==
null
)
{
...
...
@@ -622,6 +628,27 @@ public class MatrixProject extends AbstractProject<MatrixProject,MatrixBuild> im
return
active
;
}
private
boolean
isDynamicFilter
(
final
String
filter
)
{
if
(!
isParameterized
()
||
filter
==
null
)
return
false
;
final
ParametersDefinitionProperty
paramDefProp
=
getProperty
(
ParametersDefinitionProperty
.
class
);
for
(
final
ParameterDefinition
definition
:
paramDefProp
.
getParameterDefinitions
())
{
final
String
name
=
definition
.
getName
();
final
Matcher
matcher
=
Pattern
.
compile
(
"\\b"
+
name
+
"\\b"
)
.
matcher
(
filter
)
;
if
(
matcher
.
find
())
return
true
;
}
return
false
;
}
private
File
getConfigurationsDir
()
{
return
new
File
(
getRootDir
(),
"configurations"
);
}
...
...
core/src/main/java/hudson/model/Cause.java
浏览文件 @
37f91746
...
...
@@ -148,6 +148,39 @@ public abstract class Cause {
this
.
upstreamCauses
=
upstreamCauses
;
}
/**
* @since 1.515
*/
@Override
public
boolean
equals
(
Object
rhs
)
{
if
(
this
==
rhs
)
return
true
;
if
(!(
rhs
instanceof
UpstreamCause
))
return
false
;
final
UpstreamCause
o
=
(
UpstreamCause
)
rhs
;
if
(
upstreamBuild
!=
o
.
upstreamBuild
)
return
false
;
if
(!
upstreamCauses
.
equals
(
o
.
upstreamCauses
))
return
false
;
if
(
upstreamUrl
==
null
?
o
.
upstreamUrl
!=
null
:
!
upstreamUrl
.
equals
(
o
.
upstreamUrl
))
return
false
;
if
(
upstreamProject
==
null
?
o
.
upstreamProject
!=
null
:
!
upstreamProject
.
equals
(
o
.
upstreamProject
))
return
false
;
return
true
;
}
/**
* @since 1.515
*/
@Override
public
int
hashCode
()
{
int
hashCode
=
17
;
hashCode
=
hashCode
*
31
+
upstreamCauses
.
hashCode
();
hashCode
=
hashCode
*
31
+
upstreamBuild
;
hashCode
=
hashCode
*
31
+
(
upstreamUrl
==
null
?
0
:
upstreamUrl
.
hashCode
());
return
hashCode
*
31
+
(
upstreamProject
==
null
?
0
:
upstreamProject
.
hashCode
());
}
private
@Nonnull
Cause
trim
(
@Nonnull
Cause
c
,
int
depth
,
Set
<
String
>
traversed
)
{
if
(!(
c
instanceof
UpstreamCause
))
{
return
c
;
...
...
core/src/main/java/hudson/model/FileParameterDefinition.java
浏览文件 @
37f91746
...
...
@@ -86,12 +86,21 @@ public class FileParameterDefinition extends ParameterDefinition {
// the requested file parameter wasn't uploaded
return
null
;
}
FileParameterValue
p
=
new
FileParameterValue
(
getName
(),
src
);
FileParameterValue
p
=
new
FileParameterValue
(
getName
(),
src
,
getFileName
(
src
.
getName
())
);
p
.
setDescription
(
getDescription
());
p
.
setLocation
(
getName
());
return
p
;
}
/**
* Strip off the path portion if the given path contains it.
*/
private
String
getFileName
(
String
possiblyPathName
)
{
possiblyPathName
=
possiblyPathName
.
substring
(
possiblyPathName
.
lastIndexOf
(
'/'
)+
1
);
possiblyPathName
=
possiblyPathName
.
substring
(
possiblyPathName
.
lastIndexOf
(
'\\'
)+
1
);
return
possiblyPathName
;
}
@Override
public
ParameterValue
createValue
(
CLICommand
command
,
String
value
)
throws
IOException
,
InterruptedException
{
// capture the file to the server
...
...
core/src/main/java/hudson/model/Node.java
浏览文件 @
37f91746
...
...
@@ -62,6 +62,7 @@ import javax.annotation.CheckForNull;
import
jenkins.model.Jenkins
;
import
jenkins.util.io.OnMaster
;
import
net.sf.json.JSONObject
;
import
org.jvnet.localizer.Localizable
;
import
org.kohsuke.stapler.BindInterceptor
;
import
org.kohsuke.stapler.Stapler
;
import
org.kohsuke.stapler.StaplerRequest
;
...
...
@@ -442,20 +443,20 @@ public abstract class Node extends AbstractModelObject implements Reconfigurable
* Constants that control how Hudson allocates jobs to slaves.
*/
public
enum
Mode
{
NORMAL
(
Messages
.
Node_Mode_NORMAL
()),
EXCLUSIVE
(
Messages
.
Node_Mode_EXCLUSIVE
());
NORMAL
(
Messages
.
_
Node_Mode_NORMAL
()),
EXCLUSIVE
(
Messages
.
_
Node_Mode_EXCLUSIVE
());
private
final
String
description
;
private
final
Localizable
description
;
public
String
getDescription
()
{
return
description
;
return
description
.
toString
()
;
}
public
String
getName
()
{
return
name
();
}
Mode
(
String
description
)
{
Mode
(
Localizable
description
)
{
this
.
description
=
description
;
}
...
...
core/src/main/java/hudson/model/Run.java
浏览文件 @
37f91746
...
...
@@ -328,6 +328,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
List
<
Action
>
actions
=
new
ArrayList
<
Action
>();
for
(
TransientBuildActionFactory
factory:
TransientBuildActionFactory
.
all
())
{
actions
.
addAll
(
factory
.
createFor
(
this
));
assert
!
actions
.
contains
(
null
)
:
"null action added by "
+
factory
;
}
return
Collections
.
unmodifiableList
(
actions
);
}
...
...
@@ -2210,8 +2211,13 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
if
(
result
==
null
){
//check transient actions too
for
(
Action
action:
getTransientActions
()){
if
(
action
.
getUrlName
().
equals
(
token
))
String
urlName
=
action
.
getUrlName
();
if
(
urlName
==
null
)
{
continue
;
}
if
(
urlName
.
equals
(
token
))
{
return
action
;
}
}
// Next/Previous Build links on an action page (like /job/Abc/123/testReport)
// will also point to same action (/job/Abc/124/testReport), but other builds
...
...
core/src/main/java/hudson/model/UpdateCenter.java
浏览文件 @
37f91746
...
...
@@ -89,6 +89,8 @@ import java.util.logging.Level;
import
java.util.logging.Logger
;
import
javax.annotation.CheckForNull
;
import
org.acegisecurity.context.SecurityContextHolder
;
import
org.kohsuke.accmod.Restricted
;
import
org.kohsuke.accmod.restrictions.NoExternalUse
;
import
org.kohsuke.stapler.export.Exported
;
import
org.kohsuke.stapler.export.ExportedBean
;
import
org.kohsuke.stapler.interceptor.RequirePOST
;
...
...
@@ -119,6 +121,9 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas
* @since 1.483
*/
public
static
final
String
ID_DEFAULT
=
"default"
;
@Restricted
(
NoExternalUse
.
class
)
public
static
final
String
ID_UPLOAD
=
"_upload"
;
/**
* {@link ExecutorService} that performs installation.
...
...
@@ -1012,6 +1017,9 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas
}
public
void
run
()
{
if
(
ID_UPLOAD
.
equals
(
site
.
getId
()))
{
return
;
}
LOGGER
.
fine
(
"Doing a connectivity check"
);
try
{
String
connectionCheckUrl
=
site
.
getConnectionCheckUrl
();
...
...
core/src/main/java/hudson/util/CopyOnWriteMap.java
浏览文件 @
37f91746
...
...
@@ -148,6 +148,19 @@ public abstract class CopyOnWriteMap<K,V> implements Map<K,V> {
return
view
.
entrySet
();
}
@Override
public
int
hashCode
()
{
return
copy
().
hashCode
();
}
@SuppressWarnings
(
"EqualsWhichDoesntCheckParameterClass"
)
@Override
public
boolean
equals
(
Object
obj
)
{
return
copy
().
equals
(
obj
);
}
@Override
public
String
toString
()
{
return
copy
().
toString
();
}
/**
* {@link CopyOnWriteMap} backed by {@link HashMap}.
*/
...
...
core/src/main/java/jenkins/model/lazy/Boundary.java
浏览文件 @
37f91746
...
...
@@ -32,7 +32,7 @@ package jenkins.model.lazy;
* this class provides likes of {@code ceil(X,p)} which is the smallest x<sub>i</sub>
* that still satisfies x<sub>i</sub> >= p.
*
* Simiarly, {@link #HIGHER} is the smallest x<sub>i</sub>
* Simi
l
arly, {@link #HIGHER} is the smallest x<sub>i</sub>
* that still satisfies x<sub>i</sub> > p.
*
* @author Kohsuke Kawaguchi
...
...
core/src/test/java/hudson/matrix/CombinationFilterUsingBuildParamsTest.java
0 → 100644
浏览文件 @
37f91746
/*
* The MIT License
*
* Copyright (c) 2012, RedHat 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.matrix
;
import
static
org
.
mockito
.
Matchers
.
anyInt
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
never
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
hudson.ExtensionList
;
import
hudson.matrix.MatrixBuild.MatrixBuildExecution
;
import
hudson.matrix.listeners.MatrixBuildListener
;
import
hudson.model.AbstractItem
;
import
hudson.model.BuildListener
;
import
hudson.model.Cause
;
import
hudson.model.Node
;
import
hudson.model.ParametersAction
;
import
hudson.model.Result
;
import
hudson.model.Run
;
import
hudson.model.StringParameterValue
;
import
java.io.IOException
;
import
java.io.PrintStream
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
jenkins.model.Jenkins
;
import
org.apache.commons.io.output.ByteArrayOutputStream
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.Mock
;
import
org.mockito.MockitoAnnotations
;
import
org.mockito.verification.VerificationMode
;
import
org.powermock.api.mockito.PowerMockito
;
import
org.powermock.core.classloader.annotations.PrepareForTest
;
import
org.powermock.modules.junit4.PowerMockRunner
;
/**
* Make sure that the combination filter schedules correct builds in correct order
*
* @author ogondza
*/
@RunWith
(
PowerMockRunner
.
class
)
@PrepareForTest
(
{
Jenkins
.
class
,
MatrixBuildListener
.
class
,
MatrixProject
.
class
,
AbstractItem
.
class
})
public
class
CombinationFilterUsingBuildParamsTest
{
/**
* Execute releases: experimental, stable, beta, devel
*
* x s b d
* 0.1
* 0.9 * * * *
* 1 * * *
* 2 * *
* 3 *
*/
private
static
final
String
filter
=
String
.
format
(
"(%s) || (%s) || (%s)"
,
"RELEASE == 'stable' && VERSION == '1'"
,
"RELEASE == 'beta' && VERSION >= '1' && VERSION <= '2'"
,
"RELEASE == 'devel' && VERSION >= '1' && VERSION <= '3'"
);
private
static
final
String
touchstoneFilter
=
"VERSION == '0.9'"
;
private
static
final
List
<
String
>
releases
=
Arrays
.
asList
(
"stable"
,
"beta"
,
"devel"
,
"experimental"
);
private
final
Map
<
String
,
MatrixConfiguration
>
confs
=
new
HashMap
<
String
,
MatrixConfiguration
>();
private
final
MatrixExecutionStrategy
strategy
=
new
DefaultMatrixExecutionStrategyImpl
(
true
,
touchstoneFilter
,
Result
.
SUCCESS
,
new
NoopMatrixConfigurationSorter
()
);
private
MatrixProject
project
;
@Mock
private
MatrixBuildExecution
execution
;
@Mock
private
MatrixBuild
build
;
@Mock
private
MatrixRun
run
;
@Mock
private
BuildListener
listener
;
@Mock
private
Jenkins
jenkins
;
@Mock
private
ExtensionList
<
MatrixBuildListener
>
extensions
;
@Before
public
void
setUp
()
throws
Exception
{
MockitoAnnotations
.
initMocks
(
this
);
usingDummyJenkins
();
usingNoListeners
();
usingDummyProject
();
usingDummyExecution
();
withReleaseAxis
(
releases
);
}
@Test
public
void
testCombinationFilterV01
()
throws
InterruptedException
,
IOException
{
givenTheVersionIs
(
"0.1"
);
strategy
.
run
(
execution
);
wasNotBuilt
(
confs
.
get
(
"devel"
));
wasNotBuilt
(
confs
.
get
(
"beta"
));
wasNotBuilt
(
confs
.
get
(
"stable"
));
wasNotBuilt
(
confs
.
get
(
"experimental"
));
}
@Test
public
void
testCombinationFilterV09
()
throws
InterruptedException
,
IOException
{
givenTheVersionIs
(
"0.9"
);
strategy
.
run
(
execution
);
wasBuilt
(
confs
.
get
(
"devel"
));
wasBuilt
(
confs
.
get
(
"beta"
));
wasBuilt
(
confs
.
get
(
"stable"
));
wasBuilt
(
confs
.
get
(
"experimental"
));
}
@Test
public
void
testCombinationFilterV1
()
throws
InterruptedException
,
IOException
{
givenTheVersionIs
(
"1"
);
strategy
.
run
(
execution
);
wasBuilt
(
confs
.
get
(
"devel"
));
wasBuilt
(
confs
.
get
(
"beta"
));
wasBuilt
(
confs
.
get
(
"stable"
));
wasNotBuilt
(
confs
.
get
(
"experimental"
));
}
@Test
public
void
testCombinationFilterV2
()
throws
InterruptedException
,
IOException
{
givenTheVersionIs
(
"2"
);
strategy
.
run
(
execution
);
wasBuilt
(
confs
.
get
(
"devel"
));
wasBuilt
(
confs
.
get
(
"beta"
));
wasNotBuilt
(
confs
.
get
(
"stable"
));
wasNotBuilt
(
confs
.
get
(
"experimental"
));
}
@Test
public
void
testCombinationFilterV3
()
throws
InterruptedException
,
IOException
{
givenTheVersionIs
(
"3"
);
strategy
.
run
(
execution
);
wasBuilt
(
confs
.
get
(
"devel"
));
wasNotBuilt
(
confs
.
get
(
"beta"
));
wasNotBuilt
(
confs
.
get
(
"stable"
));
wasNotBuilt
(
confs
.
get
(
"experimental"
));
}
private
void
usingDummyProject
()
{
project
=
PowerMockito
.
mock
(
MatrixProject
.
class
);
PowerMockito
.
when
(
build
.
getParent
()).
thenReturn
(
project
);
PowerMockito
.
when
(
project
.
getUrl
()).
thenReturn
(
"/my/project/"
);
when
(
project
.
getAxes
()).
thenReturn
(
new
AxisList
(
new
Axis
(
"RELEASE"
,
releases
)));
when
(
project
.
getCombinationFilter
()).
thenReturn
(
filter
);
}
private
void
usingDummyExecution
()
{
when
(
execution
.
getProject
()).
thenReturn
(
project
);
when
(
execution
.
getBuild
()).
thenReturn
(
build
);
when
(
execution
.
getListener
()).
thenReturn
(
listener
);
// throw away logs
when
(
listener
.
getLogger
()).
thenReturn
(
new
PrintStream
(
new
ByteArrayOutputStream
()
));
// Succeed immediately
when
(
run
.
isBuilding
()).
thenReturn
(
false
);
when
(
run
.
getResult
()).
thenReturn
(
Result
.
SUCCESS
);
}
private
void
usingDummyJenkins
()
{
PowerMockito
.
mockStatic
(
Jenkins
.
class
);
when
(
Jenkins
.
getInstance
()).
thenReturn
(
jenkins
);
when
(
jenkins
.
getNodes
()).
thenReturn
(
new
ArrayList
<
Node
>());
}
private
void
usingNoListeners
()
{
when
(
extensions
.
iterator
()).
thenReturn
(
new
ArrayList
<
MatrixBuildListener
>().
iterator
());
when
(
MatrixBuildListener
.
all
()).
thenReturn
(
extensions
);
}
private
void
withReleaseAxis
(
final
List
<
String
>
releases
)
{
for
(
final
String
release:
releases
)
{
confs
.
put
(
release
,
getConfiguration
(
"RELEASE="
+
release
));
}
when
(
execution
.
getActiveConfigurations
()).
thenReturn
(
new
HashSet
<
MatrixConfiguration
>(
confs
.
values
())
);
}
private
MatrixConfiguration
getConfiguration
(
final
String
axis
)
{
final
MatrixConfiguration
conf
=
mock
(
MatrixConfiguration
.
class
);
when
(
conf
.
getParent
()).
thenReturn
(
project
);
when
(
conf
.
getCombination
()).
thenReturn
(
Combination
.
fromString
(
axis
));
when
(
conf
.
getDisplayName
()).
thenReturn
(
axis
);
when
(
conf
.
getUrl
()).
thenReturn
(
axis
);
when
(
conf
.
getBuildByNumber
(
anyInt
())).
thenReturn
(
run
);
return
conf
;
}
private
void
givenTheVersionIs
(
final
String
version
)
{
final
ParametersAction
parametersAction
=
new
ParametersAction
(
new
StringParameterValue
(
"VERSION"
,
version
)
);
when
(
build
.
getAction
(
ParametersAction
.
class
))
.
thenReturn
(
parametersAction
)
;
}
private
void
wasBuilt
(
final
MatrixConfiguration
conf
)
{
wasBuildTimes
(
conf
,
times
(
1
));
}
private
void
wasNotBuilt
(
final
MatrixConfiguration
conf
)
{
wasBuildTimes
(
conf
,
never
());
}
private
void
wasBuildTimes
(
final
MatrixConfiguration
conf
,
final
VerificationMode
mode
)
{
verify
(
conf
,
mode
).
scheduleBuild
(
new
ArrayList
<
MatrixChildAction
>(),
new
Cause
.
UpstreamCause
((
Run
<?,
?>)
build
)
);
}
}
core/src/test/java/hudson/util/CopyOnWriteMapTest.java
浏览文件 @
37f91746
...
...
@@ -25,13 +25,15 @@ package hudson.util;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.TreeMap
;
import
junit.framework.TestCase
;
import
static
org
.
junit
.
Assert
.*;
import
org.junit.Test
;
/**
* @author Mike Dillon, Alan Harder
*/
public
class
CopyOnWriteMapTest
extends
TestCase
{
public
class
CopyOnWriteMapTest
{
public
static
final
class
HashData
{
CopyOnWriteMap
.
Hash
<
String
,
String
>
map1
=
new
CopyOnWriteMap
.
Hash
<
String
,
String
>();
HashMap
<
String
,
String
>
map2
=
new
HashMap
<
String
,
String
>();
...
...
@@ -40,7 +42,7 @@ public class CopyOnWriteMapTest extends TestCase {
/**
* Verify that serialization form of CopyOnWriteMap.Hash and HashMap are the same.
*/
public
void
testH
ashSerialization
()
throws
Exception
{
@Test
public
void
h
ashSerialization
()
throws
Exception
{
HashData
td
=
new
HashData
();
XStream2
xs
=
new
XStream2
();
...
...
@@ -82,7 +84,7 @@ public class CopyOnWriteMapTest extends TestCase {
* Verify that an empty CopyOnWriteMap.Tree can be serialized,
* and that serialization form is the same as a standard TreeMap.
*/
public
void
testT
reeSerialization
()
throws
Exception
{
@Test
public
void
t
reeSerialization
()
throws
Exception
{
TreeData
td
=
new
TreeData
();
XStream2
xs
=
new
XStream2
();
...
...
@@ -111,4 +113,18 @@ public class CopyOnWriteMapTest extends TestCase {
assertEquals
(
"bar1"
,
td2
.
map1
.
get
(
"foo1"
));
assertEquals
(
"bar2"
,
td2
.
map2
.
get
(
"foo2"
));
}
@Test
public
void
equalsHashCodeToString
()
throws
Exception
{
Map
<
String
,
Integer
>
m1
=
new
TreeMap
<
String
,
Integer
>();
Map
<
String
,
Integer
>
m2
=
new
CopyOnWriteMap
.
Tree
<
String
,
Integer
>();
m1
.
put
(
"foo"
,
5
);
m1
.
put
(
"bar"
,
7
);
m2
.
put
(
"foo"
,
5
);
m2
.
put
(
"bar"
,
7
);
assertEquals
(
m1
.
hashCode
(),
m2
.
hashCode
());
assertTrue
(
m2
.
equals
(
m1
));
assertTrue
(
m1
.
equals
(
m2
));
assertEquals
(
m1
.
toString
(),
m2
.
toString
());
}
}
maven-plugin/pom.xml
浏览文件 @
37f91746
...
...
@@ -29,7 +29,7 @@ THE SOFTWARE.
<parent>
<groupId>
org.jenkins-ci.main
</groupId>
<artifactId>
pom
</artifactId>
<version>
1.51
5
-SNAPSHOT
</version>
<version>
1.51
6
-SNAPSHOT
</version>
</parent>
<artifactId>
maven-plugin
</artifactId>
...
...
plugins/pom.xml
浏览文件 @
37f91746
...
...
@@ -11,7 +11,7 @@
<groupId>
org.jenkins-ci.plugins
</groupId>
<artifactId>
plugin
</artifactId>
<name>
Jenkins plugin POM
</name>
<version>
1.51
5
-SNAPSHOT
</version>
<version>
1.51
6
-SNAPSHOT
</version>
<packaging>
pom
</packaging>
<!--
...
...
@@ -38,7 +38,7 @@
<dependency>
<!-- if a plugin wants to depend on the maven plugin, choose the right version automatically -->
<groupId>
org.jenkins-ci.main
</groupId>
<artifactId>
maven-plugin
</artifactId>
<version>
1.51
5
-SNAPSHOT
</version>
<version>
1.51
6
-SNAPSHOT
</version>
</dependency>
</dependencies>
</dependencyManagement>
...
...
@@ -48,25 +48,25 @@
<groupId>
org.jenkins-ci.main
</groupId>
<artifactId>
jenkins-war
</artifactId>
<type>
war
</type>
<version>
1.51
5
-SNAPSHOT
</version>
<version>
1.51
6
-SNAPSHOT
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.jenkins-ci.main
</groupId>
<artifactId>
jenkins-core
</artifactId>
<version>
1.51
5
-SNAPSHOT
</version>
<version>
1.51
6
-SNAPSHOT
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.jenkins-ci.main
</groupId>
<artifactId>
jenkins-test-harness
</artifactId>
<version>
1.51
5
-SNAPSHOT
</version>
<version>
1.51
6
-SNAPSHOT
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.jenkins-ci.main
</groupId>
<artifactId>
ui-samples-plugin
</artifactId>
<version>
1.51
5
-SNAPSHOT
</version>
<version>
1.51
6
-SNAPSHOT
</version>
<scope>
test
</scope>
</dependency>
<!--
...
...
pom.xml
浏览文件 @
37f91746
...
...
@@ -33,7 +33,7 @@ THE SOFTWARE.
<groupId>
org.jenkins-ci.main
</groupId>
<artifactId>
pom
</artifactId>
<version>
1.51
5
-SNAPSHOT
</version>
<version>
1.51
6
-SNAPSHOT
</version>
<packaging>
pom
</packaging>
<name>
Jenkins main module
</name>
...
...
test/pom.xml
浏览文件 @
37f91746
...
...
@@ -29,7 +29,7 @@ THE SOFTWARE.
<parent>
<artifactId>
pom
</artifactId>
<groupId>
org.jenkins-ci.main
</groupId>
<version>
1.51
5
-SNAPSHOT
</version>
<version>
1.51
6
-SNAPSHOT
</version>
</parent>
<groupId>
org.jenkins-ci.main
</groupId>
<artifactId>
jenkins-test-harness
</artifactId>
...
...
test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java
浏览文件 @
37f91746
...
...
@@ -188,6 +188,7 @@ import com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory;
import
com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest
;
import
com.gargoylesoftware.htmlunit.xml.XmlPage
;
import
java.net.HttpURLConnection
;
import
jenkins.model.JenkinsLocationConfiguration
;
/**
* Base class for all Jenkins test cases.
...
...
@@ -330,7 +331,8 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
jenkins
.
servletContext
.
setAttribute
(
"app"
,
jenkins
);
jenkins
.
servletContext
.
setAttribute
(
"version"
,
"?"
);
WebAppMain
.
installExpressionFactory
(
new
ServletContextEvent
(
jenkins
.
servletContext
));
Mailer
.
descriptor
().
setHudsonUrl
(
getURL
().
toExternalForm
());
Mailer
.
descriptor
().
setHudsonUrl
(
getURL
().
toExternalForm
());
// for compatibility only
JenkinsLocationConfiguration
.
get
().
setUrl
(
getURL
().
toString
());
// in case we are using older mailer plugin
// set a default JDK to be the one that the harness is using.
jenkins
.
getJDKs
().
add
(
new
JDK
(
"default"
,
System
.
getProperty
(
"java.home"
)));
...
...
@@ -343,9 +345,6 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
// cause all the descriptors to reload.
// ideally we'd like to reset them to properly emulate the behavior, but that's not possible.
DescriptorImpl
desc
=
Mailer
.
descriptor
();
// prevent NPE with eclipse
if
(
desc
!=
null
)
Mailer
.
descriptor
().
setHudsonUrl
(
null
);
for
(
Descriptor
d
:
jenkins
.
getExtensionList
(
Descriptor
.
class
)
)
d
.
load
();
...
...
test/src/main/java/org/jvnet/hudson/test/JenkinsRule.java
浏览文件 @
37f91746
...
...
@@ -204,6 +204,7 @@ import java.util.logging.Filter;
import
java.util.logging.Level
;
import
java.util.logging.LogRecord
;
import
java.util.logging.Logger
;
import
jenkins.model.JenkinsLocationConfiguration
;
import
org.acegisecurity.GrantedAuthorityImpl
;
import
static
org
.
hamcrest
.
Matchers
.
hasXPath
;
...
...
@@ -351,7 +352,8 @@ public class JenkinsRule implements TestRule, MethodRule, RootAction {
// ideally we'd like to reset them to properly emulate the behavior, but that's not possible.
Mailer
.
DescriptorImpl
desc
=
Mailer
.
descriptor
();
// prevent NPE with eclipse
if
(
desc
!=
null
)
Mailer
.
descriptor
().
setHudsonUrl
(
null
);
if
(
desc
!=
null
)
Mailer
.
descriptor
().
setHudsonUrl
(
getURL
().
toString
());
JenkinsLocationConfiguration
.
get
().
setUrl
(
getURL
().
toString
());
for
(
Descriptor
d
:
jenkins
.
getExtensionList
(
Descriptor
.
class
)
)
d
.
load
();
}
...
...
test/src/test/java/hudson/init/impl/GroovyInitScriptTest.java
0 → 100644
浏览文件 @
37f91746
/*
* The MIT License
*
* Copyright 2013 Jesse Glick.
*
* 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.init.impl
;
import
static
org
.
junit
.
Assert
.*;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.jvnet.hudson.test.Bug
;
import
org.jvnet.hudson.test.JenkinsRule
;
import
org.jvnet.hudson.test.recipes.LocalData
;
public
class
GroovyInitScriptTest
{
@Rule
public
JenkinsRule
j
=
new
JenkinsRule
();
@Bug
(
17933
)
@LocalData
@Test
public
void
errorsHandled
()
throws
Exception
{
assertEquals
(
"true"
,
System
.
getProperty
(
"started"
));
/* XXX Jenkins.logRecords empty during a test, and adding a handler to root logger in JenkinsRule.before() does not work:
assertTrue(log, log.contains("Nonexistent"));
*/
}
}
test/src/test/java/hudson/model/RunTest.java
浏览文件 @
37f91746
...
...
@@ -23,16 +23,26 @@
*/
package
hudson.model
;
import
org.jvnet.hudson.test.HudsonTestCase
;
import
java.net.HttpURLConnection
;
import
java.util.Collection
;
import
java.util.Collections
;
import
static
org
.
junit
.
Assert
.*;
import
java.util.List
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.jvnet.hudson.test.Bug
;
import
org.jvnet.hudson.test.JenkinsRule
;
/**
* @author Kohsuke Kawaguchi
*/
public
class
RunTest
extends
HudsonTestCase
{
public
class
RunTest
{
@Rule
public
JenkinsRule
j
=
new
JenkinsRule
();
private
List
<?
extends
Run
<?,?>.
Artifact
>
createArtifactList
(
String
...
paths
)
throws
Exception
{
FreeStyleProject
prj
=
createFreeStyleProject
();
FreeStyleProject
prj
=
j
.
createFreeStyleProject
();
FreeStyleBuild
r
=
prj
.
scheduleBuild2
(
0
).
get
();
Run
<
FreeStyleProject
,
FreeStyleBuild
>.
ArtifactList
list
=
r
.
new
ArtifactList
();
for
(
String
p
:
paths
)
{
...
...
@@ -42,23 +52,45 @@ public class RunTest extends HudsonTestCase {
return
list
;
}
public
void
testA
rtifactListDisambiguation1
()
throws
Exception
{
@Test
public
void
a
rtifactListDisambiguation1
()
throws
Exception
{
List
<?
extends
Run
<?,
?>.
Artifact
>
a
=
createArtifactList
(
"a/b/c.xml"
,
"d/f/g.xml"
,
"h/i/j.xml"
);
assertEquals
(
a
.
get
(
0
).
getDisplayPath
(),
"c.xml"
);
assertEquals
(
a
.
get
(
1
).
getDisplayPath
(),
"g.xml"
);
assertEquals
(
a
.
get
(
2
).
getDisplayPath
(),
"j.xml"
);
}
public
void
testA
rtifactListDisambiguation2
()
throws
Exception
{
@Test
public
void
a
rtifactListDisambiguation2
()
throws
Exception
{
List
<?
extends
Run
<?,
?>.
Artifact
>
a
=
createArtifactList
(
"a/b/c.xml"
,
"d/f/g.xml"
,
"h/i/g.xml"
);
assertEquals
(
a
.
get
(
0
).
getDisplayPath
(),
"c.xml"
);
assertEquals
(
a
.
get
(
1
).
getDisplayPath
(),
"f/g.xml"
);
assertEquals
(
a
.
get
(
2
).
getDisplayPath
(),
"i/g.xml"
);
}
public
void
testA
rtifactListDisambiguation3
()
throws
Exception
{
@Test
public
void
a
rtifactListDisambiguation3
()
throws
Exception
{
List
<?
extends
Run
<?,
?>.
Artifact
>
a
=
createArtifactList
(
"a.xml"
,
"a/a.xml"
);
assertEquals
(
a
.
get
(
0
).
getDisplayPath
(),
"a.xml"
);
assertEquals
(
a
.
get
(
1
).
getDisplayPath
(),
"a/a.xml"
);
}
@Bug
(
17935
)
@Test
public
void
getDynamicInvisibleTransientAction
()
throws
Exception
{
TransientBuildActionFactory
.
all
().
add
(
0
,
new
TransientBuildActionFactory
()
{
@Override
public
Collection
<?
extends
Action
>
createFor
(
Run
target
)
{
return
Collections
.
singleton
(
new
Action
()
{
@Override
public
String
getDisplayName
()
{
return
"Test"
;
}
@Override
public
String
getIconFileName
()
{
return
null
;
}
@Override
public
String
getUrlName
()
{
return
null
;
}
});
}
});
j
.
assertBuildStatusSuccess
(
j
.
createFreeStyleProject
(
"stuff"
).
scheduleBuild2
(
0
));
j
.
createWebClient
().
assertFails
(
"job/stuff/1/nonexistent"
,
HttpURLConnection
.
HTTP_NOT_FOUND
);
}
}
test/src/test/java/org/jvnet/hudson/main/UseRecipesWithJenkinsRuleTest.java
浏览文件 @
37f91746
...
...
@@ -22,6 +22,7 @@ import org.jvnet.hudson.test.recipes.WithPluginManager;
import
org.xml.sax.SAXException
;
import
com.gargoylesoftware.htmlunit.html.HtmlPage
;
import
jenkins.model.JenkinsLocationConfiguration
;
public
class
UseRecipesWithJenkinsRuleTest
{
...
...
@@ -55,6 +56,10 @@ public class UseRecipesWithJenkinsRuleTest {
assertEquals
(
MyPluginManager
.
class
,
rule
.
jenkins
.
pluginManager
.
getClass
());
}
@Test
public
void
rightURL
()
throws
Exception
{
assertEquals
(
rule
.
getURL
(),
new
URL
(
JenkinsLocationConfiguration
.
get
().
getUrl
()));
}
private
void
verifyNotError
(
WebClient
wc
)
throws
IOException
,
SAXException
{
HtmlPage
p
=
wc
.
goTo
(
"loginError"
);
URL
url
=
p
.
getWebResponse
().
getUrl
();
...
...
test/src/test/resources/hudson/init/impl/GroovyInitScriptTest/errorsHandled.zip
0 → 100644
浏览文件 @
37f91746
此差异由.gitattributes 抑制。
ui-samples-plugin/pom.xml
浏览文件 @
37f91746
...
...
@@ -29,7 +29,7 @@ THE SOFTWARE.
<parent>
<groupId>
org.jenkins-ci.main
</groupId>
<artifactId>
pom
</artifactId>
<version>
1.51
5
-SNAPSHOT
</version>
<version>
1.51
6
-SNAPSHOT
</version>
</parent>
<artifactId>
ui-samples-plugin
</artifactId>
...
...
war/pom.xml
浏览文件 @
37f91746
...
...
@@ -28,7 +28,7 @@ THE SOFTWARE.
<parent>
<groupId>
org.jenkins-ci.main
</groupId>
<artifactId>
pom
</artifactId>
<version>
1.51
5
-SNAPSHOT
</version>
<version>
1.51
6
-SNAPSHOT
</version>
<relativePath>
../pom.xml
</relativePath>
</parent>
...
...
war/src/main/webapp/help/parameter/file.html
浏览文件 @
37f91746
...
...
@@ -8,8 +8,17 @@
place the file.
</li>
<li>
Perform data processing by uploading a dataset.
</li>
</ol>
<p>
It is possible to not submit any file. If it's case and if no file is
already present at the specified location in the workspace, then nothing
happens. If there's already a file present in the workspace, then this file
will be kept as-is.
</p>
<p>
The name of the submitted file is available in the environment variable
whose name is the same as file location. For example, if you set the file
location to be
<tt>
abc.zip
</tt>
, then
<tt>
${abc.zip}
</tt>
would give you
the original file name passed from the browser (such as
<tt>
my.zip
</tt>
.)
The name will not include the directory name portion.
</p>
<p>
File upload is optional. If a user chooses not to upload anything,
Jenkins will simply skips this parameter and will not place
anything (but it also will not delete anything that's already in the
workspace.)
</p>
</div>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录