mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-17 22:12:25 +00:00
commit
20fbd0ca97
852 files changed
+8156
-5596
No files matched your search
Generated
-59
@@ -1,59 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||
<excludeFromCompile>
|
||||
<directory url="file://$PROJECT_DIR$/core/target/generated-sources/annotations" includeSubdirectories="true" />
|
||||
<directory url="file://$PROJECT_DIR$/core/target/generated-test-sources/test-annotations" includeSubdirectories="true" />
|
||||
<directory url="file://$PROJECT_DIR$/cli/target/generated-sources/annotations" includeSubdirectories="true" />
|
||||
<directory url="file://$PROJECT_DIR$/cli/target/generated-test-sources/test-annotations" includeSubdirectories="true" />
|
||||
<directory url="file://$PROJECT_DIR$/maven-plugin/target/generated-sources/annotations" includeSubdirectories="true" />
|
||||
<directory url="file://$PROJECT_DIR$/maven-plugin/target/generated-test-sources/test-annotations" includeSubdirectories="true" />
|
||||
<directory url="file://$PROJECT_DIR$/war/target/generated-sources/annotations" includeSubdirectories="true" />
|
||||
<directory url="file://$PROJECT_DIR$/war/target/generated-test-sources/test-annotations" includeSubdirectories="true" />
|
||||
<directory url="file://$PROJECT_DIR$/test/target/generated-sources/annotations" includeSubdirectories="true" />
|
||||
<directory url="file://$PROJECT_DIR$/test/target/generated-test-sources/test-annotations" includeSubdirectories="true" />
|
||||
</excludeFromCompile>
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
<entry name="?*.properties" />
|
||||
<entry name="?*.xml" />
|
||||
<entry name="?*.gif" />
|
||||
<entry name="?*.png" />
|
||||
<entry name="?*.jpeg" />
|
||||
<entry name="?*.jpg" />
|
||||
<entry name="?*.html" />
|
||||
<entry name="?*.dtd" />
|
||||
<entry name="?*.tld" />
|
||||
<entry name="?*.ftl" />
|
||||
</wildcardResourcePatterns>
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="false">
|
||||
<processorPath useClasspath="true" />
|
||||
</profile>
|
||||
<profile default="false" name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<processorPath useClasspath="true" />
|
||||
<module name="cli" />
|
||||
<module name="jenkins-core" />
|
||||
<module name="jenkins-test-harness" />
|
||||
<module name="jenkins-war" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
<bytecodeTargetLevel>
|
||||
<module name="cli" target="1.6" />
|
||||
<module name="jenkins-core" target="1.6" />
|
||||
<module name="jenkins-test-harness" target="1.6" />
|
||||
<module name="jenkins-war" target="1.6" />
|
||||
<module name="maven-plugin" target="1.6" />
|
||||
<module name="plugin" target="1.5" />
|
||||
<module name="pom" target="1.6" />
|
||||
</bytecodeTargetLevel>
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="MAXIMUM_HEAP_SIZE" value="192" />
|
||||
</component>
|
||||
</project>
|
||||
|
||||
Generated
-12
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="true" defaultCharsetForPropertiesFiles="ISO-8859-1">
|
||||
<file url="file://$PROJECT_DIR$" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/cli" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/core" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/plugins" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/test" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/war" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
|
||||
Generated
-10
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GroovyCompilerConfiguration">
|
||||
<excludes>
|
||||
<directory url="file://$PROJECT_DIR$/maven-plugin/src/main/resources" includeSubdirectories="true" />
|
||||
<directory url="file://$PROJECT_DIR$/core/src/main/resources" includeSubdirectories="true" />
|
||||
</excludes>
|
||||
</component>
|
||||
</project>
|
||||
|
||||
@@ -26,4 +26,3 @@ All about Jenkins CI can be found on our [website]. Follow us on Twitter @[jenki
|
||||
[GitHub]: https://github.com/jenkinsci/jenkins
|
||||
[website]: http://jenkins-ci.org
|
||||
[jenkinsci]: http://twitter.com/jenkinsci
|
||||
|
||||
+232
-7
@@ -54,6 +54,218 @@ Upcoming changes</a>
|
||||
|
||||
<!-- Record your changes in the trunk here. -->
|
||||
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
|
||||
<ul class=image>
|
||||
<li class=>
|
||||
</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.553>What's new in 1.553</a> <!--=DATE=--></h3>
|
||||
<ul class=image>
|
||||
<li class=bug>
|
||||
Build history widget only showed the last day of builds.
|
||||
(Due to JENKINS-20892, even with this fix at most 20 builds are shown.)
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-21159">issue 21159</a>)
|
||||
<li class=bug>
|
||||
Random class loading error mostly known to affect static analysis plugins.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-12124">issue 12124</a>)
|
||||
<li class=bug>
|
||||
After restarting Jenkins, users known only from changelogs could be shown as <code>First Last _first.last@some.org_</code>, breaking mail delivery.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-16332">issue 16332</a>)
|
||||
<li class=bug>
|
||||
CLI <code>build -s -v</code> command caused 100% CPU usage on the master.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-20965">issue 20965</a>)
|
||||
<li class=rfe>
|
||||
Slave started from Java Web Start can now install itself as a systemd service.
|
||||
<li class=rfe>
|
||||
Split the “raw HTML” markup formatter out of core into a bundled plugin.
|
||||
</ul>
|
||||
</div><!--=END=-->
|
||||
<h3><a name=v1.552>What's new in 1.552</a> (2014/02/24)</h3>
|
||||
<ul class=image>
|
||||
<li class=bug>
|
||||
Fixed handling of default JENKINS_HOME when storing CLI credentials
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-21772">issue 21772</a>)
|
||||
<li class=bug>
|
||||
Fixed broken action links on Label page
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-21778">issue 21778</a>)
|
||||
<li class=rfe>
|
||||
Allow Actions to contribute to Labels' main page
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-21777">issue 21777</a>)
|
||||
<li class=bug>
|
||||
Expensive symlink-related calls on Windows can be simplified.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-20534">issue 20534</a>)
|
||||
<li class=bug>
|
||||
Slow rendering of directories with many entries in remote workspaces.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-21780">issue 21780</a>)
|
||||
</ul>
|
||||
<h3><a name=v1.551>What's new in 1.551</a> (2014/02/14)</h3>
|
||||
<ul class=image>
|
||||
<li class='major bug'>
|
||||
Valentine's day security release that contains more than a dozen security fixes.
|
||||
(<a href="https://wiki.jenkins-ci.org/display/SECURITY/Jenkins+Security+Advisory+2014-02-14">security advisory</a>)
|
||||
<li class='major bug'>
|
||||
Regression in Windows slaves since 1.547.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-21373">issue 21373</a>)
|
||||
<li class=bug>
|
||||
Using <code>java -jar jenkins-core.jar folder/external-monitor-job cmd …</code> did not work.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-21525">issue 21525</a>)
|
||||
<li class=bug>
|
||||
Jenkins crash on startup after upgrade from 1.546 to 1.548.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-21474">issue 21474</a>)
|
||||
<li class=bug>
|
||||
f:combobox is narrow.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-21612">issue 21612</a>)
|
||||
<li class=bug>
|
||||
The workspace cleanup thread failed to handle the modern workspace location on master, and mishandled folders.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-21023">issue 21023</a>)
|
||||
<li class=bug>
|
||||
Fixed missing help items on "Configure Global Security" page
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-19832">issue 19832</a>)
|
||||
<li class=rfe>
|
||||
Sort groups on user index page alphabetically.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-21673">issue 21673</a>)
|
||||
<li class=bug>
|
||||
Should not be able to create a job named <code>.</code> (period).
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-21639">issue 21639</a>)
|
||||
<li class=rfe>
|
||||
Plugins implementing "AsyncPeriodicWork" can overwrite default logging level
|
||||
(<a href="https://github.com/jenkinsci/jenkins/pull/1115">pull request #1115</a>)
|
||||
<li class=bug>
|
||||
Wrong log message for out-of-order build record repair.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-20730">issue 20730</a>)
|
||||
<li class=bug>
|
||||
Existing Fingerprint Action is reused and not added a second time.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-17606">issue 19832</a>)
|
||||
<li class=bug>
|
||||
TestObject doesn't replace '%' character
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-21707">issue 21707</a>)
|
||||
<li class=bug>
|
||||
"java -jar jenkins.war" should use unique session cookie for users who run multiple Jenkins on the same host.
|
||||
</ul>
|
||||
<h3><a name=v1.550>What's new in 1.550</a> (2014/02/09)</h3>
|
||||
<ul class=image>
|
||||
<li class=bug>
|
||||
Report number of all jobs as part of usage statistics
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-21448">issue 21448</a>)
|
||||
<li class=bug>
|
||||
Replace description in error dialog instead of appending
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-21457">issue 21457</a>)
|
||||
</ul>
|
||||
<h3><a name=v1.549>What's new in 1.549</a> (2014/01/25)</h3>
|
||||
<ul class=image>
|
||||
<li class=bug>
|
||||
Removing the "keep this build forever" lock on a build should require the DELETE permission.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-16417">issue 16417</a>)
|
||||
<li class=bug>
|
||||
Files added to zip archive are closed properly.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-20345">issue 20345</a>)
|
||||
<li class=bug>
|
||||
Broken CSS when reloading Jenkins after a time of inactivity
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-17526">issue 17526</a>)
|
||||
</ul>
|
||||
<h3><a name=v1.548>What's new in 1.548</a> (2014/01/20)</h3>
|
||||
<ul class=image>
|
||||
<li class=rfe>
|
||||
API for adding actions to a wide class of model objects at once.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-18224">issue 18224</a>)
|
||||
<li class='major rfe'>
|
||||
Added infrastructure for moving items into or out of folders.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-20008">issue 20008</a>)
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-18028">issue 18028</a>)
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-18680">issue 18680</a>)
|
||||
<li class=bug>
|
||||
<i>Apply</i> buttons did not work in Internet Explorer in compatibility mode.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-19826">issue 19826</a>)
|
||||
<li class="major bug">
|
||||
Builds can seem to disappear from a job in a folder if that folder is renamed.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-18694">issue 18694</a>)
|
||||
<li class=bug>
|
||||
<code>/login</code> offers link to <code>/opensearch.xml</code> which anonymous users cannot retrieve.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-21254">issue 21254</a>)
|
||||
<li class=rfe>
|
||||
Added API class <code>SecurityListener</code> to receive login events and similar.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-20999">issue 20999</a>)
|
||||
<li class=rfe>
|
||||
Option to hold lazy-loaded build references strongly, weakly, and more.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-19400">issue 19400</a>)
|
||||
</ul>
|
||||
<h3><a name=v1.547>What's new in 1.547</a> (2014/01/12)</h3>
|
||||
<ul class=image>
|
||||
<li class=rfe>
|
||||
Split Windows slave functionality into its own plugin.
|
||||
<li class="major bug">
|
||||
NPE since 1.545 when using aggregated test result publisher without specifying downstream jobs explicitly.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-18410">issue 18410</a>)
|
||||
<li class=bug>
|
||||
Fixed Trend Graph NPE when there isn't any builds
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-21239">issue 21239</a>)
|
||||
</ul>
|
||||
<h3><a name=v1.546>What's new in 1.546</a> (2014/01/06)</h3>
|
||||
<ul class=image>
|
||||
<li class="major bug">
|
||||
Builds disappear after renaming a job.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-18678">issue 18678</a>)
|
||||
<li class=bug>
|
||||
When clicking <i>Apply</i> to rename a job, tell the user that <i>Save</i> must be used instead.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-17401">issue 17401</a>)
|
||||
<li class="major bug">
|
||||
Exception from XStream running Maven builds on strange Java versions.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-21183">issue 21183</a>)
|
||||
<li class=bug>
|
||||
When clicking <i>Apply</i> results in an exception (error page), show it, rather than creating an empty dialog.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-20772">issue 20772</a>)
|
||||
</ul>
|
||||
<h3><a name=v1.545>What's new in 1.545</a> (2013/12/31)</h3>
|
||||
<ul class=image>
|
||||
<li class=bug>
|
||||
<code>CannotResolveClassException</code> breaks loading of entire containing folder, not just one job.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-20951">issue 20951</a>)
|
||||
<li class=bug>
|
||||
Better robustness against XML deserialization errors.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-21024">issue 21024</a>)
|
||||
<li class=bug>
|
||||
Minimizing disk I/O while loading the <em>names</em> of build records during Jenkins startup.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-21078">issue 21078</a>)
|
||||
<li class=bug>
|
||||
Avoiding serializing the owning build as part of a test result action, as this can lead to errors later.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-18410">issue 18410</a>)
|
||||
</ul>
|
||||
<h3><a name=v1.544>What's new in 1.544</a> (2013/12/15)</h3>
|
||||
<ul class=image>
|
||||
<li class=bug>
|
||||
RingBufferLogHandler throws ArrayIndexOutOfBoundsException after int-overflow.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-9120">issue 9120</a>)
|
||||
<li class=bug>
|
||||
Hudson shows 0GB free space when space available drops below 1GB.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-7776">issue 7776</a>)
|
||||
<li class=rfe>
|
||||
Added filter field for installed plugins tab.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-20219">issue 20219</a>)
|
||||
<li class=bug>
|
||||
<code>groovysh</code> command did not work in authenticated Jenkins instances.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-17929">issue 17929</a>)
|
||||
<li class=bug>
|
||||
Avoid eagerly loading all builds when displaying lists of them (<i>Build History</i> and <i>Build Time Trend</i> UIs).
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-20892">issue 20892</a>)
|
||||
<li class=bug>
|
||||
Error page should be visible even if the anonymous user does not have overall/read access.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-20866">issue 20866</a>)
|
||||
<li class=bug>
|
||||
JavaScript errors when navigating away from a page with a build timeline widget while the timeline is loading.
|
||||
(<a href="https://github.com/jenkinsci/jenkins/pull/1041">pull request 1041</a>)
|
||||
</ul>
|
||||
<h3><a name=v1.543>What's new in 1.543</a> (2013/12/10)</h3>
|
||||
<ul class=image>
|
||||
<li class=bug>
|
||||
Fixed a possible dead lock problem in deleting projects.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-19446">issue 19446</a>)
|
||||
<li class=bug>
|
||||
HTML metacharacters not escaped in log messages.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-20800">issue 20800</a>)
|
||||
</ul>
|
||||
<h3><a name=v1.542>What's new in 1.542</a> (2013/12/02)</h3>
|
||||
<ul class=image>
|
||||
<li class=bug>
|
||||
Improved error diagnosis for jzlib deflate problem.
|
||||
@@ -61,12 +273,17 @@ Upcoming changes</a>
|
||||
<li class=bug>
|
||||
Improved error diagnosis for CLI stream corruption.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-18058">issue 18058</a>)
|
||||
<li class=bug>
|
||||
Don't hold off building until saved for jobs copied from CLI.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-20744">issue 20744</a>)
|
||||
<li class="major rfe">
|
||||
Allow build queue and executor status panes to be collapsed.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-5622">issue 5622</a>)
|
||||
<li class="major bug">
|
||||
Jenkins 1.540 just doesn't boot on Windows at all.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-20630">issue 20630</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.541>What's new in 1.541</a> <!--=DATE=--></h3>
|
||||
<h3><a name=v1.541>What's new in 1.541</a> (2013/11/24)</h3>
|
||||
<ul class=image>
|
||||
<li class=rfe>
|
||||
Add option to create view by copying an existing one.
|
||||
@@ -83,8 +300,10 @@ Upcoming changes</a>
|
||||
<li class=bug>
|
||||
Allow background tasks to run simultaneously, preventing task blockage.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-19622">issue 19622</a>)
|
||||
<li class=bug>
|
||||
Fixed failed tests displaying as Yellow in JUnit history plot
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-7866">issue 7866</a>)
|
||||
</ul>
|
||||
</div><!--=END=-->
|
||||
<h3><a name=v1.540>What's new in 1.540</a> (2013/11/17)</h3>
|
||||
<ul class=image>
|
||||
<li class=bug>
|
||||
@@ -448,8 +667,11 @@ Upcoming changes</a>
|
||||
Ensuring <code>/log/all</code> shows only <code>INFO</code> and above messages, even if custom loggers display <code>FINE</code> or below.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-18959">issue 18959</a>)
|
||||
<li class=rfe>
|
||||
Added a new monitor that detects and fixse out-of-order builds records.
|
||||
Added a new monitor that detects and fixes out-of-order builds records.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-18289">issue 18289</a>)
|
||||
<li class=rfe>
|
||||
Added CLI command <code>create-node</code>.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-18282">issue 18282</a>)
|
||||
<li class=rfe>
|
||||
Can't build using maven 3.1.0
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-15935">issue 15935</a>)
|
||||
@@ -756,6 +978,9 @@ Upcoming changes</a>
|
||||
<li class=bug>
|
||||
NPE from <code>MatrixConfiguration.newBuild</code>.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-17728">issue 17728</a>)
|
||||
<li class=bug>
|
||||
Identify the short name of an uploaded plugin from the manifest, so it does not matter what the filename was.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-4543">issue 4543</a>)
|
||||
<li class='major bug'>
|
||||
NPE configuring Copy Artifact with Maven jobs.
|
||||
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-17402">issue 17402</a>)
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>pom</artifactId>
|
||||
<groupId>org.jenkins-ci.main</groupId>
|
||||
<version>1.542-SNAPSHOT</version>
|
||||
<version>1.554-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>cli</artifactId>
|
||||
|
||||
@@ -261,7 +261,7 @@ public class CLI {
|
||||
/**
|
||||
* If the server advertises CLI endpoint, returns its location.
|
||||
*/
|
||||
private CliPort getCliTcpPort(String url) throws IOException {
|
||||
protected CliPort getCliTcpPort(String url) throws IOException {
|
||||
URL _url = new URL(url);
|
||||
if (_url.getHost()==null || _url.getHost().length()==0) {
|
||||
throw new IOException("Invalid URL: "+url);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# The MIT License
|
||||
#
|
||||
# Copyright (c) 2004-2010, Sun Microsystems, Inc., Reginaldo L. Russinholi, Cleiber Silva
|
||||
# Copyright (c) 2004-2010, Sun Microsystems, Inc., Reginaldo L. Russinholi, Cleiber Silva, Fernando Boaglio
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -21,21 +21,21 @@
|
||||
# THE SOFTWARE.
|
||||
|
||||
# Version mismatch. This CLI cannot work with this Hudson server
|
||||
CLI.VersionMismatch=A vers\ufffdo n\ufffdo coincide. Esta CLI n\ufffdo pode funcionar com este servidor Hudson
|
||||
# Hudson CLI\n\
|
||||
# Usage: java -jar jenkins-cli.jar [-s URL] command [opts...] args...\n\
|
||||
# Options:\n\
|
||||
CLI.VersionMismatch=A vers\u00e3o n\u00e3o coincide. Esta CLI n\u00e3o pode funcionar com este servidor Hudson
|
||||
# Hudson CLI\n\
|
||||
# Usage: java -jar jenkins-cli.jar [-s URL] command [opts...] args...\n\
|
||||
# Options:\n\
|
||||
# \ -s URL : specify the server URL (defaults to the JENKINS_URL env var)\n\
|
||||
# \n\
|
||||
# The available commands depend on the server. Run the 'help' command to\n\
|
||||
# \n\
|
||||
# The available commands depend on the server. Run the 'help' command to\n\
|
||||
# see the list.
|
||||
CLI.Usage=Jenkins CLI\n\
|
||||
Uso: java -jar jenkins-cli.jar [-s URL] comando [op\ufffd\ufffdes...] par\ufffdmetros...\n\
|
||||
Op\ufffd\ufffdes:\n\
|
||||
\ -s URL : a URL do servidor (por padr\ufffdo a vari\ufffdvel de ambiente JENKINS_URL \ufffd usada)\n\
|
||||
Uso: java -jar jenkins-cli.jar [-s URL] comando [op\u00e7\u00f5es...] par\u00e2metros...\n\
|
||||
Op\u00e7\u00f5es:\n\
|
||||
\ -s URL : a URL do servidor (por padr\u00e3o a vari\u00e1vel de ambiente JENKINS_URL \u00e9 usada)\n\
|
||||
\n\
|
||||
Os comandos dispon\ufffdveis dependem do servidor. Execute o comando 'help' para\n\
|
||||
Os comandos dispon\u00edveis dependem do servidor. Execute o comando 'help' para\n\
|
||||
ver a lista.
|
||||
|
||||
# Neither -s nor the JENKINS_URL env var is specified.
|
||||
CLI.NoURL=N\ufffdo foi especificado nem '-s' e nem a vari\ufffdvel de ambiente JENKINS_URL
|
||||
CLI.NoURL=N\u00e3o foi especificado nem '-s' e nem a vari\u00e1vel de ambiente JENKINS_URL
|
||||
+8
-20
@@ -29,7 +29,7 @@ THE SOFTWARE.
|
||||
<parent>
|
||||
<groupId>org.jenkins-ci.main</groupId>
|
||||
<artifactId>pom</artifactId>
|
||||
<version>1.542-SNAPSHOT</version>
|
||||
<version>1.554-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -194,7 +194,7 @@ THE SOFTWARE.
|
||||
<dependency>
|
||||
<groupId>org.jenkins-ci</groupId>
|
||||
<artifactId>annotation-indexer</artifactId>
|
||||
<version>1.6</version>
|
||||
<version>1.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jenkins-ci</groupId>
|
||||
@@ -219,7 +219,7 @@ THE SOFTWARE.
|
||||
<dependency>
|
||||
<groupId>org.jvnet.hudson</groupId>
|
||||
<artifactId>xstream</artifactId>
|
||||
<version>1.4.4-jenkins-4</version>
|
||||
<version>1.4.4-jenkins-5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jfree</groupId>
|
||||
@@ -517,14 +517,9 @@ THE SOFTWARE.
|
||||
<version>1.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jenkins-ci</groupId>
|
||||
<artifactId>jinterop-wmi</artifactId>
|
||||
<version>1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jenkins-ci</groupId>
|
||||
<artifactId>windows-remote-command</artifactId>
|
||||
<version>1.4</version>
|
||||
<groupId>org.kohsuke.jinterop</groupId>
|
||||
<artifactId>j-interop</artifactId>
|
||||
<version>2.0.6-kohsuke-1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.kohsuke.metainf-services</groupId>
|
||||
@@ -558,12 +553,6 @@ THE SOFTWARE.
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.kohsuke</groupId>
|
||||
<artifactId>owasp-html-sanitizer</artifactId>
|
||||
<version>r88</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mindrot</groupId>
|
||||
<artifactId>jbcrypt</artifactId>
|
||||
@@ -583,7 +572,7 @@ THE SOFTWARE.
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
<!-- TODO overridden until Stapler 1.220 -->
|
||||
<!-- Overriding Stapler’s 1.1.3 version to diagnose JENKINS-20618: -->
|
||||
<dependency>
|
||||
<groupId>com.jcraft</groupId>
|
||||
<artifactId>jzlib</artifactId>
|
||||
@@ -640,7 +629,6 @@ THE SOFTWARE.
|
||||
<plugin>
|
||||
<groupId>com.infradna.tool</groupId>
|
||||
<artifactId>bridge-method-injector</artifactId>
|
||||
<version>1.9</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
@@ -787,7 +775,7 @@ THE SOFTWARE.
|
||||
<plugin><!-- generate Jelly tag lib documentation -->
|
||||
<groupId>org.kohsuke.stapler</groupId>
|
||||
<artifactId>maven-stapler-plugin</artifactId>
|
||||
<!-- version specified in grandparent pom -->
|
||||
<version>${maven-stapler-plugin.version}</version>
|
||||
<configuration>
|
||||
<patterns>
|
||||
<pattern>/lib/.*</pattern>
|
||||
|
||||
@@ -56,7 +56,6 @@ import java.io.FileInputStream;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -72,7 +71,6 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ClassicPluginStrategy implements PluginStrategy {
|
||||
private final ClassLoaderReflectionToolkit clt = new ClassLoaderReflectionToolkit();
|
||||
|
||||
/**
|
||||
* Filter for jar files.
|
||||
@@ -272,7 +270,9 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
new DetachedPlugin("ldap","1.467.*","1.0"),
|
||||
new DetachedPlugin("pam-auth","1.467.*","1.0"),
|
||||
new DetachedPlugin("mailer","1.493.*","1.2"),
|
||||
new DetachedPlugin("matrix-auth","1.535.*","1.0.2")
|
||||
new DetachedPlugin("matrix-auth","1.535.*","1.0.2"),
|
||||
new DetachedPlugin("windows-slaves","1.547.*","1.0"),
|
||||
new DetachedPlugin("antisamy-markup-formatter","1.553.*","1.0")
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -567,10 +567,10 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
if (PluginManager.FAST_LOOKUP) {
|
||||
for (PluginWrapper pw : getTransitiveDependencies()) {
|
||||
try {
|
||||
Class c = clt.findLoadedClass(pw.classLoader,name);
|
||||
Class<?> c = ClassLoaderReflectionToolkit._findLoadedClass(pw.classLoader, name);
|
||||
if (c!=null) return c;
|
||||
return clt.findClass(pw.classLoader,name);
|
||||
} catch (InvocationTargetException e) {
|
||||
return ClassLoaderReflectionToolkit._findClass(pw.classLoader, name);
|
||||
} catch (ClassNotFoundException e) {
|
||||
//not found. try next
|
||||
}
|
||||
}
|
||||
@@ -594,15 +594,11 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
HashSet<URL> result = new HashSet<URL>();
|
||||
|
||||
if (PluginManager.FAST_LOOKUP) {
|
||||
try {
|
||||
for (PluginWrapper pw : getTransitiveDependencies()) {
|
||||
Enumeration<URL> urls = clt.findResources(pw.classLoader, name);
|
||||
Enumeration<URL> urls = ClassLoaderReflectionToolkit._findResources(pw.classLoader, name);
|
||||
while (urls != null && urls.hasMoreElements())
|
||||
result.add(urls.nextElement());
|
||||
}
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
} else {
|
||||
for (Dependency dep : dependencies) {
|
||||
PluginWrapper p = pluginManager.getPlugin(dep.shortName);
|
||||
@@ -620,14 +616,10 @@ public class ClassicPluginStrategy implements PluginStrategy {
|
||||
@Override
|
||||
protected URL findResource(String name) {
|
||||
if (PluginManager.FAST_LOOKUP) {
|
||||
try {
|
||||
for (PluginWrapper pw : getTransitiveDependencies()) {
|
||||
URL url = clt.findResource(pw.classLoader,name);
|
||||
URL url = ClassLoaderReflectionToolkit._findResource(pw.classLoader, name);
|
||||
if (url!=null) return url;
|
||||
}
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
} else {
|
||||
for (Dependency dep : dependencies) {
|
||||
PluginWrapper p = pluginManager.getPlugin(dep.shortName);
|
||||
|
||||
@@ -1406,6 +1406,45 @@ public final class FilePath implements Serializable {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of unallocated bytes in the partition of that file.
|
||||
* @since 1.542
|
||||
*/
|
||||
public long getFreeDiskSpace() throws IOException, InterruptedException {
|
||||
return act(new FileCallable<Long>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override public Long invoke(File f, VirtualChannel channel) throws IOException {
|
||||
return f.getFreeSpace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of bytes in the partition of that file.
|
||||
* @since 1.542
|
||||
*/
|
||||
public long getTotalDiskSpace() throws IOException, InterruptedException {
|
||||
return act(new FileCallable<Long>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override public Long invoke(File f, VirtualChannel channel) throws IOException {
|
||||
return f.getTotalSpace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of usable bytes in the partition of that file.
|
||||
* @since 1.542
|
||||
*/
|
||||
public long getUsableDiskSpace() throws IOException, InterruptedException {
|
||||
return act(new FileCallable<Long>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override public Long invoke(File f, VirtualChannel channel) throws IOException {
|
||||
return f.getUsableSpace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the file permission.
|
||||
*
|
||||
|
||||
@@ -44,6 +44,7 @@ import hudson.model.JobPropertyDescriptor;
|
||||
import hudson.model.ModelObject;
|
||||
import hudson.model.Node;
|
||||
import hudson.model.PageDecorator;
|
||||
import hudson.model.PaneStatusProperties;
|
||||
import hudson.model.ParameterDefinition;
|
||||
import hudson.model.ParameterDefinition.ParameterDescriptor;
|
||||
import hudson.model.Project;
|
||||
@@ -149,9 +150,9 @@ import org.kohsuke.stapler.jelly.InternationalizedStringExpression.RawHtmlArgume
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import hudson.util.RunList;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.DoNotUse;
|
||||
import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
|
||||
/**
|
||||
@@ -445,13 +446,14 @@ public class Functions {
|
||||
return formatter.format(r);
|
||||
}
|
||||
|
||||
@Restricted(DoNotUse.class)
|
||||
@Restricted(NoExternalUse.class)
|
||||
public static String[] printLogRecordHtml(LogRecord r, LogRecord prior) {
|
||||
String[] oldParts = prior == null ? new String[4] : logRecordPreformat(prior);
|
||||
String[] newParts = logRecordPreformat(r);
|
||||
for (int i = 0; i < /* not 4 */3; i++) {
|
||||
newParts[i] = "<span class='" + (newParts[i].equals(oldParts[i]) ? "logrecord-metadata-old" : "logrecord-metadata-new") + "'>" + newParts[i] + "</span>";
|
||||
}
|
||||
newParts[3] = Util.xmlEscape(newParts[3]);
|
||||
return newParts;
|
||||
}
|
||||
/**
|
||||
@@ -508,6 +510,15 @@ public class Functions {
|
||||
return c.getValue();
|
||||
}
|
||||
|
||||
private static final Pattern ICON_SIZE = Pattern.compile("\\d+x\\d+");
|
||||
@Restricted(NoExternalUse.class)
|
||||
public static String validateIconSize(String iconSize) throws SecurityException {
|
||||
if (!ICON_SIZE.matcher(iconSize).matches()) {
|
||||
throw new SecurityException("invalid iconSize");
|
||||
}
|
||||
return iconSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the suffix to use for YUI JavaScript.
|
||||
*/
|
||||
@@ -580,6 +591,10 @@ public class Functions {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isCollapsed(String paneId) {
|
||||
return PaneStatusProperties.forCurrentUser().isCollapsed(paneId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the given object in the ancestor list and returns its URL.
|
||||
* This is used to determine the "current" URL assigned to the given object,
|
||||
@@ -1426,7 +1441,8 @@ public class Functions {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sub-list if the given list is bigger than the specified 'maxSize'
|
||||
* Returns a sub-list if the given list is bigger than the specified {@code maxSize}.
|
||||
* <strong>Warning:</strong> do not call this with a {@link RunList}, or you will break lazy loading!
|
||||
*/
|
||||
public static <T> List<T> subList(List<T> base, int maxSize) {
|
||||
if(maxSize<base.size())
|
||||
@@ -1671,6 +1687,9 @@ public class Functions {
|
||||
public String getPasswordValue(Object o) {
|
||||
if (o==null) return null;
|
||||
if (o instanceof Secret) return ((Secret)o).getEncryptedValue();
|
||||
if (getIsUnitTest()) {
|
||||
throw new SecurityException("attempted to render plaintext ‘" + o + "’ in password field; use a getter of type Secret instead");
|
||||
}
|
||||
return o.toString();
|
||||
}
|
||||
|
||||
@@ -1819,8 +1838,8 @@ public class Functions {
|
||||
*/
|
||||
public static String breakableString(final String plain) {
|
||||
|
||||
return plain.replaceAll("(\\p{Punct}+\\w)", "<wbr>$1")
|
||||
.replaceAll("(\\w{10})(?=\\w{3})", "$1<wbr>")
|
||||
return plain.replaceAll("([\\p{Punct}&&[^;]]+\\w)", "<wbr>$1")
|
||||
.replaceAll("([^\\p{Punct}\\s-]{10})(?=[^\\p{Punct}\\s-]{3})", "$1<wbr>")
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ import java.io.Writer;
|
||||
import java.net.HttpRetryException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.nio.charset.Charset;
|
||||
@@ -104,14 +103,14 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
String projectNameEnc = URLEncoder.encode(projectName,"UTF-8").replaceAll("\\+","%20");
|
||||
URL jobURL = new URL(home + "job/" + Util.encode(projectName).replace("/", "/job/") + "/");
|
||||
|
||||
{// check if the job name is correct
|
||||
HttpURLConnection con = open(new URL(home+"job/"+projectNameEnc+"/acceptBuildResult"));
|
||||
HttpURLConnection con = open(new URL(jobURL, "acceptBuildResult"));
|
||||
if (auth != null) con.setRequestProperty("Authorization", auth);
|
||||
con.connect();
|
||||
if(con.getResponseCode()!=200) {
|
||||
System.err.println(projectName+" is not a valid job name on "+home+" ("+con.getResponseMessage()+")");
|
||||
System.err.println(jobURL + " is not a valid external job (" + con.getResponseCode() + " " + con.getResponseMessage() + ")");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -156,11 +155,11 @@ public class Main {
|
||||
w.write("</log><result>"+ret+"</result><duration>"+(System.currentTimeMillis()-start)+"</duration></run>");
|
||||
w.close();
|
||||
|
||||
String location = home+"job/"+projectNameEnc+"/postBuildResult";
|
||||
URL location = new URL(jobURL, "postBuildResult");
|
||||
while(true) {
|
||||
try {
|
||||
// start a remote connection
|
||||
HttpURLConnection con = open(new URL(location));
|
||||
HttpURLConnection con = open(location);
|
||||
if (auth != null) con.setRequestProperty("Authorization", auth);
|
||||
if (crumbField != null && crumbValue != null) {
|
||||
con.setRequestProperty(crumbField, crumbValue);
|
||||
@@ -182,7 +181,7 @@ public class Main {
|
||||
} catch (HttpRetryException e) {
|
||||
if(e.getLocation()!=null) {
|
||||
// retry with the new location
|
||||
location = e.getLocation();
|
||||
location = new URL(e.getLocation());
|
||||
continue;
|
||||
}
|
||||
// otherwise failed for reasons beyond us.
|
||||
|
||||
@@ -82,7 +82,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
@@ -941,8 +940,6 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
|
||||
*/
|
||||
private ConcurrentMap<String, WeakReference<Class>> generatedClasses = new ConcurrentHashMap<String, WeakReference<Class>>();
|
||||
|
||||
private ClassLoaderReflectionToolkit clt = new ClassLoaderReflectionToolkit();
|
||||
|
||||
public UberClassLoader() {
|
||||
super(PluginManager.class.getClassLoader());
|
||||
}
|
||||
@@ -963,11 +960,11 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
|
||||
if (FAST_LOOKUP) {
|
||||
for (PluginWrapper p : activePlugins) {
|
||||
try {
|
||||
Class c = clt.findLoadedClass(p.classLoader,name);
|
||||
Class<?> c = ClassLoaderReflectionToolkit._findLoadedClass(p.classLoader, name);
|
||||
if (c!=null) return c;
|
||||
// calling findClass twice appears to cause LinkageError: duplicate class def
|
||||
return clt.findClass(p.classLoader,name);
|
||||
} catch (InvocationTargetException e) {
|
||||
return ClassLoaderReflectionToolkit._findClass(p.classLoader, name);
|
||||
} catch (ClassNotFoundException e) {
|
||||
//not found. try next
|
||||
}
|
||||
}
|
||||
@@ -987,15 +984,11 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
|
||||
@Override
|
||||
protected URL findResource(String name) {
|
||||
if (FAST_LOOKUP) {
|
||||
try {
|
||||
for (PluginWrapper p : activePlugins) {
|
||||
URL url = clt.findResource(p.classLoader,name);
|
||||
URL url = ClassLoaderReflectionToolkit._findResource(p.classLoader, name);
|
||||
if(url!=null)
|
||||
return url;
|
||||
}
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
} else {
|
||||
for (PluginWrapper p : activePlugins) {
|
||||
URL url = p.classLoader.getResource(name);
|
||||
@@ -1010,13 +1003,9 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
|
||||
protected Enumeration<URL> findResources(String name) throws IOException {
|
||||
List<URL> resources = new ArrayList<URL>();
|
||||
if (FAST_LOOKUP) {
|
||||
try {
|
||||
for (PluginWrapper p : activePlugins) {
|
||||
resources.addAll(Collections.list(clt.findResources(p.classLoader, name)));
|
||||
resources.addAll(Collections.list(ClassLoaderReflectionToolkit._findResources(p.classLoader, name)));
|
||||
}
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
} else {
|
||||
for (PluginWrapper p : activePlugins) {
|
||||
resources.addAll(Collections.list(p.classLoader.getResources(name)));
|
||||
|
||||
@@ -45,6 +45,7 @@ import java.util.jar.Manifest;
|
||||
import java.util.logging.Logger;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.kohsuke.stapler.HttpResponse;
|
||||
import org.kohsuke.stapler.HttpResponses;
|
||||
@@ -213,7 +214,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return getLongName();
|
||||
return StringUtils.removeStart(getLongName(), "Jenkins ");
|
||||
}
|
||||
|
||||
public Api getApi() {
|
||||
@@ -581,7 +582,7 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
|
||||
backupPlugin.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LOGGER.log(WARNING, "Failed to get backup version ", e);
|
||||
LOGGER.log(WARNING, "Failed to get backup version from " + backup, e);
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
package hudson;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.converters.ConversionException;
|
||||
import com.thoughtworks.xstream.XStreamException;
|
||||
import com.thoughtworks.xstream.converters.Converter;
|
||||
import com.thoughtworks.xstream.converters.UnmarshallingContext;
|
||||
import com.thoughtworks.xstream.io.StreamException;
|
||||
@@ -140,9 +140,7 @@ public final class XmlFile {
|
||||
InputStream in = new BufferedInputStream(new FileInputStream(file));
|
||||
try {
|
||||
return xs.fromXML(in);
|
||||
} catch(StreamException e) {
|
||||
throw new IOException("Unable to read "+file,e);
|
||||
} catch(ConversionException e) {
|
||||
} catch (XStreamException e) {
|
||||
throw new IOException("Unable to read "+file,e);
|
||||
} catch(Error e) {// mostly reflection errors
|
||||
throw new IOException("Unable to read "+file,e);
|
||||
@@ -163,9 +161,7 @@ public final class XmlFile {
|
||||
try {
|
||||
// TODO: expose XStream the driver from XStream
|
||||
return xs.unmarshal(DEFAULT_DRIVER.createReader(in), o);
|
||||
} catch (StreamException e) {
|
||||
throw new IOException("Unable to read "+file,e);
|
||||
} catch(ConversionException e) {
|
||||
} catch (XStreamException e) {
|
||||
throw new IOException("Unable to read "+file,e);
|
||||
} catch(Error e) {// mostly reflection errors
|
||||
throw new IOException("Unable to read "+file,e);
|
||||
|
||||
@@ -189,6 +189,8 @@ public abstract class CLICommand implements ExtensionPoint, Cloneable {
|
||||
* The default implementation uses args4j to parse command line arguments and call {@link #run()},
|
||||
* but if that processing is undesirable, subtypes can directly override this method and leave {@link #run()}
|
||||
* to an empty method.
|
||||
* You would however then have to consider {@link CliAuthenticator} and {@link #getTransportAuthentication},
|
||||
* so this is not really recommended.
|
||||
*
|
||||
* @param args
|
||||
* Arguments to the sub command. For example, if the CLI is invoked like "java -jar cli.jar foo bar zot",
|
||||
|
||||
@@ -43,7 +43,11 @@ public class ClientAuthenticationCache implements Serializable {
|
||||
store = (channel==null ? MasterComputer.localChannel : channel).call(new Callable<FilePath, IOException>() {
|
||||
public FilePath call() throws IOException {
|
||||
File home = new File(System.getProperty("user.home"));
|
||||
return new FilePath(new File(home, ".hudson/cli-credentials"));
|
||||
File hudsonHome = new File(home, ".hudson");
|
||||
if (hudsonHome.exists()) {
|
||||
return new FilePath(new File(hudsonHome, "cli-credentials"));
|
||||
}
|
||||
return new FilePath(new File(home, ".jenkins/cli-credentials"));
|
||||
}
|
||||
});
|
||||
if (store.exists()) {
|
||||
|
||||
@@ -75,7 +75,7 @@ public class CopyJobCommand extends CLICommand {
|
||||
dst = dst.substring(i + 1);
|
||||
}
|
||||
|
||||
ig.copy(src,dst);
|
||||
ig.copy(src,dst).save();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ public class CreateJobCommand extends CLICommand {
|
||||
name = name.substring(i + 1);
|
||||
}
|
||||
|
||||
Jenkins.checkGoodName(name);
|
||||
ig.createProjectFromXML(name, stdin);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -34,14 +34,15 @@ import org.codehaus.groovy.tools.shell.Shell;
|
||||
import org.codehaus.groovy.tools.shell.util.XmlCommandRegistrar;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.io.PrintStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import jline.UnsupportedTerminal;
|
||||
import jline.Terminal;
|
||||
import org.kohsuke.args4j.Argument;
|
||||
|
||||
/**
|
||||
* Executes Groovy shell.
|
||||
@@ -55,11 +56,12 @@ public class GroovyshCommand extends CLICommand {
|
||||
return Messages.GroovyshCommand_ShortDescription();
|
||||
}
|
||||
|
||||
@Argument(metaVar="ARGS") public List<String> args = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
public int main(List<String> args, Locale locale, InputStream stdin, PrintStream stdout, PrintStream stderr) {
|
||||
protected int run() {
|
||||
// this allows the caller to manipulate the JVM state, so require the admin privilege.
|
||||
Jenkins.getInstance().checkPermission(Jenkins.RUN_SCRIPTS);
|
||||
// TODO JENKINS-17929 this does not work
|
||||
|
||||
// this being remote means no jline capability is available
|
||||
System.setProperty("jline.terminal", UnsupportedTerminal.class.getName());
|
||||
@@ -122,7 +124,4 @@ public class GroovyshCommand extends CLICommand {
|
||||
return shell;
|
||||
}
|
||||
|
||||
protected int run() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
@@ -37,9 +37,7 @@ public class SetBuildParameterCommand extends CommandDuringBuild {
|
||||
|
||||
ParametersAction a = r.getAction(ParametersAction.class);
|
||||
if (a!=null) {
|
||||
ParametersAction b = a.createUpdated(Collections.singleton(p));
|
||||
r.addAction(b);
|
||||
r.getActions().remove(a);
|
||||
r.replaceAction(a.createUpdated(Collections.singleton(p)));
|
||||
} else {
|
||||
r.addAction(new ParametersAction(p));
|
||||
}
|
||||
|
||||
@@ -25,12 +25,10 @@ package hudson.diagnosis;
|
||||
|
||||
import hudson.Extension;
|
||||
import hudson.model.AdministrativeMonitor;
|
||||
import hudson.util.FormValidation;
|
||||
import org.kohsuke.stapler.HttpRedirect;
|
||||
import org.kohsuke.stapler.HttpResponse;
|
||||
import org.kohsuke.stapler.HttpResponses;
|
||||
import org.kohsuke.stapler.QueryParameter;
|
||||
import org.kohsuke.stapler.WebMethod;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -54,12 +52,15 @@ public class ReverseProxySetupMonitor extends AdministrativeMonitor {
|
||||
}
|
||||
|
||||
public HttpResponse doTest() {
|
||||
return new HttpRedirect("test-for-reverse-proxy-setup");
|
||||
return new HttpRedirect("testForReverseProxySetup/a%2Fb/");
|
||||
}
|
||||
|
||||
@WebMethod(name="test-for-reverse-proxy-setup")
|
||||
public FormValidation doFoo() {
|
||||
return FormValidation.ok();
|
||||
public void getTestForReverseProxySetup(String rest) {
|
||||
if (rest.equals("a/b")) {
|
||||
throw HttpResponses.ok();
|
||||
} else {
|
||||
throw HttpResponses.errorWithoutStack(404, "expected a/b but got " + rest);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -84,14 +84,38 @@ public class LogRecorder extends AbstractModelObject implements Saveable {
|
||||
|
||||
public final CopyOnWriteList<Target> targets = new CopyOnWriteList<Target>();
|
||||
|
||||
private transient /*almost final*/ RingBufferLogHandler handler = new RingBufferLogHandler() {
|
||||
@Restricted(NoExternalUse.class)
|
||||
Target[] orderedTargets() {
|
||||
// will contain targets ordered by reverse name length (place specific targets at the beginning)
|
||||
Target[] ts = targets.toArray(new Target[]{});
|
||||
|
||||
Arrays.sort(ts, new Comparator<Target>() {
|
||||
public int compare(Target left, Target right) {
|
||||
return right.getName().length() - left.getName().length();
|
||||
}
|
||||
});
|
||||
|
||||
return ts;
|
||||
}
|
||||
|
||||
@Restricted(NoExternalUse.class)
|
||||
transient /*almost final*/ RingBufferLogHandler handler = new RingBufferLogHandler() {
|
||||
@Override
|
||||
public void publish(LogRecord record) {
|
||||
for (Target t : targets) {
|
||||
if(t.includes(record)) {
|
||||
super.publish(record);
|
||||
return;
|
||||
for (Target t : orderedTargets()) {
|
||||
Boolean match = t.matches(record);
|
||||
if (match == null) {
|
||||
// domain does not match, so continue looking
|
||||
continue;
|
||||
}
|
||||
|
||||
if (match.booleanValue()) {
|
||||
// most specific logger matches, so publish
|
||||
super.publish(record);
|
||||
}
|
||||
// most specific logger does not match, so don't publish
|
||||
// allows reducing log level for more specific loggers
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -123,6 +147,11 @@ public class LogRecorder extends AbstractModelObject implements Saveable {
|
||||
return Level.parse(String.valueOf(level));
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean includes(LogRecord r) {
|
||||
if(r.getLevel().intValue() < level)
|
||||
return false; // below the threshold
|
||||
@@ -136,6 +165,21 @@ public class LogRecorder extends AbstractModelObject implements Saveable {
|
||||
return rest.startsWith(".") || rest.length()==0;
|
||||
}
|
||||
|
||||
public Boolean matches(LogRecord r) {
|
||||
boolean levelSufficient = r.getLevel().intValue() >= level;
|
||||
if (name.length() == 0) {
|
||||
return Boolean.valueOf(levelSufficient); // include if level matches
|
||||
}
|
||||
String logName = r.getLoggerName();
|
||||
if(logName==null || !logName.startsWith(name))
|
||||
return null; // not in the domain of this logger
|
||||
String rest = logName.substring(name.length());
|
||||
if (rest.startsWith(".") || rest.length()==0) {
|
||||
return Boolean.valueOf(levelSufficient); // include if level matches
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Logger getLogger() {
|
||||
if (logger == null) {
|
||||
logger = Logger.getLogger(name);
|
||||
@@ -299,7 +343,7 @@ public class LogRecorder extends AbstractModelObject implements Saveable {
|
||||
* The file we save our configuration.
|
||||
*/
|
||||
private XmlFile getConfigFile() {
|
||||
return new XmlFile(XSTREAM, new File(Jenkins.getInstance().getRootDir(),"log/"+name+".xml"));
|
||||
return new XmlFile(XSTREAM, new File(LogRecorderManager.configDir(), name + ".xml"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,6 @@ import hudson.model.RSS;
|
||||
import hudson.util.CopyOnWriteMap;
|
||||
import jenkins.model.JenkinsLocationConfiguration;
|
||||
import jenkins.model.ModelObjectWithChildren;
|
||||
import jenkins.model.ModelObjectWithContextMenu;
|
||||
import jenkins.model.ModelObjectWithContextMenu.ContextMenu;
|
||||
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
||||
import org.kohsuke.stapler.QueryParameter;
|
||||
@@ -52,7 +51,6 @@ import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
@@ -84,12 +82,16 @@ public class LogRecorderManager extends AbstractModelObject implements ModelObje
|
||||
return logRecorders.get(token);
|
||||
}
|
||||
|
||||
static File configDir() {
|
||||
return new File(Jenkins.getInstance().getRootDir(), "log");
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the configuration from disk.
|
||||
*/
|
||||
public void load() throws IOException {
|
||||
logRecorders.clear();
|
||||
File dir = new File(Jenkins.getInstance().getRootDir(), "log");
|
||||
File dir = configDir();
|
||||
File[] files = dir.listFiles((FileFilter)new WildcardFileFilter("*.xml"));
|
||||
if(files==null) return;
|
||||
for (File child : files) {
|
||||
|
||||
@@ -1,241 +0,0 @@
|
||||
// Copyright (c) 2011, Mike Samuel
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// Neither the name of the OWASP nor the names of its contributors may
|
||||
// be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
// COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
package hudson.markup;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.io.CharStreams;
|
||||
import org.owasp.html.Handler;
|
||||
import org.owasp.html.HtmlPolicyBuilder;
|
||||
import org.owasp.html.HtmlSanitizer;
|
||||
import org.owasp.html.HtmlSanitizer.Policy;
|
||||
import org.owasp.html.HtmlStreamEventReceiver;
|
||||
import org.owasp.html.HtmlStreamRenderer;
|
||||
import org.owasp.html.PolicyFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Based on the
|
||||
* <a href="http://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project#Stage_2_-_Choosing_a_base_policy_file">AntiSamy EBay example</a>.
|
||||
* <blockquote>
|
||||
* eBay (http://www.ebay.com/) is the most popular online auction site in the
|
||||
* universe, as far as I can tell. It is a public site so anyone is allowed to
|
||||
* post listings with rich HTML content. It's not surprising that given the
|
||||
* attractiveness of eBay as a target that it has been subject to a few complex
|
||||
* XSS attacks. Listings are allowed to contain much more rich content than,
|
||||
* say, Slashdot- so it's attack surface is considerably larger. The following
|
||||
* tags appear to be accepted by eBay (they don't publish rules):
|
||||
* {@code <a>},...
|
||||
* </blockquote>
|
||||
*/
|
||||
public class EbayPolicy {
|
||||
|
||||
// Some common regular expression definitions.
|
||||
|
||||
// The 16 colors defined by the HTML Spec (also used by the CSS Spec)
|
||||
private static final Pattern COLOR_NAME = Pattern.compile(
|
||||
"(?:aqua|black|blue|fuchsia|gray|grey|green|lime|maroon|navy|olive|purple"
|
||||
+ "|red|silver|teal|white|yellow)");
|
||||
|
||||
// HTML/CSS Spec allows 3 or 6 digit hex to specify color
|
||||
private static final Pattern COLOR_CODE = Pattern.compile(
|
||||
"(?:#(?:[0-9a-fA-F]{3}(?:[0-9a-fA-F]{3})?))");
|
||||
|
||||
private static final Pattern NUMBER_OR_PERCENT = Pattern.compile(
|
||||
"[0-9]+%?");
|
||||
private static final Pattern PARAGRAPH = Pattern.compile(
|
||||
"(?:[\\p{L}\\p{N},'\\.\\s\\-_\\(\\)]|&[0-9]{2};)*");
|
||||
private static final Pattern HTML_ID = Pattern.compile(
|
||||
"[a-zA-Z0-9\\:\\-_\\.]+");
|
||||
// force non-empty with a '+' at the end instead of '*'
|
||||
private static final Pattern HTML_TITLE = Pattern.compile(
|
||||
"[\\p{L}\\p{N}\\s\\-_',:\\[\\]!\\./\\\\\\(\\)&]*");
|
||||
private static final Pattern HTML_CLASS = Pattern.compile(
|
||||
"[a-zA-Z0-9\\s,\\-_]+");
|
||||
|
||||
private static final Pattern ONSITE_URL = Pattern.compile(
|
||||
"(?:[\\p{L}\\p{N}\\\\\\.\\#@\\$%\\+&;\\-_~,\\?=/!]+|\\#(\\w)+)");
|
||||
private static final Pattern OFFSITE_URL = Pattern.compile(
|
||||
"\\s*(?:(?:ht|f)tps?://|mailto:)[\\p{L}\\p{N}]"
|
||||
+ "[\\p{L}\\p{N}\\p{Zs}\\.\\#@\\$%\\+&;:\\-_~,\\?=/!\\(\\)]*\\s*");
|
||||
|
||||
private static final Pattern NUMBER = Pattern.compile(
|
||||
"[+-]?(?:(?:[0-9]+(?:\\.[0-9]*)?)|\\.[0-9]+)");
|
||||
|
||||
private static final Pattern NAME = Pattern.compile("[a-zA-Z0-9\\-_\\$]+");
|
||||
|
||||
private static final Pattern ALIGN = Pattern.compile(
|
||||
"(?i)center|left|right|justify|char");
|
||||
|
||||
private static final Pattern VALIGN = Pattern.compile(
|
||||
"(?i)baseline|bottom|middle|top");
|
||||
|
||||
private static final Predicate<String> COLOR_NAME_OR_COLOR_CODE
|
||||
= new Predicate<String>() {
|
||||
public boolean apply(String s) {
|
||||
return COLOR_NAME.matcher(s).matches()
|
||||
|| COLOR_CODE.matcher(s).matches();
|
||||
}
|
||||
};
|
||||
|
||||
private static final Predicate<String> ONSITE_OR_OFFSITE_URL
|
||||
= new Predicate<String>() {
|
||||
public boolean apply(String s) {
|
||||
return ONSITE_URL.matcher(s).matches()
|
||||
|| OFFSITE_URL.matcher(s).matches();
|
||||
}
|
||||
};
|
||||
|
||||
private static final Pattern HISTORY_BACK = Pattern.compile(
|
||||
"(?:javascript:)?\\Qhistory.go(-1)\\E");
|
||||
|
||||
private static final Pattern ONE_CHAR = Pattern.compile(
|
||||
".?", Pattern.DOTALL);
|
||||
|
||||
|
||||
public static final PolicyFactory POLICY_DEFINITION;
|
||||
|
||||
static {
|
||||
POLICY_DEFINITION = new HtmlPolicyBuilder()
|
||||
.allowAttributes("id").matching(HTML_ID).globally()
|
||||
.allowAttributes("class").matching(HTML_CLASS).globally()
|
||||
.allowAttributes("lang").matching(Pattern.compile("[a-zA-Z]{2,20}"))
|
||||
.globally()
|
||||
.allowAttributes("title").matching(HTML_TITLE).globally()
|
||||
.allowStyling()
|
||||
.allowAttributes("align").matching(ALIGN).onElements("p")
|
||||
.allowAttributes("for").matching(HTML_ID).onElements("label")
|
||||
.allowAttributes("color").matching(COLOR_NAME_OR_COLOR_CODE)
|
||||
.onElements("font")
|
||||
.allowAttributes("face")
|
||||
.matching(Pattern.compile("[\\w;, \\-]+"))
|
||||
.onElements("font")
|
||||
.allowAttributes("size").matching(NUMBER).onElements("font")
|
||||
.allowAttributes("href").matching(ONSITE_OR_OFFSITE_URL)
|
||||
.onElements("a")
|
||||
.allowStandardUrlProtocols()
|
||||
.allowAttributes("nohref").onElements("a")
|
||||
.allowAttributes("name").matching(NAME).onElements("a")
|
||||
.allowAttributes(
|
||||
"onfocus", "onblur", "onclick", "onmousedown", "onmouseup")
|
||||
.matching(HISTORY_BACK).onElements("a")
|
||||
.requireRelNofollowOnLinks()
|
||||
.allowAttributes("src").matching(ONSITE_OR_OFFSITE_URL)
|
||||
.onElements("img")
|
||||
.allowAttributes("name").matching(NAME)
|
||||
.onElements("img")
|
||||
.allowAttributes("alt").matching(PARAGRAPH)
|
||||
.onElements("img")
|
||||
.allowAttributes("border", "hspace", "vspace").matching(NUMBER)
|
||||
.onElements("img")
|
||||
.allowAttributes("border", "cellpadding", "cellspacing")
|
||||
.matching(NUMBER).onElements("table")
|
||||
.allowAttributes("bgcolor").matching(COLOR_NAME_OR_COLOR_CODE)
|
||||
.onElements("table")
|
||||
.allowAttributes("background").matching(ONSITE_URL)
|
||||
.onElements("table")
|
||||
.allowAttributes("align").matching(ALIGN)
|
||||
.onElements("table")
|
||||
.allowAttributes("noresize").matching(Pattern.compile("(?i)noresize"))
|
||||
.onElements("table")
|
||||
.allowAttributes("background").matching(ONSITE_URL)
|
||||
.onElements("td", "th", "tr")
|
||||
.allowAttributes("bgcolor").matching(COLOR_NAME_OR_COLOR_CODE)
|
||||
.onElements("td", "th")
|
||||
.allowAttributes("abbr").matching(PARAGRAPH)
|
||||
.onElements("td", "th")
|
||||
.allowAttributes("axis", "headers").matching(NAME)
|
||||
.onElements("td", "th")
|
||||
.allowAttributes("scope")
|
||||
.matching(Pattern.compile("(?i)(?:row|col)(?:group)?"))
|
||||
.onElements("td", "th")
|
||||
.allowAttributes("nowrap")
|
||||
.onElements("td", "th")
|
||||
.allowAttributes("height", "width").matching(NUMBER_OR_PERCENT)
|
||||
.onElements("table", "td", "th", "tr", "img")
|
||||
.allowAttributes("align").matching(ALIGN)
|
||||
.onElements("thead", "tbody", "tfoot", "img",
|
||||
"td", "th", "tr", "colgroup", "col")
|
||||
.allowAttributes("valign").matching(VALIGN)
|
||||
.onElements("thead", "tbody", "tfoot",
|
||||
"td", "th", "tr", "colgroup", "col")
|
||||
.allowAttributes("charoff").matching(NUMBER_OR_PERCENT)
|
||||
.onElements("td", "th", "tr", "colgroup", "col",
|
||||
"thead", "tbody", "tfoot")
|
||||
.allowAttributes("char").matching(ONE_CHAR)
|
||||
.onElements("td", "th", "tr", "colgroup", "col",
|
||||
"thead", "tbody", "tfoot")
|
||||
.allowAttributes("colspan", "rowspan").matching(NUMBER)
|
||||
.onElements("td", "th")
|
||||
.allowAttributes("span", "width").matching(NUMBER_OR_PERCENT)
|
||||
.onElements("colgroup", "col")
|
||||
.allowElements(
|
||||
"label", "noscript", "h1", "h2", "h3", "h4", "h5", "h6",
|
||||
"p", "i", "b", "u", "strong", "em", "small", "big", "pre", "code",
|
||||
"cite", "samp", "sub", "sup", "strike", "center", "blockquote",
|
||||
"hr", "br", "col", "font", "map", "span", "div", "img",
|
||||
"ul", "ol", "li", "dd", "dt", "dl", "tbody", "thead", "tfoot",
|
||||
"table", "td", "th", "tr", "colgroup", "fieldset", "legend")
|
||||
.toFactory();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
if (args.length != 0) {
|
||||
System.err.println("Reads from STDIN and writes to STDOUT");
|
||||
System.exit(-1);
|
||||
}
|
||||
System.err.println("[Reading from STDIN]");
|
||||
// Fetch the HTML to sanitize.
|
||||
String html = CharStreams.toString(
|
||||
new InputStreamReader(System.in, Charsets.UTF_8));
|
||||
// Set up an output channel to receive the sanitized HTML.
|
||||
HtmlStreamRenderer renderer = HtmlStreamRenderer.create(
|
||||
System.out,
|
||||
// Receives notifications on a failure to write to the output.
|
||||
new Handler<IOException>() {
|
||||
public void handle(IOException ex) {
|
||||
Throwables.propagate(ex); // System.out suppresses IOExceptions
|
||||
}
|
||||
},
|
||||
// Our HTML parser is very lenient, but this receives notifications on
|
||||
// truly bizarre inputs.
|
||||
new Handler<String>() {
|
||||
public void handle(String x) {
|
||||
throw new AssertionError(x);
|
||||
}
|
||||
}
|
||||
);
|
||||
// Use the policy defined above to sanitize the HTML.
|
||||
HtmlSanitizer.sanitize(html, POLICY_DEFINITION.apply(renderer));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2011 Seiji Sogabe
|
||||
*
|
||||
* 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.markup;
|
||||
|
||||
import hudson.Extension;
|
||||
import hudson.Util;
|
||||
import hudson.markup.MarkupFormatter;
|
||||
import hudson.markup.MarkupFormatterDescriptor;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import org.kohsuke.stapler.DataBoundConstructor;
|
||||
|
||||
/**
|
||||
* @link MarkupFormatter} that treats the input as the escaped html.
|
||||
*
|
||||
* @author Seiji Sogabe
|
||||
* @since 1.553
|
||||
*/
|
||||
public class EscapedMarkupFormatter extends MarkupFormatter {
|
||||
|
||||
@DataBoundConstructor
|
||||
public EscapedMarkupFormatter() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(String markup, Writer output) throws IOException {
|
||||
output.write(Util.escape(markup));
|
||||
}
|
||||
|
||||
@Extension
|
||||
public static class DescriptorImpl extends MarkupFormatterDescriptor {
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return Messages.EscapedMarkupFormatter_DisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package hudson.markup;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import org.owasp.html.HtmlPolicyBuilder;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* {@link HtmlPolicyBuilder} with additional
|
||||
* functions to simplify transcoding policy definition
|
||||
* from OWASP AntiSamy policy files.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
class HtmlPolicyBuilder2 extends HtmlPolicyBuilder {
|
||||
public void tag(String names, Object... attributes) {
|
||||
String[] tags = names.split(",");
|
||||
for (int i=0; i<attributes.length; i++) {
|
||||
String attName = (String)attributes[i];
|
||||
if (i+1<attributes.length) {
|
||||
Object operand = attributes[i+1];
|
||||
if (operand instanceof Predicate) {
|
||||
Predicate p = (Predicate) operand;
|
||||
allowAttributes(attName).matching(p).onElements(tags);
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (operand instanceof Pattern) {
|
||||
Pattern p = (Pattern) operand;
|
||||
allowAttributes(attName).matching(p).onElements(tags);
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// operand-less
|
||||
allowAttributes(attName).onElements(tags);
|
||||
}
|
||||
allowElements(tags);
|
||||
}
|
||||
}
|
||||
@@ -26,16 +26,13 @@ package hudson.markup;
|
||||
import hudson.ExtensionPoint;
|
||||
import hudson.model.AbstractDescribableImpl;
|
||||
import hudson.util.HttpResponses;
|
||||
import jenkins.model.Jenkins;
|
||||
import org.kohsuke.stapler.HttpResponse;
|
||||
import org.kohsuke.stapler.QueryParameter;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import javax.annotation.CheckForNull;
|
||||
import javax.annotation.Nonnull;
|
||||
import org.kohsuke.stapler.HttpResponse;
|
||||
import org.kohsuke.stapler.QueryParameter;
|
||||
|
||||
/**
|
||||
* Generalization of a function that takes text with some markup and converts that to HTML.
|
||||
@@ -72,9 +69,9 @@ public abstract class MarkupFormatter extends AbstractDescribableImpl<MarkupForm
|
||||
* @param output
|
||||
* Formatted HTML should be sent to this output.
|
||||
*/
|
||||
public abstract void translate(String markup, Writer output) throws IOException;
|
||||
public abstract void translate(@CheckForNull String markup, @Nonnull Writer output) throws IOException;
|
||||
|
||||
public final String translate(String markup) throws IOException {
|
||||
public final @Nonnull String translate(@CheckForNull String markup) throws IOException {
|
||||
StringWriter w = new StringWriter();
|
||||
translate(markup,w);
|
||||
return w.toString();
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
package hudson.markup;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Throwables;
|
||||
import org.owasp.html.Handler;
|
||||
import org.owasp.html.HtmlSanitizer;
|
||||
import org.owasp.html.HtmlStreamRenderer;
|
||||
import org.owasp.html.PolicyFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Policy definition based on OWASP AntiSamy MySpace policy.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see <a href="https://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project#Stage_2_-_Choosing_a_base_policy_file">OWASP AntiSamy MySpace Policy</a>
|
||||
*/
|
||||
public class MyspacePolicy {
|
||||
public static final PolicyFactory POLICY_DEFINITION;
|
||||
|
||||
private static final Pattern ONSITE_URL = Pattern.compile(
|
||||
"(?:[\\p{L}\\p{N}\\\\\\.\\#@\\$%\\+&;\\-_~,\\?=/!]+|\\#(\\w)+)");
|
||||
private static final Pattern OFFSITE_URL = Pattern.compile(
|
||||
"\\s*(?:(?:ht|f)tps?://|mailto:)[\\p{L}\\p{N}]"
|
||||
+ "[\\p{L}\\p{N}\\p{Zs}\\.\\#@\\$%\\+&;:\\-_~,\\?=/!\\(\\)]*\\s*");
|
||||
|
||||
private static final Predicate<String> ONSITE_OR_OFFSITE_URL
|
||||
= new Predicate<String>() {
|
||||
public boolean apply(String s) {
|
||||
return ONSITE_URL.matcher(s).matches()
|
||||
|| OFFSITE_URL.matcher(s).matches();
|
||||
}
|
||||
};
|
||||
|
||||
static {
|
||||
POLICY_DEFINITION = new HtmlPolicyBuilder2() {{
|
||||
allowAttributes("id","class","lang","title",
|
||||
"alt","style","media","href","name","shape",
|
||||
"border","cellpadding","cellspacing","colspan","rowspan",
|
||||
"background","bgcolor","abbr","headers","charoff","char",
|
||||
"aixs","nowrap","width","height","align","valign","scope",
|
||||
"tabindex","disabled","readonly","accesskey","size",
|
||||
"autocomplete","rows","cols").globally();
|
||||
|
||||
disallowElements(
|
||||
// I'm allowing iframe
|
||||
"script","noscript",/*"iframe",*/"frameset","frame");
|
||||
|
||||
tag("label", "for");
|
||||
tag("form", "action",ONSITE_OR_OFFSITE_URL,
|
||||
"method");
|
||||
tag("button", "value", "type");
|
||||
tag("input", "maxlength","checked",
|
||||
"src",ONSITE_OR_OFFSITE_URL,
|
||||
"usemap",ONSITE_URL,
|
||||
"type","value");
|
||||
tag("select", "multiple");
|
||||
tag("option", "value","label","selected");
|
||||
tag("textarea");
|
||||
tag("h1,h2,h3,h4,h5,h6,p,i,b,u,strong,em,small,big,pre,code,cite,samp,sub,sup,strike,center,blockquote");
|
||||
tag("hr,br,col");
|
||||
tag("font", "color", "face", "size");
|
||||
tag("a", "nohref","rel");
|
||||
tag("style", "type");
|
||||
tag("span,div");
|
||||
tag("img", "src",ONSITE_OR_OFFSITE_URL,
|
||||
"hspace","vspace");
|
||||
tag("iframe", "src");
|
||||
tag("ul,ol,li,dd,dl,dt,thead,tbody,tfoot");
|
||||
tag("table", "noresize");
|
||||
tag("td,th,tr");
|
||||
tag("colgroup", "span");
|
||||
tag("col", "span");
|
||||
tag("fieldset,legend");
|
||||
allowStandardUrlProtocols();
|
||||
}}.toFactory();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
// Fetch the HTML to sanitize.
|
||||
String html = "<a href='http://www.google.com/'>Google</a><img src='http://www.yahoo.com'>";
|
||||
// Set up an output channel to receive the sanitized HTML.
|
||||
HtmlStreamRenderer renderer = HtmlStreamRenderer.create(
|
||||
System.out,
|
||||
// Receives notifications on a failure to write to the output.
|
||||
new Handler<IOException>() {
|
||||
public void handle(IOException ex) {
|
||||
Throwables.propagate(ex); // System.out suppresses IOExceptions
|
||||
}
|
||||
},
|
||||
// Our HTML parser is very lenient, but this receives notifications on
|
||||
// truly bizarre inputs.
|
||||
new Handler<String>() {
|
||||
public void handle(String x) {
|
||||
throw new AssertionError(x);
|
||||
}
|
||||
}
|
||||
);
|
||||
// Use the policy defined above to sanitize the HTML.
|
||||
HtmlSanitizer.sanitize(html, POLICY_DEFINITION.apply(renderer));
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package hudson.markup;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import hudson.Extension;
|
||||
import org.kohsuke.stapler.DataBoundConstructor;
|
||||
import org.owasp.html.Handler;
|
||||
import org.owasp.html.HtmlSanitizer;
|
||||
import org.owasp.html.HtmlStreamRenderer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
/**
|
||||
* {@link MarkupFormatter} that treats the input as the raw html.
|
||||
* This is the backward compatible behaviour.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class RawHtmlMarkupFormatter extends MarkupFormatter {
|
||||
|
||||
final boolean disableSyntaxHighlighting;
|
||||
|
||||
@DataBoundConstructor
|
||||
public RawHtmlMarkupFormatter(final boolean disableSyntaxHighlighting) {
|
||||
this.disableSyntaxHighlighting = disableSyntaxHighlighting;
|
||||
}
|
||||
|
||||
public boolean isDisableSyntaxHighlighting() {
|
||||
return disableSyntaxHighlighting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(String markup, Writer output) throws IOException {
|
||||
HtmlStreamRenderer renderer = HtmlStreamRenderer.create(
|
||||
output,
|
||||
// Receives notifications on a failure to write to the output.
|
||||
new Handler<IOException>() {
|
||||
public void handle(IOException ex) {
|
||||
Throwables.propagate(ex); // System.out suppresses IOExceptions
|
||||
}
|
||||
},
|
||||
// Our HTML parser is very lenient, but this receives notifications on
|
||||
// truly bizarre inputs.
|
||||
new Handler<String>() {
|
||||
public void handle(String x) {
|
||||
throw new Error(x);
|
||||
}
|
||||
}
|
||||
);
|
||||
// Use the policy defined above to sanitize the HTML.
|
||||
HtmlSanitizer.sanitize(markup, MyspacePolicy.POLICY_DEFINITION.apply(renderer));
|
||||
}
|
||||
|
||||
public String getCodeMirrorMode() {
|
||||
return disableSyntaxHighlighting ? null : "htmlmixed";
|
||||
}
|
||||
|
||||
public String getCodeMirrorConfig() {
|
||||
return "mode:'text/html'";
|
||||
}
|
||||
|
||||
@Extension
|
||||
public static class DescriptorImpl extends MarkupFormatterDescriptor {
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "Raw HTML";
|
||||
}
|
||||
}
|
||||
|
||||
public static final MarkupFormatter INSTANCE = new RawHtmlMarkupFormatter(false);
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package hudson.matrix;
|
||||
import groovy.lang.GroovyRuntimeException;
|
||||
import hudson.AbortException;
|
||||
import hudson.Extension;
|
||||
import hudson.Util;
|
||||
import hudson.console.ModelHyperlinkNote;
|
||||
import hudson.matrix.MatrixBuild.MatrixBuildExecution;
|
||||
import hudson.matrix.listeners.MatrixBuildListener;
|
||||
@@ -238,7 +237,7 @@ public class DefaultMatrixExecutionStrategyImpl extends MatrixExecutionStrategy
|
||||
exec.getListener().getLogger().println(Messages.MatrixBuild_Triggering(ModelHyperlinkNote.encodeTo(c)));
|
||||
|
||||
// filter the parent actions for those that can be passed to the individual jobs.
|
||||
List<MatrixChildAction> childActions = Util.filter(build.getActions(), MatrixChildAction.class);
|
||||
List<MatrixChildAction> childActions = build.getActions(MatrixChildAction.class);
|
||||
c.scheduleBuild(childActions, new UpstreamCause((Run)build));
|
||||
}
|
||||
|
||||
|
||||
@@ -30,13 +30,13 @@ import hudson.EnvVars;
|
||||
import hudson.FilePath;
|
||||
import hudson.Functions;
|
||||
import hudson.Launcher;
|
||||
import hudson.Util;
|
||||
import hudson.console.AnnotatedLargeText;
|
||||
import hudson.console.ExpandableDetailsNote;
|
||||
import hudson.console.ModelHyperlinkNote;
|
||||
import hudson.matrix.MatrixConfiguration;
|
||||
import hudson.model.Fingerprint.BuildPtr;
|
||||
import hudson.model.Fingerprint.RangeSet;
|
||||
import hudson.model.labels.LabelAtom;
|
||||
import hudson.model.listeners.RunListener;
|
||||
import hudson.model.listeners.SCMListener;
|
||||
import hudson.scm.ChangeLogParser;
|
||||
@@ -541,11 +541,30 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
|
||||
this.listener = listener;
|
||||
|
||||
launcher = createLauncher(listener);
|
||||
if (!Jenkins.getInstance().getNodes().isEmpty())
|
||||
listener.getLogger().print(node instanceof Jenkins ? Messages.AbstractBuild_BuildingOnMaster() :
|
||||
Messages.AbstractBuild_BuildingRemotely(ModelHyperlinkNote.encodeTo("/computer/" + builtOn, builtOn)));
|
||||
else
|
||||
listener.getLogger().print(Messages.AbstractBuild_Building());
|
||||
if (!Jenkins.getInstance().getNodes().isEmpty()) {
|
||||
if (node instanceof Jenkins) {
|
||||
listener.getLogger().print(Messages.AbstractBuild_BuildingOnMaster());
|
||||
} else {
|
||||
listener.getLogger().print(Messages.AbstractBuild_BuildingRemotely(ModelHyperlinkNote.encodeTo("/computer/" + builtOn, builtOn)));
|
||||
Set<LabelAtom> assignedLabels = new HashSet<LabelAtom>(node.getAssignedLabels());
|
||||
assignedLabels.remove(node.getSelfLabel());
|
||||
if (!assignedLabels.isEmpty()) {
|
||||
boolean first = true;
|
||||
for (LabelAtom label : assignedLabels) {
|
||||
if (first) {
|
||||
listener.getLogger().print(" (");
|
||||
first = false;
|
||||
} else {
|
||||
listener.getLogger().print(' ');
|
||||
}
|
||||
listener.getLogger().print(label.getName());
|
||||
}
|
||||
listener.getLogger().print(')');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
listener.getLogger().print(Messages.AbstractBuild_Building());
|
||||
}
|
||||
|
||||
lease = decideWorkspace(node, Computer.currentComputer().getWorkspaceList());
|
||||
|
||||
@@ -922,7 +941,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
|
||||
for (Environment e : buildEnvironments)
|
||||
e.buildEnvVars(env);
|
||||
|
||||
for (EnvironmentContributingAction a : Util.filter(getActions(),EnvironmentContributingAction.class))
|
||||
for (EnvironmentContributingAction a : getActions(EnvironmentContributingAction.class))
|
||||
a.buildEnvVars(this,env);
|
||||
|
||||
EnvVars.resolve(env);
|
||||
@@ -956,6 +975,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
|
||||
return getTimestamp();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public List<Action> getPersistentActions(){
|
||||
return super.getActions();
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ public abstract class AbstractCIBase extends Node implements ItemGroup<TopLevelI
|
||||
* If you are calling this on Hudson something is wrong.
|
||||
*
|
||||
* @deprecated
|
||||
* Maybe you were trying to call {@link #getDisplayName()}.
|
||||
*/
|
||||
@Deprecated @Override
|
||||
public String getNodeName() {
|
||||
@@ -63,6 +64,7 @@ public abstract class AbstractCIBase extends Node implements ItemGroup<TopLevelI
|
||||
/**
|
||||
* @deprecated
|
||||
* Why are you calling a method that always returns ""?
|
||||
* You probably want o call {@link Jenkins#getRootUrl()}
|
||||
*/
|
||||
public String getUrl() {
|
||||
return "";
|
||||
|
||||
@@ -1,37 +1,44 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2004-2009, Kohsuke Kawaguchi
|
||||
*
|
||||
* 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.model;
|
||||
|
||||
import jenkins.model.Jenkins;
|
||||
|
||||
/**
|
||||
* Partial default implementation of {@link Describable}.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public abstract class AbstractDescribableImpl<T extends AbstractDescribableImpl<T>> implements Describable<T> {
|
||||
public Descriptor<T> getDescriptor() {
|
||||
return Jenkins.getInstance().getDescriptorOrDie(getClass());
|
||||
}
|
||||
}
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2004-2009, Kohsuke Kawaguchi
|
||||
*
|
||||
* 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.model;
|
||||
|
||||
import hudson.Extension;
|
||||
import jenkins.model.Jenkins;
|
||||
|
||||
/**
|
||||
* Partial default implementation of {@link Describable}.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public abstract class AbstractDescribableImpl<T extends AbstractDescribableImpl<T>> implements Describable<T> {
|
||||
|
||||
/**
|
||||
* By default looks for a nested class (conventionally named {@code DescriptorImpl}) implementing {@link Descriptor} and marked with {@link Extension}.
|
||||
* <p>{@inheritDoc}
|
||||
*/
|
||||
public Descriptor<T> getDescriptor() {
|
||||
return Jenkins.getInstance().getDescriptorOrDie(getClass());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import hudson.cli.declarative.CLIMethod;
|
||||
import hudson.cli.declarative.CLIResolver;
|
||||
import hudson.model.listeners.ItemListener;
|
||||
import hudson.model.listeners.SaveableListener;
|
||||
import hudson.remoting.Callable;
|
||||
import hudson.security.AccessControlled;
|
||||
import hudson.security.Permission;
|
||||
import hudson.security.ACL;
|
||||
@@ -42,6 +43,7 @@ import hudson.util.AlternativeUiTextProvider.Message;
|
||||
import hudson.util.AtomicFileWriter;
|
||||
import hudson.util.IOUtils;
|
||||
import jenkins.model.Jenkins;
|
||||
import jenkins.model.Jenkins.MasterComputer;
|
||||
import org.apache.tools.ant.taskdefs.Copy;
|
||||
import org.apache.tools.ant.types.FileSet;
|
||||
import org.kohsuke.stapler.WebMethod;
|
||||
@@ -223,6 +225,7 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
|
||||
+ " already exists");
|
||||
|
||||
String oldName = this.name;
|
||||
String oldFullName = getFullName();
|
||||
File oldRoot = this.getRootDir();
|
||||
|
||||
doSetName(newName);
|
||||
@@ -293,8 +296,7 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
|
||||
|
||||
callOnRenamed(newName, parent, oldName);
|
||||
|
||||
for (ItemListener l : ItemListener.all())
|
||||
l.onRenamed(this, oldName, newName);
|
||||
ItemListener.fireLocationChange(this, oldFullName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -366,7 +368,7 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
|
||||
|
||||
/**
|
||||
* Called right after when a {@link Item} is loaded from disk.
|
||||
* This is an opporunity to do a post load processing.
|
||||
* This is an opportunity to do a post load processing.
|
||||
*/
|
||||
public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException {
|
||||
this.parent = parent;
|
||||
@@ -510,21 +512,23 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
|
||||
checkPermission(DELETE);
|
||||
performDelete();
|
||||
|
||||
try {
|
||||
invokeOnDeleted();
|
||||
} catch (AbstractMethodError e) {
|
||||
// ignore
|
||||
}
|
||||
// defer the notification to avoid the lock ordering problem. See JENKINS-19446.
|
||||
MasterComputer.threadPoolForRemoting.submit(new java.util.concurrent.Callable<Void>() {
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
invokeOnDeleted();
|
||||
Jenkins.getInstance().rebuildDependencyGraphAsync();
|
||||
return null;
|
||||
}
|
||||
|
||||
Jenkins.getInstance().rebuildDependencyGraphAsync();
|
||||
}
|
||||
|
||||
/**
|
||||
* A pointless function to work around what appears to be a HotSpot problem. See JENKINS-5756 and bug 6933067
|
||||
* on BugParade for more details.
|
||||
*/
|
||||
private void invokeOnDeleted() throws IOException {
|
||||
getParent().onDeleted(this);
|
||||
/**
|
||||
* A pointless function to work around what appears to be a HotSpot problem. See JENKINS-5756 and bug 6933067
|
||||
* on BugParade for more details.
|
||||
*/
|
||||
private void invokeOnDeleted() throws IOException {
|
||||
getParent().onDeleted(AbstractItem.this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -585,17 +589,17 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
|
||||
new StreamResult(out));
|
||||
out.close();
|
||||
} catch (TransformerException e) {
|
||||
throw new IOException("Failed to persist configuration.xml", e);
|
||||
throw new IOException("Failed to persist config.xml", e);
|
||||
}
|
||||
|
||||
// try to reflect the changes by reloading
|
||||
new XmlFile(Items.XSTREAM, out.getTemporaryFile()).unmarshal(this);
|
||||
Items.updatingByXml.set(true);
|
||||
try {
|
||||
onLoad(getParent(), getRootDir().getName());
|
||||
} finally {
|
||||
Items.updatingByXml.set(false);
|
||||
}
|
||||
Items.whileUpdatingByXml(new Callable<Void,IOException>() {
|
||||
@Override public Void call() throws IOException {
|
||||
onLoad(getParent(), getRootDir().getName());
|
||||
return null;
|
||||
}
|
||||
});
|
||||
Jenkins.getInstance().rebuildDependencyGraphAsync();
|
||||
|
||||
// if everything went well, commit this new version
|
||||
|
||||
@@ -27,15 +27,16 @@
|
||||
*/
|
||||
package hudson.model;
|
||||
|
||||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
||||
import hudson.EnvVars;
|
||||
import hudson.ExtensionPoint;
|
||||
import hudson.Functions;
|
||||
import antlr.ANTLRException;
|
||||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
||||
import hudson.AbortException;
|
||||
import hudson.CopyOnWrite;
|
||||
import hudson.EnvVars;
|
||||
import hudson.Extension;
|
||||
import hudson.ExtensionPoint;
|
||||
import hudson.FeedAdapter;
|
||||
import hudson.FilePath;
|
||||
import hudson.Functions;
|
||||
import hudson.Launcher;
|
||||
import hudson.Util;
|
||||
import hudson.cli.declarative.CLIMethod;
|
||||
@@ -48,21 +49,23 @@ import hudson.model.Fingerprint.RangeSet;
|
||||
import hudson.model.PermalinkProjectAction.Permalink;
|
||||
import hudson.model.Queue.Executable;
|
||||
import hudson.model.Queue.Task;
|
||||
import hudson.model.queue.QueueTaskFuture;
|
||||
import hudson.model.queue.ScheduleResult;
|
||||
import hudson.model.queue.SubTask;
|
||||
import hudson.model.RunMap.Constructor;
|
||||
import hudson.model.labels.LabelAtom;
|
||||
import hudson.model.labels.LabelExpression;
|
||||
import hudson.model.listeners.ItemListener;
|
||||
import hudson.model.listeners.SCMPollListener;
|
||||
import hudson.model.queue.CauseOfBlockage;
|
||||
import hudson.model.queue.QueueTaskFuture;
|
||||
import hudson.model.queue.ScheduleResult;
|
||||
import hudson.model.queue.SubTask;
|
||||
import hudson.model.queue.SubTaskContributor;
|
||||
import hudson.node_monitors.DiskSpaceMonitor;
|
||||
import hudson.scm.ChangeLogSet;
|
||||
import hudson.scm.ChangeLogSet.Entry;
|
||||
import hudson.scm.NullSCM;
|
||||
import hudson.scm.PollingResult;
|
||||
|
||||
import static hudson.scm.PollingResult.*;
|
||||
import hudson.scm.SCM;
|
||||
import hudson.scm.SCMRevisionState;
|
||||
import hudson.scm.SCMS;
|
||||
@@ -85,38 +88,6 @@ import hudson.util.FormValidation;
|
||||
import hudson.util.TimeUnit2;
|
||||
import hudson.widgets.BuildHistoryWidget;
|
||||
import hudson.widgets.HistoryWidget;
|
||||
import jenkins.model.Jenkins;
|
||||
import jenkins.model.JenkinsLocationConfiguration;
|
||||
import jenkins.model.ModelObjectWithChildren;
|
||||
import jenkins.model.Uptime;
|
||||
import jenkins.model.lazy.AbstractLazyLoadRunMap.Direction;
|
||||
import jenkins.scm.DefaultSCMCheckoutStrategyImpl;
|
||||
import jenkins.scm.SCMCheckoutStrategy;
|
||||
import jenkins.scm.SCMCheckoutStrategyDescriptor;
|
||||
import jenkins.util.TimeDuration;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.acegisecurity.Authentication;
|
||||
import org.acegisecurity.context.SecurityContext;
|
||||
import org.acegisecurity.context.SecurityContextHolder;
|
||||
import org.jenkinsci.bytecode.AdaptField;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
import org.kohsuke.args4j.Argument;
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.stapler.Ancestor;
|
||||
import org.kohsuke.stapler.AncestorInPath;
|
||||
import org.kohsuke.stapler.ForwardToView;
|
||||
import org.kohsuke.stapler.HttpRedirect;
|
||||
import org.kohsuke.stapler.HttpResponse;
|
||||
import org.kohsuke.stapler.HttpResponses;
|
||||
import org.kohsuke.stapler.QueryParameter;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
import org.kohsuke.stapler.export.Exported;
|
||||
import org.kohsuke.stapler.interceptor.RequirePOST;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.servlet.ServletException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@@ -139,10 +110,40 @@ import java.util.concurrent.Future;
|
||||
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static hudson.scm.PollingResult.*;
|
||||
import javax.annotation.CheckForNull;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.servlet.ServletException;
|
||||
import static javax.servlet.http.HttpServletResponse.*;
|
||||
import jenkins.model.Jenkins;
|
||||
import jenkins.model.JenkinsLocationConfiguration;
|
||||
import jenkins.model.ModelObjectWithChildren;
|
||||
import jenkins.model.Uptime;
|
||||
import jenkins.model.lazy.AbstractLazyLoadRunMap.Direction;
|
||||
import jenkins.scm.DefaultSCMCheckoutStrategyImpl;
|
||||
import jenkins.scm.SCMCheckoutStrategy;
|
||||
import jenkins.scm.SCMCheckoutStrategyDescriptor;
|
||||
import jenkins.util.TimeDuration;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.acegisecurity.Authentication;
|
||||
import org.acegisecurity.context.SecurityContext;
|
||||
import org.acegisecurity.context.SecurityContextHolder;
|
||||
import org.jenkinsci.bytecode.AdaptField;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.DoNotUse;
|
||||
import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
import org.kohsuke.args4j.Argument;
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.stapler.Ancestor;
|
||||
import org.kohsuke.stapler.AncestorInPath;
|
||||
import org.kohsuke.stapler.ForwardToView;
|
||||
import org.kohsuke.stapler.HttpRedirect;
|
||||
import org.kohsuke.stapler.HttpResponse;
|
||||
import org.kohsuke.stapler.HttpResponses;
|
||||
import org.kohsuke.stapler.QueryParameter;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
import org.kohsuke.stapler.export.Exported;
|
||||
import org.kohsuke.stapler.interceptor.RequirePOST;
|
||||
|
||||
/**
|
||||
* Base implementation of {@link Job}s that build software.
|
||||
@@ -326,8 +327,9 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
|
||||
}
|
||||
this.builds = builds;
|
||||
triggers().setOwner(this);
|
||||
for (Trigger t : triggers())
|
||||
t.start(this, Items.updatingByXml.get());
|
||||
for (Trigger t : triggers()) {
|
||||
t.start(this, Items.currentlyUpdatingByXml());
|
||||
}
|
||||
if(scm==null)
|
||||
scm = new NullSCM(); // perhaps it was pointing to a plugin that no longer exists.
|
||||
|
||||
@@ -399,7 +401,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
|
||||
* If this project is configured to be always built on this node,
|
||||
* return that {@link Node}. Otherwise null.
|
||||
*/
|
||||
public Label getAssignedLabel() {
|
||||
public @CheckForNull Label getAssignedLabel() {
|
||||
if(canRoam)
|
||||
return null;
|
||||
|
||||
@@ -776,13 +778,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
|
||||
}
|
||||
|
||||
public List<ProminentProjectAction> getProminentActions() {
|
||||
List<Action> a = getActions();
|
||||
List<ProminentProjectAction> pa = new Vector<ProminentProjectAction>();
|
||||
for (Action action : a) {
|
||||
if(action instanceof ProminentProjectAction)
|
||||
pa.add((ProminentProjectAction) action);
|
||||
}
|
||||
return pa;
|
||||
return getActions(ProminentProjectAction.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1103,7 +1099,10 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines Class<R>.
|
||||
* Type token for the corresponding build type.
|
||||
* The build class must have two constructors:
|
||||
* one taking this project type;
|
||||
* and one taking this project type, then {@link File}.
|
||||
*/
|
||||
protected abstract Class<R> getBuildClass();
|
||||
|
||||
@@ -1174,6 +1173,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
|
||||
*
|
||||
* @see TransientProjectActionFactory
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public List<Action> getActions() {
|
||||
// add all the transient actions, too
|
||||
@@ -2026,7 +2026,14 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
|
||||
|
||||
for (Publisher _t : Descriptor.newInstancesFromHeteroList(req, json, "publisher", Jenkins.getInstance().getExtensionList(BuildTrigger.DescriptorImpl.class))) {
|
||||
BuildTrigger t = (BuildTrigger) _t;
|
||||
for (AbstractProject downstream : t.getChildProjects(this)) {
|
||||
List<AbstractProject> childProjects;
|
||||
SecurityContext orig = ACL.impersonate(ACL.SYSTEM);
|
||||
try {
|
||||
childProjects = t.getChildProjects(this);
|
||||
} finally {
|
||||
SecurityContextHolder.setContext(orig);
|
||||
}
|
||||
for (AbstractProject downstream : childProjects) {
|
||||
downstream.checkPermission(BUILD);
|
||||
}
|
||||
}
|
||||
@@ -2119,6 +2126,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
|
||||
makeDisabled(false);
|
||||
return new HttpRedirect(".");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* RSS feed for changes in this project.
|
||||
@@ -2221,7 +2229,8 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
|
||||
return FormValidation.error(e,
|
||||
Messages.AbstractProject_AssignedLabelString_InvalidBooleanExpression(e.getMessage()));
|
||||
}
|
||||
Label l = Jenkins.getInstance().getLabel(value);
|
||||
Jenkins j = Jenkins.getInstance();
|
||||
Label l = j.getLabel(value);
|
||||
if (l.isEmpty()) {
|
||||
for (LabelAtom a : l.listAtoms()) {
|
||||
if (a.isEmpty()) {
|
||||
@@ -2232,7 +2241,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
|
||||
return FormValidation.warning(Messages.AbstractProject_AssignedLabelString_NoMatch());
|
||||
}
|
||||
if (project != null) {
|
||||
for (AbstractProject.LabelValidator v : Jenkins.getInstance()
|
||||
for (AbstractProject.LabelValidator v : j
|
||||
.getExtensionList(AbstractProject.LabelValidator.class)) {
|
||||
FormValidation result = v.check(project, l);
|
||||
if (!FormValidation.Kind.OK.equals(result.kind)) {
|
||||
@@ -2240,7 +2249,9 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
|
||||
}
|
||||
}
|
||||
}
|
||||
return FormValidation.ok();
|
||||
return FormValidation.okWithMarkup(Messages.AbstractProject_LabelLink(
|
||||
j.getRootUrl(), l.getUrl(), l.getNodes().size() + l.getClouds().size()
|
||||
));
|
||||
}
|
||||
|
||||
public FormValidation doCheckCustomWorkspace(@QueryParameter(value="customWorkspace.directory") String customWorkspace){
|
||||
@@ -2415,4 +2426,14 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
|
||||
public abstract FormValidation check(@Nonnull AbstractProject<?, ?> project, @Nonnull Label label);
|
||||
}
|
||||
|
||||
@Restricted(DoNotUse.class)
|
||||
@Extension public static final class ItemListenerImpl extends ItemListener {
|
||||
@Override public void onLocationChanged(Item item, String oldFullName, String newFullName) {
|
||||
if (item instanceof AbstractProject) {
|
||||
AbstractProject p = (AbstractProject) item;
|
||||
p.builds.updateBaseDir(p.getBuildDir());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,27 +23,20 @@
|
||||
*/
|
||||
package hudson.model;
|
||||
|
||||
import hudson.Functions;
|
||||
import hudson.model.queue.Tasks;
|
||||
import hudson.Util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import jenkins.model.Jenkins;
|
||||
import jenkins.model.ModelObjectWithContextMenu;
|
||||
import org.apache.commons.jelly.JellyContext;
|
||||
import org.apache.commons.jelly.JellyException;
|
||||
import org.apache.commons.jelly.JellyTagException;
|
||||
import org.apache.commons.jelly.Script;
|
||||
import org.apache.commons.jelly.XMLOutput;
|
||||
import jenkins.model.TransientActionFactory;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
import org.kohsuke.stapler.WebApp;
|
||||
import org.kohsuke.stapler.export.Exported;
|
||||
import org.kohsuke.stapler.export.ExportedBean;
|
||||
import org.kohsuke.stapler.jelly.JellyClassTearOff;
|
||||
import org.kohsuke.stapler.jelly.JellyFacet;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
* {@link ModelObject} that can have additional {@link Action}s.
|
||||
@@ -60,15 +53,23 @@ public abstract class Actionable extends AbstractModelObject implements ModelObj
|
||||
private volatile CopyOnWriteArrayList<Action> actions;
|
||||
|
||||
/**
|
||||
* Gets actions contributed to this build.
|
||||
* Gets actions contributed to this object.
|
||||
*
|
||||
* <p>
|
||||
* A new {@link Action} can be added by {@code getActions().add(...)}.
|
||||
* A new {@link Action} can be added by {@link #addAction}.
|
||||
*
|
||||
* <p>If you are <em>reading</em> the list, rather than <em>modifying</em> it,
|
||||
* use {@link #getAllActions} instead.
|
||||
* This method by default returns only <em>persistent</em> actions
|
||||
* (though some subclasses override it to return an extended unmodifiable list).
|
||||
*
|
||||
* @return
|
||||
* may be empty but never null.
|
||||
* @deprecated Normally outside code should not call this method any more.
|
||||
* Use {@link #getAllActions}, or {@link #addAction}, or {@link #replaceAction}.
|
||||
* May still be called for compatibility reasons from subclasses predating {@link TransientActionFactory}.
|
||||
*/
|
||||
@Exported
|
||||
@Deprecated
|
||||
public List<Action> getActions() {
|
||||
if(actions == null) {
|
||||
synchronized (this) {
|
||||
@@ -81,7 +82,27 @@ public abstract class Actionable extends AbstractModelObject implements ModelObj
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all actions of a specified type that contributed to this build.
|
||||
* Gets all actions, transient or persistent.
|
||||
* {@link #getActions} is supplemented with anything contributed by {@link TransientActionFactory}.
|
||||
* @return an unmodifiable, possible empty list
|
||||
* @since 1.548
|
||||
*/
|
||||
@Exported(name="actions")
|
||||
public final List<? extends Action> getAllActions() {
|
||||
List<Action> _actions = new ArrayList<Action>(getActions());
|
||||
for (TransientActionFactory<?> taf : Jenkins.getInstance().getExtensionList(TransientActionFactory.class)) {
|
||||
if (taf.type().isInstance(this)) {
|
||||
_actions.addAll(createFor(taf));
|
||||
}
|
||||
}
|
||||
return Collections.unmodifiableList(_actions);
|
||||
}
|
||||
private <T> Collection<? extends Action> createFor(TransientActionFactory<T> taf) {
|
||||
return taf.createFor(taf.type().cast(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all actions of a specified type that contributed to this object.
|
||||
*
|
||||
* @param type The type of action to return.
|
||||
* @return
|
||||
@@ -89,23 +110,39 @@ public abstract class Actionable extends AbstractModelObject implements ModelObj
|
||||
* @see #getAction(Class)
|
||||
*/
|
||||
public <T extends Action> List<T> getActions(Class<T> type) {
|
||||
List<T> result = new Vector<T>();
|
||||
for (Action a : getActions())
|
||||
if (type.isInstance(a))
|
||||
result.add(type.cast(a));
|
||||
return result;
|
||||
return Util.filter(getAllActions(), type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new action.
|
||||
*
|
||||
* Short for <tt>getActions().add(a)</tt>
|
||||
* The default implementation calls {@code getActions().add(a)}.
|
||||
*/
|
||||
public void addAction(Action a) {
|
||||
if(a==null) throw new IllegalArgumentException();
|
||||
getActions().add(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an action, replacing any existing action of the (exact) same class.
|
||||
* @param a an action to add/replace
|
||||
* @since 1.548
|
||||
*/
|
||||
public void replaceAction(Action a) {
|
||||
// CopyOnWriteArrayList does not support Iterator.remove, so need to do it this way:
|
||||
List<Action> old = new ArrayList<Action>(1);
|
||||
List<Action> current = getActions();
|
||||
for (Action a2 : current) {
|
||||
if (a2.getClass() == a.getClass()) {
|
||||
old.add(a2);
|
||||
}
|
||||
}
|
||||
current.removeAll(old);
|
||||
addAction(a);
|
||||
}
|
||||
|
||||
/** @deprecated No clear purpose, since subclasses may have overridden {@link #getActions}, and does not consider {@link TransientActionFactory}. */
|
||||
@Deprecated
|
||||
public Action getAction(int index) {
|
||||
if(actions==null) return null;
|
||||
return actions.get(index);
|
||||
@@ -119,14 +156,14 @@ public abstract class Actionable extends AbstractModelObject implements ModelObj
|
||||
* @see #getActions(Class)
|
||||
*/
|
||||
public <T extends Action> T getAction(Class<T> type) {
|
||||
for (Action a : getActions())
|
||||
for (Action a : getAllActions())
|
||||
if (type.isInstance(a))
|
||||
return type.cast(a);
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object getDynamic(String token, StaplerRequest req, StaplerResponse rsp) {
|
||||
for (Action a : getActions()) {
|
||||
for (Action a : getAllActions()) {
|
||||
if(a==null)
|
||||
continue; // be defensive
|
||||
String urlName = a.getUrlName();
|
||||
|
||||
@@ -81,11 +81,6 @@ public class AllView extends View {
|
||||
return ""; // there's no configuration page
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJobRenamed(Item item, String oldName, String newName) {
|
||||
// noop
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void submit(StaplerRequest req) throws IOException, ServletException, FormException {
|
||||
// noop
|
||||
|
||||
@@ -38,12 +38,12 @@ public abstract class AsyncPeriodicWork extends PeriodicWork {
|
||||
public final void doRun() {
|
||||
try {
|
||||
if(thread!=null && thread.isAlive()) {
|
||||
logger.log(Level.INFO, name+" thread is still running. Execution aborted.");
|
||||
logger.log(this.getNormalLoggingLevel(), name+" thread is still running. Execution aborted.");
|
||||
return;
|
||||
}
|
||||
thread = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
logger.log(Level.INFO, "Started "+name);
|
||||
logger.log(getNormalLoggingLevel(), "Started "+name);
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
StreamTaskListener l = createListener();
|
||||
@@ -59,13 +59,13 @@ public abstract class AsyncPeriodicWork extends PeriodicWork {
|
||||
l.closeQuietly();
|
||||
}
|
||||
|
||||
logger.log(Level.INFO, "Finished "+name+". "+
|
||||
logger.log(getNormalLoggingLevel(), "Finished "+name+". "+
|
||||
(System.currentTimeMillis()-startTime)+" ms");
|
||||
}
|
||||
},name+" thread");
|
||||
thread.start();
|
||||
} catch (Throwable t) {
|
||||
logger.log(Level.SEVERE, name+" thread failed with error", t);
|
||||
logger.log(this.getErrorLoggingLevel(), name+" thread failed with error", t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,31 @@ public abstract class AsyncPeriodicWork extends PeriodicWork {
|
||||
protected File getLogFile() {
|
||||
return new File(Jenkins.getInstance().getRootDir(),name+".log");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the logging level at which normal messages are displayed.
|
||||
*
|
||||
* @return
|
||||
* The logging level as @Level.
|
||||
*
|
||||
* @since 1.551
|
||||
*/
|
||||
protected Level getNormalLoggingLevel() {
|
||||
return Level.INFO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the logging level at which error messages are displayed.
|
||||
*
|
||||
* @return
|
||||
* The logging level as @Level.
|
||||
*
|
||||
* @since 1.551
|
||||
*/
|
||||
protected Level getErrorLoggingLevel() {
|
||||
return Level.SEVERE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the task.
|
||||
*
|
||||
|
||||
@@ -91,7 +91,22 @@ public class AutoCompletionCandidates implements HttpResponse {
|
||||
public static <T extends Item> AutoCompletionCandidates ofJobNames(final Class<T> type, final String value, @CheckForNull Item self, ItemGroup container) {
|
||||
if (self==container)
|
||||
container = self.getParent();
|
||||
return ofJobNames(type, value, container);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Auto-completes possible job names.
|
||||
*
|
||||
* @param type
|
||||
* Limit the auto-completion to the subtype of this type.
|
||||
* @param value
|
||||
* The value the user has typed in. Matched as a prefix.
|
||||
* @param container
|
||||
* The nearby contextual {@link ItemGroup} to resolve relative job names from.
|
||||
* @since 1.553
|
||||
*/
|
||||
public static <T extends Item> AutoCompletionCandidates ofJobNames(final Class<T> type, final String value, ItemGroup container) {
|
||||
final AutoCompletionCandidates candidates = new AutoCompletionCandidates();
|
||||
class Visitor extends ItemVisitor {
|
||||
String prefix;
|
||||
|
||||
Executable → Regular
File mode changed.
Executable → Regular
File mode changed.
@@ -33,7 +33,7 @@ import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* UI widget for showing the SMILE timeline control.
|
||||
* UI widget for showing the SIMILE timeline control.
|
||||
*
|
||||
* <p>
|
||||
* Return this from your "getTimeline" method.
|
||||
@@ -45,13 +45,15 @@ public class BuildTimelineWidget {
|
||||
protected final RunList<?> builds;
|
||||
|
||||
public BuildTimelineWidget(RunList<?> builds) {
|
||||
this.builds = builds;
|
||||
this.builds = builds.limit(20); // TODO instead render lazily
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Run<?, ?> getFirstBuild() {
|
||||
return builds.getFirstBuild();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Run<?, ?> getLastBuild() {
|
||||
return builds.getLastBuild();
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import jenkins.model.Jenkins;
|
||||
import org.kohsuke.stapler.export.Exported;
|
||||
import org.kohsuke.stapler.export.ExportedBean;
|
||||
import com.thoughtworks.xstream.converters.UnmarshallingContext;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import javax.annotation.CheckForNull;
|
||||
@@ -412,10 +413,13 @@ public abstract class Cause {
|
||||
@Override
|
||||
public String getShortDescription() {
|
||||
if(note != null) {
|
||||
return Messages.Cause_RemoteCause_ShortDescriptionWithNote(addr, note);
|
||||
} else {
|
||||
return Messages.Cause_RemoteCause_ShortDescription(addr);
|
||||
try {
|
||||
return Messages.Cause_RemoteCause_ShortDescriptionWithNote(addr, Jenkins.getInstance().getMarkupFormatter().translate(note));
|
||||
} catch (IOException x) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
return Messages.Cause_RemoteCause_ShortDescription(addr);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -144,7 +144,7 @@ public class CauseAction implements FoldableAction, RunAction2 {
|
||||
return;
|
||||
}
|
||||
// no CauseAction found, so add a copy of this one
|
||||
item.getActions().add(new CauseAction(this));
|
||||
item.addAction(new CauseAction(this));
|
||||
}
|
||||
|
||||
public static class ConverterImpl extends XStream2.PassthruConverter<CauseAction> {
|
||||
|
||||
Executable → Regular
File mode changed.
@@ -180,6 +180,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
|
||||
/**
|
||||
* Returns the transient {@link Action}s associated with the computer.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public List<Action> getActions() {
|
||||
List<Action> result = new ArrayList<Action>();
|
||||
result.addAll(super.getActions());
|
||||
@@ -189,9 +190,10 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
|
||||
}
|
||||
result.addAll(transientActions);
|
||||
}
|
||||
return result;
|
||||
return Collections.unmodifiableList(result);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void addAction(Action a) {
|
||||
if(a==null) throw new IllegalArgumentException();
|
||||
@@ -1083,9 +1085,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
|
||||
checkPermission(DISCONNECT);
|
||||
offlineMessage = Util.fixEmptyAndTrim(offlineMessage);
|
||||
setTemporarilyOffline(!temporarilyOffline,
|
||||
OfflineCause.create(hudson.slaves.Messages._SlaveComputer_DisconnectedBy(
|
||||
Jenkins.getAuthentication().getName(),
|
||||
offlineMessage!=null ? " : " + offlineMessage : "")));
|
||||
new OfflineCause.UserCause(User.current(), offlineMessage));
|
||||
} else {
|
||||
checkPermission(CONNECT);
|
||||
setTemporarilyOffline(!temporarilyOffline,null);
|
||||
@@ -1097,9 +1097,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
|
||||
checkPermission(DISCONNECT);
|
||||
offlineMessage = Util.fixEmptyAndTrim(offlineMessage);
|
||||
setTemporarilyOffline(true,
|
||||
OfflineCause.create(hudson.slaves.Messages._SlaveComputer_DisconnectedBy(
|
||||
Jenkins.getAuthentication().getName(),
|
||||
offlineMessage != null ? " : " + offlineMessage : "")));
|
||||
new OfflineCause.UserCause(User.current(), offlineMessage));
|
||||
return HttpResponses.redirectToDot();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,9 @@ public interface Describable<T extends Describable<T>> {
|
||||
*
|
||||
* <p>
|
||||
* {@link Descriptor} is a singleton for every concrete {@link Describable}
|
||||
* implementation, so if <tt>a.getClass()==b.getClass()</tt> then
|
||||
* <tt>a.getDescriptor()==b.getDescriptor()</tt> must hold.
|
||||
* implementation, so if {@code a.getClass() == b.getClass()} then by default
|
||||
* {@code a.getDescriptor() == b.getDescriptor()} as well.
|
||||
* (In rare cases a single implementation class may be used for instances with distinct descriptors.)
|
||||
*/
|
||||
Descriptor<T> getDescriptor();
|
||||
}
|
||||
@@ -967,7 +967,7 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
|
||||
|
||||
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException {
|
||||
if (FormApply.isApply(req)) {
|
||||
FormApply.applyResponse("notificationBar.show(" + quote(getMessage())+ ",notificationBar.defaultOptions.ERROR)")
|
||||
FormApply.applyResponse("notificationBar.show(" + quote(getMessage())+ ",notificationBar.ERROR)")
|
||||
.generateResponse(req, rsp, node);
|
||||
} else {
|
||||
// for now, we can't really use the field name that caused the problem.
|
||||
|
||||
@@ -25,13 +25,6 @@ package hudson.model;
|
||||
|
||||
import hudson.FilePath;
|
||||
import hudson.Util;
|
||||
import jenkins.model.Jenkins;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
import org.kohsuke.stapler.HttpResponse;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@@ -41,14 +34,23 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jenkins.model.Jenkins;
|
||||
import jenkins.util.VirtualFile;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.kohsuke.stapler.HttpResponse;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
|
||||
/**
|
||||
* Has convenience methods to serve file system.
|
||||
@@ -351,7 +353,12 @@ public final class DirectoryBrowserSupport implements HttpResponse {
|
||||
VirtualFile f = dir.child(n);
|
||||
e.setTime(f.lastModified());
|
||||
zos.putNextEntry(e);
|
||||
Util.copyStream(f.open(), zos);
|
||||
InputStream in = f.open();
|
||||
try {
|
||||
Util.copyStream(in, zos);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(in);
|
||||
}
|
||||
zos.closeEntry();
|
||||
}
|
||||
zos.close();
|
||||
@@ -424,8 +431,9 @@ public final class DirectoryBrowserSupport implements HttpResponse {
|
||||
|
||||
private static final class FileComparator implements Comparator<VirtualFile> {
|
||||
private Collator collator;
|
||||
private final Map<VirtualFile,Boolean> isDirCache = new HashMap<VirtualFile,Boolean>();
|
||||
|
||||
public FileComparator(Locale locale) {
|
||||
FileComparator(Locale locale) {
|
||||
this.collator = Collator.getInstance(locale);
|
||||
}
|
||||
|
||||
@@ -437,9 +445,18 @@ public final class DirectoryBrowserSupport implements HttpResponse {
|
||||
return this.collator.compare(lhs.getName(), rhs.getName());
|
||||
}
|
||||
|
||||
private boolean isDirectory(VirtualFile f) throws IOException {
|
||||
Boolean known = isDirCache.get(f);
|
||||
if (known == null) {
|
||||
known = f.isDirectory();
|
||||
isDirCache.put(f, known);
|
||||
}
|
||||
return known;
|
||||
}
|
||||
|
||||
private int dirRank(VirtualFile f) {
|
||||
try {
|
||||
if(f.isDirectory()) return 0;
|
||||
if(isDirectory(f)) return 0;
|
||||
else return 1;
|
||||
} catch (IOException ex) {
|
||||
return 0;
|
||||
|
||||
@@ -274,13 +274,13 @@ public class Executor extends Thread implements ModelObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current {@link hudson.model.Queue.Task} this executor is running.
|
||||
* Returns the current build this executor is running.
|
||||
*
|
||||
* @return
|
||||
* null if the executor is idle.
|
||||
*/
|
||||
@Exported
|
||||
public Queue.Executable getCurrentExecutable() {
|
||||
public @CheckForNull Queue.Executable getCurrentExecutable() {
|
||||
return executable;
|
||||
}
|
||||
|
||||
|
||||
@@ -727,7 +727,7 @@ public class Fingerprint implements ModelObject, Saveable {
|
||||
@Extension
|
||||
public static final class ProjectRenameListener extends ItemListener {
|
||||
@Override
|
||||
public void onRenamed(Item item, String oldName, String newName) {
|
||||
public void onLocationChanged(Item item, String oldName, String newName) {
|
||||
if (item instanceof AbstractProject) {
|
||||
AbstractProject p = Jenkins.getInstance().getItemByFullName(newName, AbstractProject.class);
|
||||
if (p != null) {
|
||||
|
||||
@@ -23,9 +23,6 @@
|
||||
*/
|
||||
package hudson.model;
|
||||
|
||||
import hudson.slaves.WorkspaceList;
|
||||
import hudson.slaves.WorkspaceList.Lease;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
*/
|
||||
package hudson.model;
|
||||
|
||||
import hudson.model.listeners.ItemListener;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.io.File;
|
||||
@@ -76,6 +77,7 @@ public interface ItemGroup<T extends Item> extends PersistenceRoot, ModelObject
|
||||
|
||||
/**
|
||||
* Internal method. Called by {@link Item}s when they are renamed by users.
|
||||
* This is <em>not</em> expected to call {@link ItemListener#onRenamed}, inconsistent with {@link #onDeleted}.
|
||||
*/
|
||||
void onRenamed(T item, String oldName, String newName) throws IOException;
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ package hudson.model;
|
||||
|
||||
import hudson.Util;
|
||||
import hudson.model.listeners.ItemListener;
|
||||
import hudson.remoting.Callable;
|
||||
import hudson.security.AccessControlled;
|
||||
import hudson.util.CopyOnWriteMap;
|
||||
import hudson.util.Function1;
|
||||
@@ -40,6 +41,8 @@ import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Defines a bunch of static methods to be used as a "mix-in" for {@link ItemGroup}
|
||||
@@ -96,10 +99,16 @@ public abstract class ItemGroupMixIn {
|
||||
CopyOnWriteMap.Tree<K,V> configurations = new CopyOnWriteMap.Tree<K,V>();
|
||||
for (File subdir : subdirs) {
|
||||
try {
|
||||
V item = (V) Items.load(parent,subdir);
|
||||
// Try to retain the identity of an existing child object if we can.
|
||||
V item = (V) parent.getItem(subdir.getName());
|
||||
if (item == null) {
|
||||
item = (V) Items.load(parent,subdir);
|
||||
} else {
|
||||
item.onLoad(parent, subdir.getName());
|
||||
}
|
||||
configurations.put(key.call(item), item);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace(); // TODO: logging
|
||||
Logger.getLogger(ItemGroupMixIn.class.getName()).log(Level.WARNING, "could not load " + subdir, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,12 +213,12 @@ public abstract class ItemGroupMixIn {
|
||||
Util.copyFile(Items.getConfigFile(src).getFile(),Items.getConfigFile(result).getFile());
|
||||
|
||||
// reload from the new config
|
||||
Items.updatingByXml.set(true);
|
||||
try {
|
||||
result = (T)Items.load(parent,result.getRootDir());
|
||||
} finally {
|
||||
Items.updatingByXml.set(false);
|
||||
}
|
||||
final File rootDir = result.getRootDir();
|
||||
result = Items.whileUpdatingByXml(new Callable<T,IOException>() {
|
||||
@Override public T call() throws IOException {
|
||||
return (T) Items.load(parent, rootDir);
|
||||
}
|
||||
});
|
||||
result.onCopiedFrom(src);
|
||||
|
||||
add(result);
|
||||
@@ -229,18 +238,17 @@ public abstract class ItemGroupMixIn {
|
||||
|
||||
// place it as config.xml
|
||||
File configXml = Items.getConfigFile(getRootDirFor(name)).getFile();
|
||||
configXml.getParentFile().mkdirs();
|
||||
final File dir = configXml.getParentFile();
|
||||
dir.mkdirs();
|
||||
try {
|
||||
IOUtils.copy(xml,configXml);
|
||||
|
||||
// load it
|
||||
TopLevelItem result;
|
||||
Items.updatingByXml.set(true);
|
||||
try {
|
||||
result = (TopLevelItem)Items.load(parent,configXml.getParentFile());
|
||||
} finally {
|
||||
Items.updatingByXml.set(false);
|
||||
}
|
||||
TopLevelItem result = Items.whileUpdatingByXml(new Callable<TopLevelItem,IOException>() {
|
||||
@Override public TopLevelItem call() throws IOException {
|
||||
return (TopLevelItem) Items.load(parent, dir);
|
||||
}
|
||||
});
|
||||
add(result);
|
||||
|
||||
ItemListener.fireOnCreated(result);
|
||||
@@ -249,7 +257,7 @@ public abstract class ItemGroupMixIn {
|
||||
return result;
|
||||
} catch (IOException e) {
|
||||
// if anything fails, delete the config file to avoid further confusion
|
||||
Util.deleteRecursive(configXml.getParentFile());
|
||||
Util.deleteRecursive(dir);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ import hudson.matrix.MatrixProject;
|
||||
import hudson.matrix.MatrixConfiguration;
|
||||
import hudson.XmlFile;
|
||||
import hudson.matrix.Axis;
|
||||
import hudson.model.listeners.ItemListener;
|
||||
import hudson.remoting.Callable;
|
||||
import hudson.triggers.Trigger;
|
||||
import hudson.util.DescriptorList;
|
||||
import hudson.util.EditDistance;
|
||||
@@ -41,6 +43,8 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import javax.annotation.CheckForNull;
|
||||
import jenkins.model.DirectlyModifiableTopLevelItemGroup;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
/**
|
||||
* Convenience methods related to {@link Item}.
|
||||
@@ -61,12 +65,41 @@ public class Items {
|
||||
* @see Trigger#start
|
||||
* @since 1.482
|
||||
*/
|
||||
static final ThreadLocal<Boolean> updatingByXml = new ThreadLocal<Boolean>() {
|
||||
private static final ThreadLocal<Boolean> updatingByXml = new ThreadLocal<Boolean>() {
|
||||
@Override protected Boolean initialValue() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Runs a block while making {@link #currentlyUpdatingByXml} be temporarily true.
|
||||
* Use this when you are creating or changing an item.
|
||||
* @param <V> a return value type (may be {@link Void})
|
||||
* @param <T> an error type (may be {@link Error})
|
||||
* @param callable a block, typically running {@link #load} or {@link Item#onLoad}
|
||||
* @return whatever {@code callable} returned
|
||||
* @throws T anything {@code callable} throws
|
||||
* @since 1.546
|
||||
*/
|
||||
public static <V,T extends Throwable> V whileUpdatingByXml(Callable<V,T> callable) throws T {
|
||||
updatingByXml.set(true);
|
||||
try {
|
||||
return callable.call();
|
||||
} finally {
|
||||
updatingByXml.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether we are in the middle of creating or configuring an item via XML.
|
||||
* Used to determine the {@code newInstance} parameter for {@link Trigger#start}.
|
||||
* @return true if {@link #whileUpdatingByXml} is currently being called, false for example when merely starting Jenkins or reloading from disk
|
||||
* @since 1.546
|
||||
*/
|
||||
public static boolean currentlyUpdatingByXml() {
|
||||
return updatingByXml.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the registered {@link TopLevelItemDescriptor}s.
|
||||
*/
|
||||
@@ -149,8 +182,8 @@ public class Items {
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the relative name of list of items after a rename occurred. Used to manage job references as names in
|
||||
* plugins to support {@link hudson.model.listeners.ItemListener#onRenamed(hudson.model.Item, String, String)}.
|
||||
* Computes the relative name of list of items after a rename or move occurred.
|
||||
* Used to manage job references as names in plugins to support {@link hudson.model.listeners.ItemListener#onLocationChanged}.
|
||||
* <p>
|
||||
* In a hierarchical context, when a plugin has a reference to a job as <code>../foo/bar</code> this method will
|
||||
* handle the relative path as "foo" is renamed to "zot" to compute <code>../zot/bar</code>
|
||||
@@ -170,8 +203,11 @@ public class Items {
|
||||
String canonicalName = getCanonicalName(context, relativeName);
|
||||
if (canonicalName.equals(oldFullName) || canonicalName.startsWith(oldFullName+'/')) {
|
||||
String newCanonicalName = newFullName + canonicalName.substring(oldFullName.length());
|
||||
// relative name points to the renamed item, let's compute the new relative name
|
||||
newValue.add( computeRelativeNameAfterRenaming(canonicalName, newCanonicalName, relativeName) );
|
||||
if (relativeName.startsWith("/")) {
|
||||
newValue.add("/" + newCanonicalName);
|
||||
} else {
|
||||
newValue.add(getRelativeNameFrom(newCanonicalName, context.getFullName()));
|
||||
}
|
||||
} else {
|
||||
newValue.add(relativeName);
|
||||
}
|
||||
@@ -179,39 +215,56 @@ public class Items {
|
||||
return StringUtils.join(newValue, ",");
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the relative name of an Item after renaming
|
||||
*/
|
||||
private static String computeRelativeNameAfterRenaming(String oldFullName, String newFullName, String relativeName) {
|
||||
|
||||
String[] a = oldFullName.split("/");
|
||||
String[] n = newFullName.split("/");
|
||||
assert a.length == n.length;
|
||||
String[] r = relativeName.split("/");
|
||||
|
||||
int j = a.length-1;
|
||||
for(int i=r.length-1;i>=0;i--) {
|
||||
String part = r[i];
|
||||
if (part.equals("") && i==0) {
|
||||
continue;
|
||||
}
|
||||
if (part.equals(".")) {
|
||||
continue;
|
||||
}
|
||||
if (part.equals("..")) {
|
||||
j--;
|
||||
continue;
|
||||
}
|
||||
if (part.equals(a[j])) {
|
||||
r[i] = n[j];
|
||||
j--;
|
||||
// Had difficulty adapting the version in Functions to use no live items, so rewrote it:
|
||||
static String getRelativeNameFrom(String itemFullName, String groupFullName) {
|
||||
String[] itemFullNameA = itemFullName.isEmpty() ? new String[0] : itemFullName.split("/");
|
||||
String[] groupFullNameA = groupFullName.isEmpty() ? new String[0] : groupFullName.split("/");
|
||||
for (int i = 0; ; i++) {
|
||||
if (i == itemFullNameA.length) {
|
||||
if (i == groupFullNameA.length) {
|
||||
// itemFullName and groupFullName are identical
|
||||
return ".";
|
||||
} else {
|
||||
// itemFullName is an ancestor of groupFullName; insert ../ for rest of groupFullName
|
||||
StringBuilder b = new StringBuilder();
|
||||
for (int j = 0; j < groupFullNameA.length - itemFullNameA.length; j++) {
|
||||
if (j > 0) {
|
||||
b.append('/');
|
||||
}
|
||||
b.append("..");
|
||||
}
|
||||
return b.toString();
|
||||
}
|
||||
} else if (i == groupFullNameA.length) {
|
||||
// groupFullName is an ancestor of itemFullName; insert rest of itemFullName
|
||||
StringBuilder b = new StringBuilder();
|
||||
for (int j = i; j < itemFullNameA.length; j++) {
|
||||
if (j > i) {
|
||||
b.append('/');
|
||||
}
|
||||
b.append(itemFullNameA[j]);
|
||||
}
|
||||
return b.toString();
|
||||
} else if (itemFullNameA[i].equals(groupFullNameA[i])) {
|
||||
// identical up to this point
|
||||
continue;
|
||||
} else {
|
||||
// first mismatch; insert ../ for rest of groupFullName, then rest of itemFullName
|
||||
StringBuilder b = new StringBuilder();
|
||||
for (int j = i; j < groupFullNameA.length; j++) {
|
||||
if (j > i) {
|
||||
b.append('/');
|
||||
}
|
||||
b.append("..");
|
||||
}
|
||||
for (int j = i; j < itemFullNameA.length; j++) {
|
||||
b.append('/').append(itemFullNameA[j]);
|
||||
}
|
||||
return b.toString();
|
||||
}
|
||||
}
|
||||
return StringUtils.join(r, '/');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads a {@link Item} from a config file.
|
||||
*
|
||||
@@ -300,6 +353,42 @@ public class Items {
|
||||
return Jenkins.getInstance().getItem(nearest, context, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves an item between folders (or top level).
|
||||
* Fires all relevant events but does not verify that the item’s directory is not currently being used in some way (for example by a running build).
|
||||
* Does not check any permissions.
|
||||
* @param item some item (job or folder)
|
||||
* @param destination the destination of the move (a folder or {@link Jenkins}); not the current parent (or you could just call {@link AbstractItem#renameTo})
|
||||
* @return the new item (usually the same object as {@code item})
|
||||
* @throws IOException if the move fails, or some subsequent step fails (directory might have already been moved)
|
||||
* @throws IllegalArgumentException if the move would really be a rename, or the destination cannot accept the item, or the destination already has an item of that name
|
||||
* @since 1.548
|
||||
*/
|
||||
public static <I extends AbstractItem & TopLevelItem> I move(I item, DirectlyModifiableTopLevelItemGroup destination) throws IOException, IllegalArgumentException {
|
||||
DirectlyModifiableTopLevelItemGroup oldParent = (DirectlyModifiableTopLevelItemGroup) item.getParent();
|
||||
if (oldParent == destination) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
// TODO verify that destination is to not equal to, or inside, item
|
||||
if (!destination.canAdd(item)) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
String name = item.getName();
|
||||
if (destination.getItem(name) != null) {
|
||||
throw new IllegalArgumentException(name + " already exists");
|
||||
}
|
||||
String oldFullName = item.getFullName();
|
||||
// TODO AbstractItem.renameTo has a more baroque implementation; factor it out into a utility method perhaps?
|
||||
File destDir = destination.getRootDirFor(item);
|
||||
FileUtils.forceMkdir(destDir.getParentFile());
|
||||
FileUtils.moveDirectory(item.getRootDir(), destDir);
|
||||
oldParent.remove(item);
|
||||
I newItem = destination.add(item, name);
|
||||
newItem.onLoad(destination, name);
|
||||
ItemListener.fireLocationChange(newItem, oldFullName);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to load/save job configuration.
|
||||
*
|
||||
|
||||
@@ -54,6 +54,7 @@ import hudson.util.DescribableList;
|
||||
import hudson.util.FormApply;
|
||||
import hudson.util.Graph;
|
||||
import hudson.util.ProcessTree;
|
||||
import hudson.util.QuotedStringTokenizer;
|
||||
import hudson.util.RunList;
|
||||
import hudson.util.ShiftedCategoryAxis;
|
||||
import hudson.util.StackedAreaRenderer2;
|
||||
@@ -357,10 +358,12 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
|
||||
public EnvVars getEnvironment(Node node, TaskListener listener) throws IOException, InterruptedException {
|
||||
EnvVars env;
|
||||
|
||||
if (node!=null)
|
||||
env = node.toComputer().buildEnvironment(listener);
|
||||
else
|
||||
if (node!=null) {
|
||||
final Computer computer = node.toComputer();
|
||||
env = (computer != null) ? computer.buildEnvironment(listener) : new EnvVars();
|
||||
} else {
|
||||
env = new EnvVars();
|
||||
}
|
||||
|
||||
env.putAll(getCharacteristicEnvVars());
|
||||
|
||||
@@ -972,11 +975,8 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
|
||||
public PermalinkList getPermalinks() {
|
||||
// TODO: shall we cache this?
|
||||
PermalinkList permalinks = new PermalinkList(Permalink.BUILTIN);
|
||||
for (Action a : getActions()) {
|
||||
if (a instanceof PermalinkProjectAction) {
|
||||
PermalinkProjectAction ppa = (PermalinkProjectAction) a;
|
||||
permalinks.addAll(ppa.getPermalinks());
|
||||
}
|
||||
for (PermalinkProjectAction ppa : getActions(PermalinkProjectAction.class)) {
|
||||
permalinks.addAll(ppa.getPermalinks());
|
||||
}
|
||||
return permalinks;
|
||||
}
|
||||
@@ -1144,7 +1144,11 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
|
||||
// check this error early to avoid HTTP response splitting.
|
||||
Jenkins.checkGoodName(newName);
|
||||
namingStrategy.checkName(newName);
|
||||
rsp.sendRedirect("rename?newName=" + URLEncoder.encode(newName, "UTF-8"));
|
||||
if (FormApply.isApply(req)) {
|
||||
FormApply.applyResponse("notificationBar.show(" + QuotedStringTokenizer.quote(Messages.Job_you_must_use_the_save_button_if_you_wish()) + ",notificationBar.WARNING)").generateResponse(req, rsp, null);
|
||||
} else {
|
||||
rsp.sendRedirect("rename?newName=" + URLEncoder.encode(newName, "UTF-8"));
|
||||
}
|
||||
} else {
|
||||
if(namingStrategy.isForceExistingJobs()){
|
||||
namingStrategy.checkName(name);
|
||||
@@ -1211,7 +1215,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
|
||||
}
|
||||
|
||||
public Graph getBuildTimeGraph() {
|
||||
return new Graph(getLastBuild().getTimestamp(),500,400) {
|
||||
return new Graph(getLastBuildTime(),500,400) {
|
||||
@Override
|
||||
protected JFreeChart createGraph() {
|
||||
class ChartLabel implements Comparable<ChartLabel> {
|
||||
@@ -1269,7 +1273,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
|
||||
}
|
||||
|
||||
DataSetBuilder<String, ChartLabel> data = new DataSetBuilder<String, ChartLabel>();
|
||||
for (Run r : getBuilds()) {
|
||||
for (Run r : getNewBuilds()) {
|
||||
if (r.isBuilding())
|
||||
continue;
|
||||
data.add(((double) r.getDuration()) / (1000 * 60), "min",
|
||||
@@ -1345,6 +1349,16 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
|
||||
};
|
||||
}
|
||||
|
||||
private Calendar getLastBuildTime() {
|
||||
final RunT lastBuild = getLastBuild();
|
||||
if (lastBuild ==null) {
|
||||
final GregorianCalendar neverBuiltCalendar = new GregorianCalendar();
|
||||
neverBuiltCalendar.setTimeInMillis(0);
|
||||
return neverBuiltCalendar;
|
||||
}
|
||||
return lastBuild.getTimestamp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Renames this job.
|
||||
*/
|
||||
|
||||
@@ -28,6 +28,7 @@ import hudson.Extension;
|
||||
import hudson.Util;
|
||||
import hudson.diagnosis.OldDataMonitor;
|
||||
import hudson.model.Descriptor.FormException;
|
||||
import hudson.model.listeners.ItemListener;
|
||||
import hudson.util.CaseInsensitiveComparator;
|
||||
import hudson.util.DescribableList;
|
||||
import hudson.util.FormValidation;
|
||||
@@ -37,13 +38,18 @@ import hudson.views.ViewJobFilter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
import javax.annotation.concurrent.GuardedBy;
|
||||
import javax.servlet.ServletException;
|
||||
import jenkins.model.Jenkins;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
|
||||
import org.kohsuke.stapler.DataBoundConstructor;
|
||||
import org.kohsuke.stapler.HttpResponse;
|
||||
@@ -302,12 +308,6 @@ public class ListView extends View implements Saveable {
|
||||
return HttpResponses.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onJobRenamed(Item item, String oldName, String newName) {
|
||||
if(jobNames.remove(oldName) && newName!=null)
|
||||
jobNames.add(newName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the configuration submission.
|
||||
*
|
||||
@@ -387,4 +387,56 @@ public class ListView extends View implements Saveable {
|
||||
public static List<ListViewColumn> getDefaultColumns() {
|
||||
return ListViewColumn.createDefaultInitialColumnList();
|
||||
}
|
||||
|
||||
@Restricted(NoExternalUse.class)
|
||||
@Extension public static final class Listener extends ItemListener {
|
||||
@Override public void onLocationChanged(Item item, String oldFullName, String newFullName) {
|
||||
for (Item g : Jenkins.getInstance().getAllItems()) {
|
||||
if (g instanceof ViewGroup) {
|
||||
ViewGroup vg = (ViewGroup) g;
|
||||
for (View v : vg.getViews()) {
|
||||
if (v instanceof ListView) {
|
||||
ListView lv = (ListView) v;
|
||||
synchronized (lv) {
|
||||
Set<String> oldJobNames = new HashSet<String>(lv.jobNames);
|
||||
lv.jobNames.clear();
|
||||
for (String oldName : oldJobNames) {
|
||||
lv.jobNames.add(Items.computeRelativeNamesAfterRenaming(oldFullName, newFullName, oldName, vg.getItemGroup()));
|
||||
}
|
||||
if (!oldJobNames.equals(lv.jobNames)) {
|
||||
try {
|
||||
g.save();
|
||||
} catch (IOException x) {
|
||||
Logger.getLogger(ListView.class.getName()).log(Level.WARNING, null, x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override public void onDeleted(Item item) {
|
||||
for (Item g : Jenkins.getInstance().getAllItems()) {
|
||||
if (g instanceof ViewGroup) {
|
||||
ViewGroup vg = (ViewGroup) g;
|
||||
for (View v : vg.getViews()) {
|
||||
if (v instanceof ListView) {
|
||||
ListView lv = (ListView) v;
|
||||
synchronized (lv) {
|
||||
if (lv.jobNames.remove(item.getRelativeNameFrom(vg.getItemGroup()))) {
|
||||
try {
|
||||
g.save();
|
||||
} catch (IOException x) {
|
||||
Logger.getLogger(ListView.class.getName()).log(Level.WARNING, null, x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2013 Red Hat, 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.model;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* {@link ViewGroup} that can be modified.
|
||||
*
|
||||
* @author ogondza
|
||||
* @since 1.545
|
||||
*/
|
||||
public interface ModifiableViewGroup extends ViewGroup {
|
||||
|
||||
/**
|
||||
* Add new {@link View} to this {@link ViewGroup}.
|
||||
*/
|
||||
public void addView(@Nonnull View view) throws IOException;
|
||||
}
|
||||
@@ -86,11 +86,6 @@ public class MyView extends View {
|
||||
return ""; // there's no configuration page
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJobRenamed(Item item, String oldName, String newName) {
|
||||
// noop
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void submit(StaplerRequest req) throws IOException, ServletException, FormException {
|
||||
// noop
|
||||
|
||||
@@ -58,7 +58,7 @@ import org.kohsuke.stapler.StaplerResponse;
|
||||
*
|
||||
* @author Tom Huybrechts
|
||||
*/
|
||||
public class MyViewsProperty extends UserProperty implements ViewGroup, Action, StaplerFallback {
|
||||
public class MyViewsProperty extends UserProperty implements ModifiableViewGroup, Action, StaplerFallback {
|
||||
private String primaryViewName;
|
||||
|
||||
/**
|
||||
@@ -136,6 +136,7 @@ public class MyViewsProperty extends UserProperty implements ViewGroup, Action,
|
||||
viewGroupMixIn.onViewRenamed(view,oldName,newName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addView(View view) throws IOException {
|
||||
viewGroupMixIn.addView(view);
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ public abstract class Node extends AbstractModelObject implements Reconfigurable
|
||||
* null if this node is not connected hence the path is not available
|
||||
*/
|
||||
// TODO: should this be modified now that getWorkspace is moved from AbstractProject to AbstractBuild?
|
||||
public abstract FilePath getWorkspaceFor(TopLevelItem item);
|
||||
public abstract @CheckForNull FilePath getWorkspaceFor(TopLevelItem item);
|
||||
|
||||
/**
|
||||
* Gets the root directory of this node.
|
||||
@@ -384,7 +384,7 @@ public abstract class Node extends AbstractModelObject implements Reconfigurable
|
||||
* null if the node is offline and hence the {@link FilePath}
|
||||
* object is not available.
|
||||
*/
|
||||
public abstract FilePath getRootPath();
|
||||
public abstract @CheckForNull FilePath getRootPath();
|
||||
|
||||
/**
|
||||
* Gets the {@link FilePath} on this node.
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
package hudson.model;
|
||||
|
||||
import static java.lang.String.format;
|
||||
import hudson.Extension;
|
||||
import hudson.util.PersistedList;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.kohsuke.stapler.Stapler;
|
||||
|
||||
public class PaneStatusProperties extends UserProperty implements Saveable {
|
||||
|
||||
private final PersistedList<String> collapsed = new PersistedList<String>(this);
|
||||
|
||||
private static final PaneStatusProperties FALLBACK = new PaneStatusPropertiesSessionFallback();
|
||||
|
||||
public boolean isCollapsed(String paneId) {
|
||||
return collapsed.contains(paneId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param paneId panel name
|
||||
* @return the actual state of panel
|
||||
*/
|
||||
public boolean toggleCollapsed(String paneId) throws IOException {
|
||||
if (collapsed.contains(paneId)) {
|
||||
collapsed.remove(paneId);
|
||||
return false;
|
||||
} else {
|
||||
collapsed.add(paneId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void save() throws IOException {
|
||||
user.save();
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
collapsed.setOwner(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Extension
|
||||
public static class DescriptorImpl extends UserPropertyDescriptor {
|
||||
|
||||
@Override
|
||||
public UserProperty newInstance(User user) {
|
||||
return new PaneStatusProperties();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class PaneStatusPropertiesSessionFallback extends PaneStatusProperties {
|
||||
|
||||
private final String attribute = "jenkins_pane_%s_collapsed";
|
||||
|
||||
@Override
|
||||
public boolean isCollapsed(String paneId) {
|
||||
final HttpSession session = Stapler.getCurrentRequest().getSession();
|
||||
return session.getAttribute(format(attribute, paneId)) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toggleCollapsed(String paneId) {
|
||||
final HttpSession session = Stapler.getCurrentRequest().getSession();
|
||||
final String property = format(attribute, paneId);
|
||||
final Object collapsed = session.getAttribute(property);
|
||||
if (collapsed == null) {
|
||||
session.setAttribute(property, true);
|
||||
return true;
|
||||
}
|
||||
session.removeAttribute(property);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static PaneStatusProperties forCurrentUser() {
|
||||
final User current = User.current();
|
||||
if (current == null) {
|
||||
return FALLBACK;
|
||||
}
|
||||
return current.getProperty(PaneStatusProperties.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,6 +28,8 @@ import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.DataBoundConstructor;
|
||||
import hudson.Extension;
|
||||
import hudson.util.Secret;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.DoNotUse;
|
||||
|
||||
/**
|
||||
* Parameter whose value is a {@link Secret} and is hidden from the UI.
|
||||
@@ -76,6 +78,11 @@ public class PasswordParameterDefinition extends SimpleParameterDefinition {
|
||||
return Secret.toString(defaultValue);
|
||||
}
|
||||
|
||||
@Restricted(DoNotUse.class) // used from Jelly
|
||||
public Secret getDefaultValueAsSecret() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
// kept for backward compatibility
|
||||
public void setDefaultValue(String defaultValue) {
|
||||
this.defaultValue = Secret.fromString(defaultValue);
|
||||
|
||||
@@ -89,13 +89,6 @@ public class ProxyView extends View implements StaplerFallback {
|
||||
return getProxiedView().contains(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJobRenamed(Item item, String oldName, String newName) {
|
||||
if (oldName.equals(proxiedViewName)) {
|
||||
proxiedViewName = newName;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void submit(StaplerRequest req) throws IOException, ServletException, FormException {
|
||||
String proxiedViewName = req.getSubmittedForm().getString("proxiedViewName");
|
||||
|
||||
@@ -116,6 +116,7 @@ import org.kohsuke.stapler.export.ExportedBean;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter;
|
||||
import javax.annotation.CheckForNull;
|
||||
import org.kohsuke.stapler.QueryParameter;
|
||||
import org.kohsuke.stapler.interceptor.RequirePOST;
|
||||
|
||||
@@ -448,12 +449,9 @@ public class Queue extends ResourceController implements Saveable {
|
||||
|
||||
/**
|
||||
* Schedule a new build for this project.
|
||||
*
|
||||
* @return true if the project is actually added to the queue.
|
||||
* false if the queue contained it and therefore the add()
|
||||
* was noop
|
||||
* @see #schedule(Task, int)
|
||||
*/
|
||||
public WaitingItem schedule(AbstractProject p) {
|
||||
public @CheckForNull WaitingItem schedule(AbstractProject p) {
|
||||
return schedule(p, p.getQuietPeriod());
|
||||
}
|
||||
|
||||
@@ -539,7 +537,7 @@ public class Queue extends ResourceController implements Saveable {
|
||||
shouldScheduleItem |= action.shouldSchedule(actions);
|
||||
}
|
||||
for (QueueAction action: Util.filter(actions,QueueAction.class)) {
|
||||
shouldScheduleItem |= action.shouldSchedule(item.getActions());
|
||||
shouldScheduleItem |= action.shouldSchedule((new ArrayList<Action>(item.getAllActions())));
|
||||
}
|
||||
if(!shouldScheduleItem) {
|
||||
duplicatesInQueue.add(item);
|
||||
@@ -603,7 +601,7 @@ public class Queue extends ResourceController implements Saveable {
|
||||
return schedule(p, quietPeriod)!=null;
|
||||
}
|
||||
|
||||
public synchronized WaitingItem schedule(Task p, int quietPeriod) {
|
||||
public synchronized @CheckForNull WaitingItem schedule(Task p, int quietPeriod) {
|
||||
return schedule(p, quietPeriod, new Action[0]);
|
||||
}
|
||||
|
||||
@@ -618,7 +616,7 @@ public class Queue extends ResourceController implements Saveable {
|
||||
/**
|
||||
* Convenience wrapper method around {@link #schedule(Task, int, List)}
|
||||
*/
|
||||
public synchronized WaitingItem schedule(Task p, int quietPeriod, Action... actions) {
|
||||
public synchronized @CheckForNull WaitingItem schedule(Task p, int quietPeriod, Action... actions) {
|
||||
return schedule2(p, quietPeriod, actions).getCreateItem();
|
||||
}
|
||||
|
||||
@@ -853,8 +851,9 @@ public class Queue extends ResourceController implements Saveable {
|
||||
return bi;
|
||||
|
||||
for (Item item : waitingList) {
|
||||
if (item.task == t)
|
||||
if (item.task.equals(t)) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -870,8 +869,9 @@ public class Queue extends ResourceController implements Saveable {
|
||||
result.addAll(buildables.getAll(t));
|
||||
result.addAll(pendings.getAll(t));
|
||||
for (Item item : waitingList) {
|
||||
if (item.task == t)
|
||||
if (item.task.equals(t)) {
|
||||
result.add(item);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -892,8 +892,9 @@ public class Queue extends ResourceController implements Saveable {
|
||||
if (blockedProjects.containsKey(t) || buildables.containsKey(t) || pendings.containsKey(t))
|
||||
return true;
|
||||
for (Item item : waitingList) {
|
||||
if (item.task == t)
|
||||
if (item.task.equals(t)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1417,7 +1418,7 @@ public class Queue extends ResourceController implements Saveable {
|
||||
}
|
||||
|
||||
protected Item(Item item) {
|
||||
this(item.task, item.getActions(), item.id, item.future, item.inQueueSince);
|
||||
this(item.task, new ArrayList<Action>(item.getAllActions()), item.id, item.future, item.inQueueSince);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1453,13 +1454,10 @@ public class Queue extends ResourceController implements Saveable {
|
||||
@Exported
|
||||
public String getParams() {
|
||||
StringBuilder s = new StringBuilder();
|
||||
for(Action action : getActions()) {
|
||||
if(action instanceof ParametersAction) {
|
||||
ParametersAction pa = (ParametersAction)action;
|
||||
for (ParameterValue p : pa.getParameters()) {
|
||||
s.append('\n').append(p.getShortDescription());
|
||||
}
|
||||
}
|
||||
for (ParametersAction pa : getActions(ParametersAction.class)) {
|
||||
for (ParameterValue p : pa.getParameters()) {
|
||||
s.append('\n').append(p.getShortDescription());
|
||||
}
|
||||
}
|
||||
return s.toString();
|
||||
}
|
||||
@@ -2003,7 +2001,7 @@ public class Queue extends ResourceController implements Saveable {
|
||||
private class ItemList<T extends Item> extends ArrayList<T> {
|
||||
public T get(Task task) {
|
||||
for (T item: this) {
|
||||
if (item.task == task) {
|
||||
if (item.task.equals(task)) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -2013,7 +2011,7 @@ public class Queue extends ResourceController implements Saveable {
|
||||
public List<T> getAll(Task task) {
|
||||
List<T> result = new ArrayList<T>();
|
||||
for (T item: this) {
|
||||
if (item.task == task) {
|
||||
if (item.task.equals(task)) {
|
||||
result.add(item);
|
||||
}
|
||||
}
|
||||
@@ -2028,7 +2026,7 @@ public class Queue extends ResourceController implements Saveable {
|
||||
Iterator<T> it = iterator();
|
||||
while (it.hasNext()) {
|
||||
T t = it.next();
|
||||
if (t.task == task) {
|
||||
if (t.task.equals(task)) {
|
||||
it.remove();
|
||||
return t;
|
||||
}
|
||||
@@ -2037,7 +2035,7 @@ public class Queue extends ResourceController implements Saveable {
|
||||
}
|
||||
|
||||
public void put(Task task, T item) {
|
||||
assert item.task == task;
|
||||
assert item.task.equals(task);
|
||||
add(item);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ import hudson.tasks.test.AbstractTestResultAction;
|
||||
import hudson.util.FlushProofOutputStream;
|
||||
import hudson.util.FormApply;
|
||||
import hudson.util.LogTaskListener;
|
||||
import hudson.util.ProcessTree;
|
||||
import hudson.util.XStream2;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@@ -210,7 +211,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
|
||||
/**
|
||||
* The current build state.
|
||||
*/
|
||||
protected volatile transient State state;
|
||||
private volatile transient State state;
|
||||
|
||||
private static enum State {
|
||||
/**
|
||||
@@ -331,7 +332,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
protected void onLoad() {
|
||||
for (Action a : getActions()) {
|
||||
for (Action a : getAllActions()) {
|
||||
if (a instanceof RunAction2) {
|
||||
((RunAction2) a).onLoad(this);
|
||||
} else if (a instanceof RunAction) {
|
||||
@@ -347,7 +348,9 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
|
||||
* Return all transient actions associated with this build.
|
||||
*
|
||||
* @return the list can be empty but never null. read only.
|
||||
* @deprecated Use {@link #getAllActions} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public List<Action> getTransientActions() {
|
||||
List<Action> actions = new ArrayList<Action>();
|
||||
for (TransientBuildActionFactory factory: TransientBuildActionFactory.all()) {
|
||||
@@ -442,21 +445,11 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
|
||||
* Gets the subset of {@link #getActions()} that consists of {@link BuildBadgeAction}s.
|
||||
*/
|
||||
public List<BuildBadgeAction> getBadgeActions() {
|
||||
List<BuildBadgeAction> r = null;
|
||||
for (Action a : getActions()) {
|
||||
if(a instanceof BuildBadgeAction) {
|
||||
if(r==null)
|
||||
r = new ArrayList<BuildBadgeAction>();
|
||||
r.add((BuildBadgeAction)a);
|
||||
}
|
||||
}
|
||||
List<BuildBadgeAction> r = getActions(BuildBadgeAction.class);
|
||||
if(isKeepLog()) {
|
||||
if(r==null)
|
||||
r = new ArrayList<BuildBadgeAction>();
|
||||
r.add(new KeepLogBuildBadge());
|
||||
}
|
||||
if(r==null) return Collections.emptyList();
|
||||
else return r;
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1252,7 +1245,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
|
||||
|
||||
/**
|
||||
* Gets the artifact file.
|
||||
* @deprecated May not be meaningful with custom artifact managers. Use {@link ArtifactManager#load} with {@link #relativePath} instead.
|
||||
* @deprecated May not be meaningful with custom artifact managers. Use {@link ArtifactManager#root} plus {@link VirtualFile#child} with {@link #relativePath} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public File getFile() {
|
||||
@@ -1370,10 +1363,16 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
|
||||
public void writeWholeLogTo(OutputStream out) throws IOException, InterruptedException {
|
||||
long pos = 0;
|
||||
AnnotatedLargeText logText;
|
||||
do {
|
||||
logText = getLogText();
|
||||
pos = logText.writeLogTo(pos, out);
|
||||
|
||||
while (!logText.isComplete()) {
|
||||
// Instead of us hitting the log file as many times as possible, instead we get the information once every
|
||||
// second to avoid CPU usage getting very high.
|
||||
Thread.sleep(1000);
|
||||
logText = getLogText();
|
||||
pos = logText.writeLogTo(pos, out);
|
||||
} while (!logText.isComplete());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1388,7 +1387,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
|
||||
SearchIndexBuilder builder = super.makeSearchIndex()
|
||||
.add("console")
|
||||
.add("changes");
|
||||
for (Action a : getActions()) {
|
||||
for (Action a : getAllActions()) {
|
||||
if(a.getIconFileName()!=null)
|
||||
builder.add(a.getUrlName());
|
||||
}
|
||||
@@ -2093,7 +2092,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
|
||||
}
|
||||
|
||||
public void keepLog(boolean newValue) throws IOException {
|
||||
checkPermission(UPDATE);
|
||||
checkPermission(newValue ? UPDATE : DELETE);
|
||||
keepLog = newValue;
|
||||
save();
|
||||
}
|
||||
@@ -2123,7 +2122,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
|
||||
req.setAttribute("stackTraces", writer);
|
||||
req.getView(this, "delete-retry.jelly").forward(req, rsp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
rsp.sendRedirect2(req.getContextPath()+'/' + getParent().getUrl());
|
||||
}
|
||||
|
||||
|
||||
@@ -194,24 +194,21 @@ public final class RunMap<R extends Run<?,R>> extends AbstractLazyLoadRunMap<R>
|
||||
final SimpleDateFormat formatter = Run.ID_FORMATTER.get();
|
||||
|
||||
return new FilenameFilter() {
|
||||
public boolean accept(File dir, String name) {
|
||||
// JENKINS-1461 sometimes create bogus data directories with impossible dates, such as year 0, April 31st,
|
||||
// or August 0th. Date object doesn't roundtrip those, so we eventually fail to load this data.
|
||||
// Don't even bother trying.
|
||||
if (!isCorrectDate(name)) {
|
||||
LOGGER.log(FINE, "Skipping {0}", new File(dir,name));
|
||||
@Override public boolean accept(File dir, String name) {
|
||||
if (name.startsWith("0000")) {
|
||||
// JENKINS-1461 sometimes create bogus data directories with impossible dates, such as year 0, April 31st,
|
||||
// or August 0th. Date object doesn't roundtrip those, so we eventually fail to load this data.
|
||||
// Don't even bother trying.
|
||||
return false;
|
||||
}
|
||||
return !name.startsWith("0000") && new File(dir,name).isDirectory();
|
||||
}
|
||||
|
||||
private boolean isCorrectDate(String name) {
|
||||
try {
|
||||
if(formatter.format(formatter.parse(name)).equals(name))
|
||||
if (formatter.format(formatter.parse(name)).equals(name)) {
|
||||
return true;
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
// fall through
|
||||
}
|
||||
LOGGER.log(FINE, "Skipping {0} in {1}", new Object[] {name, dir});
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -57,6 +57,7 @@ import java.util.Set;
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import hudson.util.TimeUnit2;
|
||||
import javax.annotation.CheckForNull;
|
||||
import jenkins.model.Jenkins;
|
||||
import jenkins.slaves.WorkspaceLocator;
|
||||
|
||||
@@ -284,7 +285,7 @@ public abstract class Slave extends Node implements Serializable {
|
||||
* @return
|
||||
* null if not connected.
|
||||
*/
|
||||
public FilePath getWorkspaceRoot() {
|
||||
public @CheckForNull FilePath getWorkspaceRoot() {
|
||||
FilePath r = getRootPath();
|
||||
if(r==null) return null;
|
||||
return r.child(WORKSPACE_ROOT);
|
||||
|
||||
@@ -6,6 +6,7 @@ import hudson.ExtensionPoint;
|
||||
import jenkins.model.Jenkins;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import jenkins.model.TransientActionFactory;
|
||||
|
||||
/**
|
||||
* Extension point for inserting transient {@link Action}s into {@link Run}s.
|
||||
@@ -15,8 +16,9 @@ import java.util.Collections;
|
||||
* @author Lucie Votypkova
|
||||
* @since 1.458
|
||||
* @see Action
|
||||
* @deprecated Does not contribute to {@link Run#getActions}. Use {@link TransientActionFactory} instead.
|
||||
*/
|
||||
|
||||
@Deprecated
|
||||
public abstract class TransientBuildActionFactory implements ExtensionPoint {
|
||||
/**
|
||||
* Creates actions for the given build.
|
||||
|
||||
@@ -30,6 +30,7 @@ import jenkins.model.Jenkins;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import jenkins.model.TransientActionFactory;
|
||||
|
||||
/**
|
||||
* Extension point for inserting transient {@link hudson.model.Action}s to {@link hudson.model.Computer}s.
|
||||
@@ -39,6 +40,7 @@ import java.util.List;
|
||||
* @author Stephen Connolly
|
||||
* @since 1.405
|
||||
* @see hudson.model.Action
|
||||
* @see TransientActionFactory
|
||||
*/
|
||||
public abstract class TransientComputerActionFactory implements ExtensionPoint {
|
||||
/**
|
||||
|
||||
@@ -30,6 +30,7 @@ import hudson.tasks.BuildStep;
|
||||
import jenkins.model.Jenkins;
|
||||
|
||||
import java.util.Collection;
|
||||
import jenkins.model.TransientActionFactory;
|
||||
|
||||
/**
|
||||
* Extension point for inserting transient {@link Action}s into {@link AbstractProject}s.
|
||||
@@ -50,6 +51,7 @@ import java.util.Collection;
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @since 1.327
|
||||
* @see Action
|
||||
* @see TransientActionFactory
|
||||
*/
|
||||
public abstract class TransientProjectActionFactory implements ExtensionPoint {
|
||||
/**
|
||||
|
||||
@@ -119,14 +119,7 @@ public class TreeView extends View implements ViewGroup {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onJobRenamed(Item item, String oldName, String newName) {
|
||||
if(jobNames.remove(oldName) && newName!=null)
|
||||
jobNames.add(newName);
|
||||
// forward to children
|
||||
for (View v : views)
|
||||
v.onJobRenamed(item,oldName,newName);
|
||||
}
|
||||
// TODO listen for changes that might affect jobNames
|
||||
|
||||
protected void submit(StaplerRequest req) throws IOException, ServletException, FormException {
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import jenkins.model.Jenkins;
|
||||
import jenkins.util.JSONSignatureValidator;
|
||||
import net.sf.json.JSONException;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.kohsuke.stapler.DataBoundConstructor;
|
||||
import org.kohsuke.stapler.HttpResponse;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
@@ -637,8 +638,12 @@ public class UpdateSite {
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
if(title!=null) return title;
|
||||
return name;
|
||||
String displayName;
|
||||
if(title!=null)
|
||||
displayName = title;
|
||||
else
|
||||
displayName = name;
|
||||
return StringUtils.removeStart(displayName, "Jenkins ");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -156,7 +156,7 @@ public class UsageStatistics extends PageDecorator {
|
||||
o.put("plugins",plugins);
|
||||
|
||||
JSONObject jobs = new JSONObject();
|
||||
List<TopLevelItem> items = j.getItems();
|
||||
List<TopLevelItem> items = j.getAllItems(TopLevelItem.class);
|
||||
for (TopLevelItemDescriptor d : Items.all()) {
|
||||
int cnt=0;
|
||||
for (TopLevelItem item : items) {
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
package hudson.model;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
||||
import hudson.*;
|
||||
import hudson.model.Descriptor.FormException;
|
||||
@@ -349,9 +350,13 @@ public class User extends AbstractModelObject implements AccessControlled, Descr
|
||||
if (LOGGER.isLoggable(Level.FINE) && !fullName.equals(prev.getFullName())) {
|
||||
LOGGER.log(Level.FINE, "mismatch on fullName (‘" + fullName + "’ vs. ‘" + prev.getFullName() + "’) for ‘" + id + "’", new Throwable());
|
||||
}
|
||||
}
|
||||
if (LOGGER.isLoggable(Level.FINE) && id.equals(fullName) && fullName.matches(".+ _\\S+@\\S+_")) {
|
||||
LOGGER.log(Level.FINE, "[JENKINS-16332] Suspicious fullName being stored: " + fullName, new Throwable());
|
||||
} else if (!id.equals(fullName) && !getConfigFileFor(id).exists()) {
|
||||
// JENKINS-16332: since the fullName may not be recoverable from the id, and various code may store the id only, we must save the fullName
|
||||
try {
|
||||
u.save();
|
||||
} catch (IOException x) {
|
||||
LOGGER.log(Level.WARNING, null, x);
|
||||
}
|
||||
}
|
||||
}
|
||||
return u;
|
||||
@@ -432,30 +437,33 @@ public class User extends AbstractModelObject implements AccessControlled, Descr
|
||||
return getFullName();
|
||||
}
|
||||
|
||||
/** true if {@link AbstractBuild#hasParticipant} or {@link hudson.model.Cause.UserIdCause} */
|
||||
private boolean relatedTo(AbstractBuild<?,?> b) {
|
||||
if (b.hasParticipant(this)) {
|
||||
return true;
|
||||
}
|
||||
for (Cause cause : b.getCauses()) {
|
||||
if (cause instanceof Cause.UserIdCause) {
|
||||
String userId = ((Cause.UserIdCause) cause).getUserId();
|
||||
if (userId != null && userId.equals(getId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of {@link Build}s that include changes by this user,
|
||||
* by the timestamp order.
|
||||
*
|
||||
* TODO: do we need some index for this?
|
||||
*/
|
||||
@WithBridgeMethods(List.class)
|
||||
public RunList getBuilds() {
|
||||
List<AbstractBuild> r = new ArrayList<AbstractBuild>();
|
||||
for (AbstractProject<?,?> p : Jenkins.getInstance().getAllItems(AbstractProject.class))
|
||||
for (AbstractBuild<?,?> b : p.getBuilds().newBuilds()){
|
||||
if(b.hasParticipant(this))
|
||||
r.add(b);
|
||||
else {
|
||||
//append builds that were run by this user
|
||||
Cause.UserIdCause cause = b.getCause(Cause.UserIdCause.class);
|
||||
if (cause != null) {
|
||||
String userId = cause.getUserId();
|
||||
if (userId != null && this.getId() != null && userId.equals(this.getId()))
|
||||
r.add(b);
|
||||
}
|
||||
}
|
||||
return new RunList<Run<?,?>>(Jenkins.getInstance().getAllItems(Job.class)).filter(new Predicate<Run<?,?>>() {
|
||||
@Override public boolean apply(Run<?,?> r) {
|
||||
return r instanceof AbstractBuild && relatedTo((AbstractBuild<?,?>) r);
|
||||
}
|
||||
return RunList.fromRuns(r);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -573,21 +581,18 @@ public class User extends AbstractModelObject implements AccessControlled, Descr
|
||||
}
|
||||
|
||||
public void doRssAll(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
|
||||
rss(req, rsp, " all builds", RunList.fromRuns(getBuilds()), Run.FEED_ADAPTER);
|
||||
rss(req, rsp, " all builds", getBuilds(), Run.FEED_ADAPTER);
|
||||
}
|
||||
|
||||
public void doRssFailed(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
|
||||
rss(req, rsp, " regression builds", RunList.fromRuns(getBuilds()).regressionOnly(), Run.FEED_ADAPTER);
|
||||
rss(req, rsp, " regression builds", getBuilds().regressionOnly(), Run.FEED_ADAPTER);
|
||||
}
|
||||
|
||||
public void doRssLatest(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
|
||||
final List<Run> lastBuilds = new ArrayList<Run>();
|
||||
for (final TopLevelItem item : Jenkins.getInstance().getItems()) {
|
||||
if (!(item instanceof Job)) continue;
|
||||
for (Run r = ((Job) item).getLastBuild(); r != null; r = r.getPreviousBuild()) {
|
||||
if (!(r instanceof AbstractBuild)) continue;
|
||||
final AbstractBuild b = (AbstractBuild) r;
|
||||
if (b.hasParticipant(this)) {
|
||||
for (AbstractProject<?,?> p : Jenkins.getInstance().getAllItems(AbstractProject.class)) {
|
||||
for (AbstractBuild<?,?> b = p.getLastBuild(); b != null; b = b.getPreviousBuild()) {
|
||||
if (relatedTo(b)) {
|
||||
lastBuilds.add(b);
|
||||
break;
|
||||
}
|
||||
@@ -668,6 +673,7 @@ public class User extends AbstractModelObject implements AccessControlled, Descr
|
||||
r.add(n);
|
||||
}
|
||||
}
|
||||
Collections.sort(r, String.CASE_INSENSITIVE_ORDER);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
* This is an extension point in Hudson, allowing different kind of
|
||||
* rendering to be added as plugins.
|
||||
*
|
||||
* <h2>Note for implementors</h2>
|
||||
* <h2>Note for implementers</h2>
|
||||
* <ul>
|
||||
* <li>
|
||||
* {@link View} subtypes need the <tt>newViewDetail.jelly</tt> page,
|
||||
@@ -436,22 +436,21 @@ public abstract class View extends AbstractModelObject implements AccessControll
|
||||
}
|
||||
|
||||
for (Computer c : computers) {
|
||||
Node n = c.getNode();
|
||||
if (n != null) {
|
||||
if (labels.contains(null) && n.getMode() == Mode.NORMAL || !isDisjoint(n.getAssignedLabels(), labels)) {
|
||||
result.add(c);
|
||||
}
|
||||
}
|
||||
if (isRelevant(labels, c)) result.add(c);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean isDisjoint(Collection c1, Collection c2) {
|
||||
for (Object o : c1)
|
||||
if (c2.contains(o))
|
||||
return false;
|
||||
return true;
|
||||
private boolean isRelevant(Collection<Label> labels, Computer computer) {
|
||||
Node node = computer.getNode();
|
||||
if (node == null) return false;
|
||||
if (labels.contains(null) && node.getMode() == Mode.NORMAL) return true;
|
||||
|
||||
for (Label l : labels)
|
||||
if (l != null && l.contains(node))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private List<Queue.Item> filterQueue(List<Queue.Item> base) {
|
||||
@@ -581,21 +580,9 @@ public abstract class View extends AbstractModelObject implements AccessControll
|
||||
return getACL().hasPermission(p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a job name is changed or deleted.
|
||||
*
|
||||
* <p>
|
||||
* If this view contains this job, it should update the view membership so that
|
||||
* the renamed job will remain in the view, and the deleted job is removed.
|
||||
*
|
||||
* @param item
|
||||
* The item whose name is being changed.
|
||||
* @param oldName
|
||||
* Old name of the item. Always non-null.
|
||||
* @param newName
|
||||
* New name of the item, if the item is renamed. Or null, if the item is removed.
|
||||
*/
|
||||
public abstract void onJobRenamed(Item item, String oldName, String newName);
|
||||
/** @deprecated Does not work properly with moved jobs. Use {@link ItemListener#onLocationChanged} instead. */
|
||||
@Deprecated
|
||||
public void onJobRenamed(Item item, String oldName, String newName) {}
|
||||
|
||||
@ExportedBean(defaultVisibility=2)
|
||||
public static final class UserInfo implements Comparable<UserInfo> {
|
||||
@@ -796,7 +783,7 @@ public abstract class View extends AbstractModelObject implements AccessControll
|
||||
|
||||
{
|
||||
StaplerRequest req = Stapler.getCurrentRequest();
|
||||
iconSize = req != null ? Functions.getCookie(req, "iconSize", "32x32") : "32x32";
|
||||
iconSize = req != null ? Functions.validateIconSize(Functions.getCookie(req, "iconSize", "32x32")) : "32x32";
|
||||
}
|
||||
|
||||
@Override protected void compute() throws Exception {
|
||||
@@ -845,6 +832,9 @@ public abstract class View extends AbstractModelObject implements AccessControll
|
||||
return;
|
||||
}
|
||||
for (User u : User.getAll()) { // TODO nice to have a method to iterate these lazily
|
||||
if (canceled()) {
|
||||
return;
|
||||
}
|
||||
if (u == unknown) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import hudson.views.ListViewColumnDescriptor;
|
||||
import hudson.views.ViewJobFilter;
|
||||
import jenkins.model.Jenkins;
|
||||
import org.kohsuke.stapler.QueryParameter;
|
||||
import org.kohsuke.stapler.AncestorInPath;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -67,10 +68,8 @@ public abstract class ViewDescriptor extends Descriptor<View> {
|
||||
protected ViewDescriptor() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto-completion for the "copy from" field in the new job page.
|
||||
*/
|
||||
public AutoCompletionCandidates doAutoCompleteCopyNewItemFrom(@QueryParameter final String value) {
|
||||
@Deprecated
|
||||
public AutoCompletionCandidates doAutoCompleteCopyNewItemFrom(final String prefix) {
|
||||
final AutoCompletionCandidates r = new AutoCompletionCandidates();
|
||||
|
||||
new ItemVisitor() {
|
||||
@@ -78,13 +77,13 @@ public abstract class ViewDescriptor extends Descriptor<View> {
|
||||
public void onItemGroup(ItemGroup<?> group) {
|
||||
// only dig deep when the path matches what's typed.
|
||||
// for example, if 'foo/bar' is typed, we want to show 'foo/barcode'
|
||||
if (value.startsWith(group.getFullName()))
|
||||
if (prefix.startsWith(group.getFullName()))
|
||||
super.onItemGroup(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItem(Item i) {
|
||||
if (i.getFullName().startsWith(value)) {
|
||||
if (i.getFullName().startsWith(prefix)) {
|
||||
r.add((i.getFullName()));
|
||||
super.onItem(i);
|
||||
}
|
||||
@@ -94,6 +93,14 @@ public abstract class ViewDescriptor extends Descriptor<View> {
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto-completion for the "copy from" field in the new job page.
|
||||
* @since 1.553
|
||||
*/
|
||||
public AutoCompletionCandidates doAutoCompleteCopyNewItemFrom(@QueryParameter final String value, @AncestorInPath ItemGroup container) {
|
||||
return AutoCompletionCandidates.ofJobNames(TopLevelItem.class, value, container);
|
||||
}
|
||||
|
||||
/**
|
||||
* Possible {@link ListViewColumnDescriptor}s that can be used with this view.
|
||||
*/
|
||||
|
||||
@@ -23,18 +23,18 @@
|
||||
*/
|
||||
package hudson.model;
|
||||
|
||||
import hudson.Extension;
|
||||
import hudson.FilePath;
|
||||
import hudson.Util;
|
||||
import hudson.Extension;
|
||||
import jenkins.model.Jenkins;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.annotation.Nonnull;
|
||||
import jenkins.model.Jenkins;
|
||||
import jenkins.model.ModifiableTopLevelItemGroup;
|
||||
|
||||
/**
|
||||
* Clean up old left-over workspaces from slaves.
|
||||
@@ -47,7 +47,7 @@ public class WorkspaceCleanupThread extends AsyncPeriodicWork {
|
||||
super("Workspace clean-up");
|
||||
}
|
||||
|
||||
public long getRecurrencePeriod() {
|
||||
@Override public long getRecurrencePeriod() {
|
||||
return DAY;
|
||||
}
|
||||
|
||||
@@ -55,121 +55,87 @@ public class WorkspaceCleanupThread extends AsyncPeriodicWork {
|
||||
Jenkins.getInstance().getExtensionList(AsyncPeriodicWork.class).get(WorkspaceCleanupThread.class).run();
|
||||
}
|
||||
|
||||
// so that this can be easily accessed from sub-routine.
|
||||
private TaskListener listener;
|
||||
|
||||
protected void execute(TaskListener listener) throws InterruptedException, IOException {
|
||||
try {
|
||||
if(disabled) {
|
||||
LOGGER.fine("Disabled. Skipping execution");
|
||||
return;
|
||||
}
|
||||
|
||||
this.listener = listener;
|
||||
|
||||
Jenkins h = Jenkins.getInstance();
|
||||
for (Node n : h.getNodes())
|
||||
if (n instanceof Slave) process((Slave)n);
|
||||
|
||||
process(h);
|
||||
} finally {
|
||||
this.listener = null;
|
||||
@Override protected void execute(TaskListener listener) throws InterruptedException, IOException {
|
||||
if (disabled) {
|
||||
LOGGER.fine("Disabled. Skipping execution");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void process(Jenkins h) throws IOException, InterruptedException {
|
||||
File jobs = new File(h.getRootDir(), "jobs");
|
||||
File[] dirs = jobs.listFiles(DIR_FILTER);
|
||||
if(dirs==null) return;
|
||||
for (File dir : dirs) {
|
||||
FilePath ws = new FilePath(new File(dir, "workspace"));
|
||||
if(shouldBeDeleted(dir.getName(),ws,h)) {
|
||||
delete(ws);
|
||||
List<Node> nodes = new ArrayList<Node>();
|
||||
Jenkins j = Jenkins.getInstance();
|
||||
nodes.add(j);
|
||||
nodes.addAll(j.getNodes());
|
||||
for (TopLevelItem item : j.getAllItems(TopLevelItem.class)) {
|
||||
if (item instanceof ModifiableTopLevelItemGroup) { // no such thing as TopLevelItemGroup, and ItemGroup offers no access to its type parameter
|
||||
continue; // children will typically have their own workspaces as subdirectories; probably no real workspace of its own
|
||||
}
|
||||
listener.getLogger().println("Checking " + item.getFullDisplayName());
|
||||
for (Node node : nodes) {
|
||||
FilePath ws = node.getWorkspaceFor(item);
|
||||
if (ws == null) {
|
||||
continue; // offline, fine
|
||||
}
|
||||
boolean check;
|
||||
try {
|
||||
check = shouldBeDeleted(item, ws, node);
|
||||
} catch (IOException x) {
|
||||
x.printStackTrace(listener.error("Failed to check " + node.getDisplayName()));
|
||||
continue;
|
||||
} catch (InterruptedException x) {
|
||||
x.printStackTrace(listener.error("Failed to check " + node.getDisplayName()));
|
||||
continue;
|
||||
}
|
||||
if (check) {
|
||||
listener.getLogger().println("Deleting " + ws + " on " + node.getDisplayName());
|
||||
try {
|
||||
ws.deleteRecursive();
|
||||
} catch (IOException x) {
|
||||
x.printStackTrace(listener.error("Failed to delete " + ws + " on " + node.getDisplayName()));
|
||||
} catch (InterruptedException x) {
|
||||
x.printStackTrace(listener.error("Failed to delete " + ws + " on " + node.getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldBeDeleted(String workspaceDirectoryName, FilePath dir, Node n) throws IOException, InterruptedException {
|
||||
private boolean shouldBeDeleted(@Nonnull TopLevelItem item, FilePath dir, Node n) throws IOException, InterruptedException {
|
||||
// TODO: the use of remoting is not optimal.
|
||||
// One remoting can execute "exists", "lastModified", and "delete" all at once.
|
||||
TopLevelItem item = Jenkins.getInstance().getItem(workspaceDirectoryName);
|
||||
|
||||
if(!dir.exists())
|
||||
// (Could even invert master loop so that one FileCallable takes care of all known items.)
|
||||
if(!dir.exists()) {
|
||||
LOGGER.log(Level.FINE, "Directory {0} does not exist", dir);
|
||||
return false;
|
||||
}
|
||||
|
||||
// if younger than a month, keep it
|
||||
long now = new Date().getTime();
|
||||
if(dir.lastModified() + 30 * DAY > now) {
|
||||
LOGGER.fine("Directory "+dir+" is only "+ Util.getTimeSpanString(now-dir.lastModified())+" old, so not deleting");
|
||||
LOGGER.log(Level.FINE, "Directory {0} is only {1} old, so not deleting", new Object[] {dir, Util.getTimeSpanString(now-dir.lastModified())});
|
||||
return false;
|
||||
}
|
||||
|
||||
// Could mean that directory doesn't belong to a job. But can also mean that it's a custom workspace belonging to a job.
|
||||
// So better leave it alone - will still be deleted after 30 days - until we have a proper check for custom workspaces.
|
||||
// TODO: implement proper check for custom workspaces.
|
||||
// TODO: If we do the above, could also be good to add checkbox that lets users configure a workspace to never be auto-cleaned.
|
||||
if(item==null) {
|
||||
return false;
|
||||
}
|
||||
// TODO could also be good to add checkbox that lets users configure a workspace to never be auto-cleaned.
|
||||
|
||||
if (item instanceof AbstractProject<?,?>) {
|
||||
AbstractProject<?,?> p = (AbstractProject<?,?>) item;
|
||||
Node lb = p.getLastBuiltOn();
|
||||
LOGGER.finer("Directory "+dir+" is last built on "+lb);
|
||||
LOGGER.log(Level.FINER, "Directory {0} is last built on {1}", new Object[] {dir, lb});
|
||||
if(lb!=null && lb.equals(n)) {
|
||||
// this is the active workspace. keep it.
|
||||
LOGGER.fine("Directory "+dir+" is the last workspace for "+p);
|
||||
LOGGER.log(Level.FINE, "Directory {0} is the last workspace for {1}", new Object[] {dir, p});
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!p.getScm().processWorkspaceBeforeDeletion(p,dir,n)) {
|
||||
LOGGER.fine("Directory deletion of "+dir+" is vetoed by SCM");
|
||||
LOGGER.log(Level.FINE, "Directory deletion of {0} is vetoed by SCM", dir);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
LOGGER.finer("Going to delete directory "+dir);
|
||||
LOGGER.log(Level.FINER, "Going to delete directory {0}", dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void process(Slave s) throws InterruptedException {
|
||||
listener.getLogger().println("Scanning "+s.getNodeName());
|
||||
|
||||
try {
|
||||
FilePath path = s.getWorkspaceRoot();
|
||||
if(path==null) return;
|
||||
|
||||
List<FilePath> dirs = path.list(DIR_FILTER);
|
||||
if(dirs ==null) return;
|
||||
for (FilePath dir : dirs) {
|
||||
if(shouldBeDeleted(dir.getName(),dir,s))
|
||||
delete(dir);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace(listener.error("Failed on "+s.getNodeName()));
|
||||
}
|
||||
}
|
||||
|
||||
private void delete(FilePath dir) throws InterruptedException {
|
||||
try {
|
||||
listener.getLogger().println("Deleting "+dir);
|
||||
dir.deleteRecursive();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace(listener.error("Failed to delete "+dir));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class DirectoryFilter implements FileFilter, Serializable {
|
||||
public boolean accept(File f) {
|
||||
return f.isDirectory();
|
||||
}
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
private static final FileFilter DIR_FILTER = new DirectoryFilter();
|
||||
|
||||
private static final long DAY = 1000*60*60*24;
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(WorkspaceCleanupThread.class.getName());
|
||||
|
||||
/**
|
||||
|
||||
@@ -93,6 +93,7 @@ public class LabelAtom extends Label implements Saveable {
|
||||
* {@link LabelAtomProperty}s who want to add a project action
|
||||
* should do so by implementing {@link LabelAtomProperty#getActions(LabelAtom)}.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public List<Action> getActions() {
|
||||
// add all the transient actions, too
|
||||
|
||||
@@ -28,6 +28,8 @@ import hudson.ExtensionList;
|
||||
import hudson.Extension;
|
||||
import jenkins.model.Jenkins;
|
||||
import hudson.model.Item;
|
||||
import hudson.model.ItemGroup;
|
||||
import hudson.model.Items;
|
||||
|
||||
/**
|
||||
* Receives notifications about CRUD operations of {@link Item}.
|
||||
@@ -82,7 +84,7 @@ public class ItemListener implements ExtensionPoint {
|
||||
|
||||
/**
|
||||
* Called after a job is renamed.
|
||||
*
|
||||
* Most implementers should rather use {@link #onLocationChanged}.
|
||||
* @param item
|
||||
* The job being renamed.
|
||||
* @param oldName
|
||||
@@ -94,6 +96,28 @@ public class ItemListener implements ExtensionPoint {
|
||||
public void onRenamed(Item item, String oldName, String newName) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after an item’s fully-qualified location has changed.
|
||||
* This might be because:
|
||||
* <ul>
|
||||
* <li>This item was renamed.
|
||||
* <li>Some ancestor folder was renamed.
|
||||
* <li>This item was moved between folders (or from a folder to Jenkins root or vice-versa).
|
||||
* <li>Some ancestor folder was moved.
|
||||
* </ul>
|
||||
* Where applicable, {@link #onRenamed} will already have been called on this item or an ancestor.
|
||||
* And where applicable, {@link #onLocationChanged} will already have been called on its ancestors.
|
||||
* <p>This method should be used (instead of {@link #onRenamed}) by any code
|
||||
* which seeks to keep (absolute) references to items up to date:
|
||||
* if a persisted reference matches {@code oldFullName}, replace it with {@code newFullName}.
|
||||
* @param item an item whose absolute position is now different
|
||||
* @param oldFullName the former {@link Item#getFullName}
|
||||
* @param newFullName the current {@link Item#getFullName}
|
||||
* @see Items#computeRelativeNamesAfterRenaming
|
||||
* @since 1.548
|
||||
*/
|
||||
public void onLocationChanged(Item item, String oldFullName, String newFullName) {}
|
||||
|
||||
/**
|
||||
* Called after a job has its configuration updated.
|
||||
*
|
||||
@@ -141,4 +165,50 @@ public class ItemListener implements ExtensionPoint {
|
||||
for (ItemListener l : all())
|
||||
l.onUpdated(item);
|
||||
}
|
||||
|
||||
/** @since 1.548 */
|
||||
public static void fireOnDeleted(Item item) {
|
||||
for (ItemListener l : all()) {
|
||||
l.onDeleted(item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link #onRenamed} and {@link #onLocationChanged} as appropriate.
|
||||
* @param rootItem the topmost item whose location has just changed
|
||||
* @param oldFullName the previous {@link Item#getFullName}
|
||||
* @since 1.548
|
||||
*/
|
||||
public static void fireLocationChange(Item rootItem, String oldFullName) {
|
||||
String prefix = rootItem.getParent().getFullName();
|
||||
if (!prefix.isEmpty()) {
|
||||
prefix += '/';
|
||||
}
|
||||
String newFullName = rootItem.getFullName();
|
||||
assert newFullName.startsWith(prefix);
|
||||
int prefixS = prefix.length();
|
||||
if (oldFullName.startsWith(prefix) && oldFullName.indexOf('/', prefixS) == -1) {
|
||||
String oldName = oldFullName.substring(prefixS);
|
||||
String newName = rootItem.getName();
|
||||
assert newName.equals(newFullName.substring(prefixS));
|
||||
for (ItemListener l : all()) {
|
||||
l.onRenamed(rootItem, oldName, newName);
|
||||
}
|
||||
}
|
||||
for (ItemListener l : all()) {
|
||||
l.onLocationChanged(rootItem, oldFullName, newFullName);
|
||||
}
|
||||
if (rootItem instanceof ItemGroup) {
|
||||
for (Item child : Items.getAllItems((ItemGroup) rootItem, Item.class)) {
|
||||
String childNew = child.getFullName();
|
||||
assert childNew.startsWith(newFullName);
|
||||
assert childNew.charAt(newFullName.length()) == '/';
|
||||
String childOld = oldFullName + childNew.substring(newFullName.length());
|
||||
for (ItemListener l : all()) {
|
||||
l.onLocationChanged(child, childOld, childNew);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -92,7 +92,8 @@ public abstract class CauseOfBlockage {
|
||||
}
|
||||
|
||||
public String getShortDescription() {
|
||||
return Messages.Queue_NodeOffline(node.getDisplayName());
|
||||
String name = (node.toComputer() != null) ? node.toComputer().getDisplayName() : node.getDisplayName();
|
||||
return Messages.Queue_NodeOffline(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,7 +129,8 @@ public abstract class CauseOfBlockage {
|
||||
}
|
||||
|
||||
public String getShortDescription() {
|
||||
return Messages.Queue_WaitingForNextAvailableExecutorOn(node.getNodeName());
|
||||
String name = (node.toComputer() != null) ? node.toComputer().getDisplayName() : node.getDisplayName();
|
||||
return Messages.Queue_WaitingForNextAvailableExecutorOn(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,6 +5,7 @@ import hudson.model.Queue;
|
||||
import hudson.model.Queue.Item;
|
||||
import hudson.model.Queue.Task;
|
||||
import hudson.model.Queue.WaitingItem;
|
||||
import javax.annotation.CheckForNull;
|
||||
|
||||
/**
|
||||
* Result of {@link Queue#schedule2}
|
||||
@@ -36,7 +37,7 @@ public abstract class ScheduleResult {
|
||||
* the newly created item in the queue or the existing item that's already
|
||||
* in the queue that matched the submitted task.
|
||||
*/
|
||||
public Item getItem() {
|
||||
public @CheckForNull Item getItem() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -44,7 +45,7 @@ public abstract class ScheduleResult {
|
||||
* If {@link #isCreated()} returns true, then this method returns
|
||||
* the newly created item, which is always of the type {@link WaitingItem}.
|
||||
*/
|
||||
public WaitingItem getCreateItem() {
|
||||
public @CheckForNull WaitingItem getCreateItem() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public final class WorkUnitContext {
|
||||
this.item = item;
|
||||
this.task = item.task;
|
||||
this.future = (FutureImpl)item.getFuture();
|
||||
this.actions = item.getActions();
|
||||
this.actions = new ArrayList<Action>(item.getAllActions());
|
||||
|
||||
// +1 for the main task
|
||||
int workUnitSize = Tasks.getSubTasksOf(task).size();
|
||||
|
||||
@@ -265,7 +265,7 @@ public abstract class AbstractNodeMonitorDescriptor<T> extends Descriptor<NodeMo
|
||||
synchronized(AbstractNodeMonitorDescriptor.this) {
|
||||
if(inProgress!=null) {
|
||||
// maybe it got stuck?
|
||||
LOGGER.warning("Previous "+getDisplayName()+" monitoring activity still in progress. Interrupting");
|
||||
LOGGER.log(Level.WARNING, "Previous {0} monitoring activity still in progress. Interrupting", getDisplayName());
|
||||
inProgress.interrupt();
|
||||
}
|
||||
inProgress = this;
|
||||
@@ -283,7 +283,9 @@ public abstract class AbstractNodeMonitorDescriptor<T> extends Descriptor<NodeMo
|
||||
timestamp = System.currentTimeMillis();
|
||||
record = this;
|
||||
|
||||
LOGGER.fine("Node monitoring "+getDisplayName()+" completed in "+(System.currentTimeMillis()-startTime)+"ms");
|
||||
LOGGER.log(Level.FINE, "Node monitoring {0} completed in {1}ms", new Object[] {getDisplayName(), System.currentTimeMillis()-startTime});
|
||||
} catch (InterruptedException x) {
|
||||
// interrupted by new one, fine
|
||||
} catch (Throwable t) {
|
||||
LOGGER.log(Level.WARNING, "Unexpected node monitoring termination: "+getDisplayName(),t);
|
||||
} finally {
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
package hudson.node_monitors;
|
||||
|
||||
import hudson.FilePath.FileCallable;
|
||||
import hudson.Functions;
|
||||
import hudson.remoting.VirtualChannel;
|
||||
import hudson.Util;
|
||||
import hudson.slaves.OfflineCause;
|
||||
@@ -95,15 +96,11 @@ public abstract class DiskSpaceMonitorDescriptor extends AbstractAsyncNodeMonito
|
||||
* Returns the HTML representation of the space.
|
||||
*/
|
||||
public String toHtml() {
|
||||
long space = size;
|
||||
space/=1024L; // convert to KB
|
||||
space/=1024L; // convert to MB
|
||||
String humanReadableSpace = Functions.humanReadableByteSize(size);
|
||||
if(triggered) {
|
||||
// less than a GB
|
||||
return Util.wrapToErrorSpan(new BigDecimal(space).scaleByPowerOfTen(-3).toPlainString()+"GB");
|
||||
return Util.wrapToErrorSpan(humanReadableSpace);
|
||||
}
|
||||
|
||||
return space/1024+"GB";
|
||||
return humanReadableSpace;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,7 @@ package hudson.node_monitors;
|
||||
|
||||
import hudson.Util;
|
||||
import hudson.Extension;
|
||||
import hudson.Functions;
|
||||
import hudson.model.Computer;
|
||||
import jenkins.model.Jenkins;
|
||||
import hudson.remoting.Callable;
|
||||
@@ -51,14 +52,16 @@ public class SwapSpaceMonitor extends NodeMonitor {
|
||||
if(usage.availableSwapSpace==-1)
|
||||
return "N/A";
|
||||
|
||||
String humanReadableSpace = Functions.humanReadableByteSize(usage.availableSwapSpace);
|
||||
|
||||
long free = usage.availableSwapSpace;
|
||||
free/=1024L; // convert to KB
|
||||
free/=1024L; // convert to MB
|
||||
if(free>256 || usage.totalSwapSpace<usage.availableSwapSpace*5)
|
||||
return free+"MB"; // if we have more than 256MB free or less than 80% filled up, it's OK
|
||||
return humanReadableSpace; // if we have more than 256MB free or less than 80% filled up, it's OK
|
||||
|
||||
// Otherwise considered dangerously low.
|
||||
return Util.wrapToErrorSpan(free+"MB");
|
||||
return Util.wrapToErrorSpan(humanReadableSpace);
|
||||
}
|
||||
|
||||
public long toMB(MemoryUsage usage) {
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2012-, CloudBees, 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.os.windows;
|
||||
|
||||
import hudson.Extension;
|
||||
import hudson.ExtensionPoint;
|
||||
import hudson.model.AbstractDescribableImpl;
|
||||
import hudson.model.Descriptor;
|
||||
import hudson.os.windows.ManagedWindowsServiceLauncher.AccountInfo;
|
||||
import hudson.util.Secret;
|
||||
import org.kohsuke.stapler.DataBoundConstructor;
|
||||
|
||||
/**
|
||||
* Encapsulates how to login (a part of {@link ManagedWindowsServiceLauncher}).
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @author Vincent Latombe
|
||||
* @since 1.448
|
||||
*/
|
||||
public abstract class ManagedWindowsServiceAccount extends AbstractDescribableImpl<ManagedWindowsServiceAccount> implements ExtensionPoint {
|
||||
public abstract AccountInfo getAccount(ManagedWindowsServiceLauncher launcher);
|
||||
|
||||
/**
|
||||
* Logs in with the local system user.
|
||||
* This is the default.
|
||||
*/
|
||||
public static final class LocalSystem extends ManagedWindowsServiceAccount {
|
||||
@DataBoundConstructor
|
||||
public LocalSystem() {}
|
||||
|
||||
@Override
|
||||
public AccountInfo getAccount(ManagedWindowsServiceLauncher launcher) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Extension(ordinal=100)
|
||||
public static class DescriptorImpl extends Descriptor<ManagedWindowsServiceAccount> {
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "Use Local System User";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs in with the administrator user account supplied in {@link ManagedWindowsServiceLauncher}.
|
||||
*/
|
||||
public static final class Administrator extends ManagedWindowsServiceAccount {
|
||||
@DataBoundConstructor
|
||||
public Administrator() {}
|
||||
|
||||
@Override
|
||||
public AccountInfo getAccount(ManagedWindowsServiceLauncher launcher) {
|
||||
return new AccountInfo(launcher.userName,Secret.toString(launcher.password));
|
||||
}
|
||||
|
||||
@Extension
|
||||
public static class DescriptorImpl extends Descriptor<ManagedWindowsServiceAccount> {
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "Use Administrator account given above";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs in with a separate user.
|
||||
*/
|
||||
public static final class AnotherUser extends ManagedWindowsServiceAccount {
|
||||
public final String userName;
|
||||
public final Secret password;
|
||||
|
||||
@DataBoundConstructor
|
||||
public AnotherUser(String userName, Secret password) {
|
||||
this.userName = userName;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccountInfo getAccount(ManagedWindowsServiceLauncher launcher) {
|
||||
return new AccountInfo(userName,Secret.toString(password));
|
||||
}
|
||||
|
||||
@Extension
|
||||
public static class DescriptorImpl extends Descriptor<ManagedWindowsServiceAccount> {
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "Log on using a different account";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package hudson.os.windows;
|
||||
|
||||
import hudson.Extension;
|
||||
import hudson.model.TaskListener;
|
||||
import hudson.slaves.ComputerConnector;
|
||||
import hudson.slaves.ComputerConnectorDescriptor;
|
||||
import hudson.util.Secret;
|
||||
import org.kohsuke.stapler.DataBoundConstructor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* {@link ComputerConnector} that delegates to {@link ManagedWindowsServiceLauncher}.
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class ManagedWindowsServiceConnector extends ComputerConnector {
|
||||
/**
|
||||
* "[DOMAIN\\]USERNAME" to follow the Windows convention.
|
||||
*/
|
||||
public final String userName;
|
||||
|
||||
public final Secret password;
|
||||
|
||||
@DataBoundConstructor
|
||||
public ManagedWindowsServiceConnector(String userName, String password) {
|
||||
this.userName = userName;
|
||||
this.password = Secret.fromString(password);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManagedWindowsServiceLauncher launch(final String hostName, TaskListener listener) throws IOException, InterruptedException {
|
||||
return new ManagedWindowsServiceLauncher(userName,Secret.toString(password),hostName);
|
||||
}
|
||||
|
||||
@Extension
|
||||
public static class DescriptorImpl extends ComputerConnectorDescriptor {
|
||||
public String getDisplayName() {
|
||||
return Messages.ManagedWindowsServiceLauncher_DisplayName();
|
||||
}
|
||||
|
||||
// used by Jelly
|
||||
public static final Class<?> CONFIG_DELEGATE_TO = ManagedWindowsServiceLauncher.class;
|
||||
}
|
||||
}
|
||||
@@ -1,529 +0,0 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2004-2009, 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.os.windows;
|
||||
|
||||
import static hudson.Util.copyStreamAndClose;
|
||||
import static org.jvnet.hudson.wmi.Win32Service.Win32OwnProcess;
|
||||
|
||||
import hudson.EnvVars;
|
||||
import hudson.Extension;
|
||||
import hudson.Util;
|
||||
import hudson.model.*;
|
||||
import hudson.os.windows.ManagedWindowsServiceAccount.AnotherUser;
|
||||
import hudson.os.windows.ManagedWindowsServiceAccount.LocalSystem;
|
||||
import hudson.remoting.Channel;
|
||||
import hudson.remoting.Channel.Listener;
|
||||
import hudson.remoting.SocketInputStream;
|
||||
import hudson.remoting.SocketOutputStream;
|
||||
import hudson.slaves.*;
|
||||
import hudson.tools.JDKInstaller;
|
||||
import hudson.tools.JDKInstaller.CPU;
|
||||
import hudson.tools.JDKInstaller.Platform;
|
||||
import hudson.util.DescribableList;
|
||||
import hudson.util.IOUtils;
|
||||
import hudson.util.Secret;
|
||||
import hudson.util.jna.DotNet;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import jcifs.smb.NtlmPasswordAuthentication;
|
||||
import jcifs.smb.SmbException;
|
||||
import jcifs.smb.SmbFile;
|
||||
import jenkins.model.Jenkins;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentException;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.jinterop.dcom.common.JIDefaultAuthInfoImpl;
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jinterop.dcom.core.JISession;
|
||||
import org.jvnet.hudson.remcom.WindowsRemoteProcessLauncher;
|
||||
import org.jvnet.hudson.wmi.SWbemServices;
|
||||
import org.jvnet.hudson.wmi.WMI;
|
||||
import org.jvnet.hudson.wmi.Win32Service;
|
||||
import org.kohsuke.stapler.DataBoundConstructor;
|
||||
|
||||
/**
|
||||
* Windows slave installed/managed as a service entirely remotely
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class ManagedWindowsServiceLauncher extends ComputerLauncher {
|
||||
|
||||
/**
|
||||
* "[DOMAIN\\]USERNAME" to follow the Windows convention.
|
||||
*/
|
||||
public final String userName;
|
||||
|
||||
public final Secret password;
|
||||
|
||||
public final String vmargs;
|
||||
|
||||
public final String javaPath;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #account}
|
||||
*/
|
||||
public transient final AccountInfo logOn;
|
||||
|
||||
/**
|
||||
* Specifies the account used to run the service.
|
||||
*/
|
||||
private ManagedWindowsServiceAccount account;
|
||||
|
||||
public static class LogOnOption {
|
||||
public final String value;
|
||||
|
||||
public final AccountInfo logOn;
|
||||
|
||||
@DataBoundConstructor
|
||||
public LogOnOption(String value, AccountInfo logOn) {
|
||||
this.value = value;
|
||||
this.logOn = logOn;
|
||||
}
|
||||
}
|
||||
|
||||
public static class AccountInfo extends AbstractDescribableImpl<AccountInfo> {
|
||||
public final String userName;
|
||||
|
||||
public final Secret password;
|
||||
|
||||
@DataBoundConstructor
|
||||
public AccountInfo(String userName, String password) {
|
||||
this.userName = userName;
|
||||
this.password = Secret.fromString(password);
|
||||
}
|
||||
|
||||
@Extension
|
||||
public static class DescriptorImpl extends Descriptor<AccountInfo> {
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return ""; // unused
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Host name to connect to. For compatibility reasons, null if the same with the slave name.
|
||||
* @since 1.419
|
||||
*/
|
||||
public final String host;
|
||||
|
||||
public ManagedWindowsServiceLauncher(String userName, String password) {
|
||||
this (userName, password, null);
|
||||
}
|
||||
|
||||
public ManagedWindowsServiceLauncher(String userName, String password, String host) {
|
||||
this(userName, password, host, null, null);
|
||||
}
|
||||
|
||||
public ManagedWindowsServiceLauncher(String userName, String password, String host, AccountInfo account) {
|
||||
this(userName,password,host,account==null ? new LocalSystem() : new AnotherUser(account.userName,account.password), null);
|
||||
}
|
||||
|
||||
public ManagedWindowsServiceLauncher(String userName, String password, String host, ManagedWindowsServiceAccount account, String vmargs) {
|
||||
this(userName, password, host, account, vmargs, "");
|
||||
}
|
||||
@DataBoundConstructor
|
||||
public ManagedWindowsServiceLauncher(String userName, String password, String host, ManagedWindowsServiceAccount account, String vmargs, String javaPath) {
|
||||
this.userName = userName;
|
||||
this.password = Secret.fromString(password);
|
||||
this.vmargs = Util.fixEmptyAndTrim(vmargs);
|
||||
this.javaPath = Util.fixEmptyAndTrim(javaPath);
|
||||
this.host = Util.fixEmptyAndTrim(host);
|
||||
this.account = account==null ? new LocalSystem() : account;
|
||||
this.logOn = null;
|
||||
}
|
||||
|
||||
public Object readResolve() {
|
||||
if (logOn!=null)
|
||||
account = new AnotherUser(logOn.userName,logOn.password);
|
||||
return this;
|
||||
}
|
||||
|
||||
private JIDefaultAuthInfoImpl createAuth() {
|
||||
String[] tokens = userName.split("\\\\");
|
||||
if(tokens.length==2)
|
||||
return new JIDefaultAuthInfoImpl(tokens[0], tokens[1], Secret.toString(password));
|
||||
return new JIDefaultAuthInfoImpl("", userName, Secret.toString(password));
|
||||
}
|
||||
|
||||
private NtlmPasswordAuthentication createSmbAuth() {
|
||||
JIDefaultAuthInfoImpl auth = createAuth();
|
||||
return new NtlmPasswordAuthentication(auth.getDomain(), auth.getUserName(), auth.getPassword());
|
||||
}
|
||||
|
||||
public ManagedWindowsServiceAccount getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
private AccountInfo getLogOn() {
|
||||
if (account==null) return null;
|
||||
return account.getAccount(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launch(final SlaveComputer computer, final TaskListener listener) throws IOException, InterruptedException {
|
||||
try {
|
||||
final PrintStream logger = listener.getLogger();
|
||||
final String name = determineHost(computer);
|
||||
|
||||
logger.println(Messages.ManagedWindowsServiceLauncher_ConnectingTo(name));
|
||||
|
||||
InetAddress host = InetAddress.getByName(name);
|
||||
|
||||
/*
|
||||
Somehow this didn't work for me, so I'm disabling it.
|
||||
*/
|
||||
// ping check
|
||||
// if (!host.isReachable(3000)) {
|
||||
// logger.println("Failed to ping "+name+". Is this a valid reachable host name?");
|
||||
// // continue anyway, just in case it's just ICMP that's getting filtered
|
||||
// }
|
||||
|
||||
checkPort135Access(logger, name, host);
|
||||
|
||||
JIDefaultAuthInfoImpl auth = createAuth();
|
||||
JISession session = JISession.createSession(auth);
|
||||
session.setGlobalSocketTimeout(60000);
|
||||
SWbemServices services = WMI.connect(session, name);
|
||||
|
||||
|
||||
String path = computer.getNode().getRemoteFS();
|
||||
if (path.indexOf(':')==-1) throw new IOException("Remote file system root path of the slave needs to be absolute: "+path);
|
||||
SmbFile remoteRoot = new SmbFile("smb://" + name + "/" + path.replace('\\', '/').replace(':', '$')+"/",createSmbAuth());
|
||||
|
||||
if(!remoteRoot.exists())
|
||||
remoteRoot.mkdirs();
|
||||
|
||||
String java = resolveJava(computer);
|
||||
|
||||
try {// does Java exist?
|
||||
logger.println("Checking if Java exists");
|
||||
WindowsRemoteProcessLauncher wrpl = new WindowsRemoteProcessLauncher(name,auth);
|
||||
Process proc = wrpl.launch("\"" +java + "\" -version","c:\\");
|
||||
proc.getOutputStream().close();
|
||||
StringWriter console = new StringWriter();
|
||||
IOUtils.copy(proc.getInputStream(), console);
|
||||
proc.getInputStream().close();
|
||||
int exitCode = proc.waitFor();
|
||||
if (exitCode==1) {// we'll get this error code if Java is not found
|
||||
logger.println("No Java found. Downloading JDK");
|
||||
JDKInstaller jdki = new JDKInstaller("jdk-6u16-oth-JPR@CDS-CDS_Developer",true);
|
||||
URL jdk = jdki.locate(listener, Platform.WINDOWS, CPU.i386);
|
||||
|
||||
listener.getLogger().println("Installing JDK");
|
||||
copyStreamAndClose(jdk.openStream(), new SmbFile(remoteRoot, "jdk.exe").getOutputStream());
|
||||
|
||||
String javaDir = path + "\\jdk"; // this is where we install Java to
|
||||
|
||||
WindowsRemoteFileSystem fs = new WindowsRemoteFileSystem(name, createSmbAuth());
|
||||
fs.mkdirs(javaDir);
|
||||
|
||||
jdki.install(new WindowsRemoteLauncher(listener,wrpl), Platform.WINDOWS,
|
||||
fs, listener, javaDir ,path+"\\jdk.exe");
|
||||
} else {
|
||||
checkJavaVersion(logger, java, new BufferedReader(new StringReader(console.toString())));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace(listener.error("Failed to prepare Java"));
|
||||
return;
|
||||
}
|
||||
|
||||
// this just doesn't work --- trying to obtain the type or check the existence of smb://server/C$/ results in "access denied"
|
||||
// {// check if the administrative share exists
|
||||
// String fullpath = remoteRoot.getPath();
|
||||
// int idx = fullpath.indexOf("$/");
|
||||
// if (idx>=0) {// this must be true but be defensive since all we are trying to do here is a friendlier error check
|
||||
// boolean exists;
|
||||
// try {
|
||||
// // SmbFile.exists() doesn't work on a share
|
||||
// new SmbFile(fullpath.substring(0, idx + 2)).getType();
|
||||
// exists = true;
|
||||
// } catch (SmbException e) {
|
||||
// // on Windows XP that I was using for the test, if the share doesn't exist I get this error
|
||||
// // a thread in jcifs library ML confirms this, too:
|
||||
// // http://old.nabble.com/"The-network-name-cannot-be-found"-after-30-seconds-td18859163.html
|
||||
// if (e.getNtStatus()== NtStatus.NT_STATUS_BAD_NETWORK_NAME)
|
||||
// exists = false;
|
||||
// else
|
||||
// throw e;
|
||||
// }
|
||||
// if (!exists) {
|
||||
// logger.println(name +" appears to be missing the administrative share "+fullpath.substring(idx-1,idx+1)/*C$*/);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
String id = generateServiceId(path);
|
||||
Win32Service slaveService = services.getService(id);
|
||||
if(slaveService==null) {
|
||||
logger.println(Messages.ManagedWindowsServiceLauncher_InstallingSlaveService());
|
||||
if(!DotNet.isInstalled(2,0, name, auth)) {
|
||||
// abort the launch
|
||||
logger.println(Messages.ManagedWindowsServiceLauncher_DotNetRequired());
|
||||
return;
|
||||
}
|
||||
|
||||
// copy exe
|
||||
logger.println(Messages.ManagedWindowsServiceLauncher_CopyingSlaveExe());
|
||||
copyStreamAndClose(getClass().getResource("/windows-service/jenkins.exe").openStream(), new SmbFile(remoteRoot,"jenkins-slave.exe").getOutputStream());
|
||||
|
||||
copyStreamAndClose(getClass().getResource("/windows-service/jenkins.exe.config").openStream(), new SmbFile(remoteRoot,"jenkins-slave.exe.config").getOutputStream());
|
||||
|
||||
copySlaveJar(logger, remoteRoot);
|
||||
|
||||
// copy jenkins-slave.xml
|
||||
String xml = createAndCopyJenkinsSlaveXml(java, id, logger, remoteRoot);
|
||||
|
||||
// install it as a service
|
||||
logger.println(Messages.ManagedWindowsServiceLauncher_RegisteringService());
|
||||
Document dom = new SAXReader().read(new StringReader(xml));
|
||||
Win32Service svc = services.Get("Win32_Service").cast(Win32Service.class);
|
||||
int r;
|
||||
AccountInfo logOn = getLogOn();
|
||||
if (logOn == null) {
|
||||
r = svc.Create(
|
||||
id,
|
||||
dom.selectSingleNode("/service/name").getText()+" at "+path,
|
||||
path+"\\jenkins-slave.exe",
|
||||
Win32OwnProcess, 0, "Manual", true);
|
||||
} else {
|
||||
r = svc.Create(
|
||||
id,
|
||||
dom.selectSingleNode("/service/name").getText()+" at "+path,
|
||||
path+"\\jenkins-slave.exe",
|
||||
Win32OwnProcess,
|
||||
0,
|
||||
"Manual",
|
||||
false, // When using a different user, it isn't possible to interact
|
||||
logOn.userName,
|
||||
Secret.toString(logOn.password),
|
||||
null, null, null);
|
||||
|
||||
}
|
||||
if(r!=0) {
|
||||
listener.error("Failed to create a service: "+svc.getErrorMessage(r));
|
||||
return;
|
||||
}
|
||||
slaveService = services.getService(id);
|
||||
} else {
|
||||
createAndCopyJenkinsSlaveXml(java, id, logger, remoteRoot);
|
||||
copySlaveJar(logger, remoteRoot);
|
||||
}
|
||||
|
||||
logger.println(Messages.ManagedWindowsServiceLauncher_StartingService());
|
||||
slaveService.start();
|
||||
|
||||
// wait until we see the port.txt, but don't do so forever
|
||||
logger.println(Messages.ManagedWindowsServiceLauncher_WaitingForService());
|
||||
SmbFile portFile = new SmbFile(remoteRoot, "port.txt");
|
||||
for( int i=0; !portFile.exists(); i++ ) {
|
||||
if(i>=30) {
|
||||
listener.error(Messages.ManagedWindowsServiceLauncher_ServiceDidntRespond());
|
||||
return;
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
int p = readSmbFile(portFile);
|
||||
|
||||
// connect
|
||||
logger.println(Messages.ManagedWindowsServiceLauncher_ConnectingToPort(p));
|
||||
final Socket s = new Socket(name,p);
|
||||
|
||||
// ready
|
||||
computer.setChannel(new BufferedInputStream(new SocketInputStream(s)),
|
||||
new BufferedOutputStream(new SocketOutputStream(s)),
|
||||
listener.getLogger(),new Listener() {
|
||||
@Override
|
||||
public void onClosed(Channel channel, IOException cause) {
|
||||
afterDisconnect(computer,listener);
|
||||
}
|
||||
});
|
||||
//destroy session to free the socket
|
||||
JISession.destroySession(session);
|
||||
} catch (SmbException e) {
|
||||
e.printStackTrace(listener.error(e.getMessage()));
|
||||
} catch (JIException e) {
|
||||
if(e.getErrorCode()==5)
|
||||
// access denied error
|
||||
e.printStackTrace(listener.error(Messages.ManagedWindowsServiceLauncher_AccessDenied()));
|
||||
else
|
||||
e.printStackTrace(listener.error(e.getMessage()));
|
||||
} catch (DocumentException e) {
|
||||
e.printStackTrace(listener.error(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
private String resolveJava(SlaveComputer computer) {
|
||||
if (StringUtils.isNotBlank(javaPath)) {
|
||||
return getEnvVars(computer).expand(javaPath);
|
||||
}
|
||||
return "java";
|
||||
}
|
||||
|
||||
// -- duplicates code from ssh-slaves-plugin
|
||||
private EnvVars getEnvVars(SlaveComputer computer) {
|
||||
final EnvVars global = getEnvVars(Jenkins.getInstance());
|
||||
|
||||
final EnvVars local = getEnvVars(computer.getNode());
|
||||
|
||||
if (global != null) {
|
||||
if (local != null) {
|
||||
final EnvVars merged = new EnvVars(global);
|
||||
merged.overrideAll(local);
|
||||
|
||||
return merged;
|
||||
} else {
|
||||
return global;
|
||||
}
|
||||
} else if (local != null) {
|
||||
return local;
|
||||
} else {
|
||||
return new EnvVars();
|
||||
}
|
||||
}
|
||||
|
||||
private EnvVars getEnvVars(Node n) {
|
||||
return getEnvVars(n.getNodeProperties());
|
||||
}
|
||||
|
||||
private EnvVars getEnvVars(DescribableList<NodeProperty<?>, NodePropertyDescriptor> dl) {
|
||||
final EnvironmentVariablesNodeProperty evnp = dl.get(EnvironmentVariablesNodeProperty.class);
|
||||
if (evnp == null) {
|
||||
return null;
|
||||
}
|
||||
return evnp.getEnvVars();
|
||||
}
|
||||
|
||||
|
||||
private void checkPort135Access(PrintStream logger, String name, InetAddress host) throws IOException {
|
||||
Socket s = new Socket();
|
||||
try {
|
||||
s.connect(new InetSocketAddress(host,135),5000);
|
||||
} catch (IOException e) {
|
||||
logger.println("Failed to connect to port 135 of "+name+". Is Windows firewall blocking this port? Or did you disable DCOM service?");
|
||||
// again, let it continue.
|
||||
} finally {
|
||||
s.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the host name (or the IP address) to connect to.
|
||||
*/
|
||||
protected String determineHost(Computer c) {
|
||||
// If host not provided, default to the slave name
|
||||
if (StringUtils.isBlank(host)) {
|
||||
return c.getName();
|
||||
} else {
|
||||
return host;
|
||||
}
|
||||
}
|
||||
|
||||
private String createAndCopyJenkinsSlaveXml(String java, String serviceId, PrintStream logger, SmbFile remoteRoot) throws IOException {
|
||||
logger.println(Messages.ManagedWindowsServiceLauncher_CopyingSlaveXml());
|
||||
String xml = generateSlaveXml(serviceId,
|
||||
java + "w.exe", vmargs, "-tcp %BASE%\\port.txt");
|
||||
copyStreamAndClose(new ByteArrayInputStream(xml.getBytes("UTF-8")), new SmbFile(remoteRoot,"jenkins-slave.xml").getOutputStream());
|
||||
return xml;
|
||||
}
|
||||
|
||||
private void copySlaveJar(PrintStream logger, SmbFile remoteRoot) throws IOException {
|
||||
// copy slave.jar
|
||||
logger.println(Messages.ManagedWindowsServiceLauncher_CopyingSlaveJar());
|
||||
copyStreamAndClose(Jenkins.getInstance().getJnlpJars("slave.jar").getURL().openStream(), new SmbFile(remoteRoot,"slave.jar").getOutputStream());
|
||||
}
|
||||
|
||||
private int readSmbFile(SmbFile f) throws IOException {
|
||||
InputStream in=null;
|
||||
try {
|
||||
in = f.getInputStream();
|
||||
return Integer.parseInt(IOUtils.toString(in));
|
||||
} finally {
|
||||
IOUtils.closeQuietly(in);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterDisconnect(SlaveComputer computer, TaskListener listener) {
|
||||
try {
|
||||
JIDefaultAuthInfoImpl auth = createAuth();
|
||||
JISession session = JISession.createSession(auth);
|
||||
session.setGlobalSocketTimeout(60000);
|
||||
SWbemServices services = WMI.connect(session, determineHost(computer));
|
||||
String id = generateServiceId(computer.getNode().getRemoteFS());
|
||||
Win32Service slaveService = services.getService(id);
|
||||
if(slaveService!=null) {
|
||||
listener.getLogger().println(Messages.ManagedWindowsServiceLauncher_StoppingService());
|
||||
slaveService.StopService();
|
||||
listener.getLogger().println(Messages.ManagedWindowsServiceLauncher_UnregisteringService());
|
||||
slaveService.Delete();
|
||||
}
|
||||
//destroy session to free the socket
|
||||
JISession.destroySession(session);
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace(listener.error(e.getMessage()));
|
||||
} catch (JIException e) {
|
||||
e.printStackTrace(listener.error(e.getMessage()));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace(listener.error(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
String generateServiceId(String slaveRoot) throws IOException {
|
||||
return "jenkinsslave-"+slaveRoot.replace(':','_').replace('\\','_').replace('/','_');
|
||||
}
|
||||
|
||||
String generateSlaveXml(String id, String java, String vmargs, String args) throws IOException {
|
||||
String xml = org.apache.commons.io.IOUtils.toString(getClass().getResourceAsStream("/windows-service/jenkins-slave.xml"), "UTF-8");
|
||||
xml = xml.replace("@ID@", id);
|
||||
xml = xml.replace("@JAVA@", java);
|
||||
xml = xml.replace("@VMARGS@", StringUtils.defaultString(vmargs));
|
||||
xml = xml.replace("@ARGS@", args);
|
||||
return xml;
|
||||
}
|
||||
|
||||
@Extension
|
||||
public static class DescriptorImpl extends Descriptor<ComputerLauncher> {
|
||||
public String getDisplayName() {
|
||||
return Messages.ManagedWindowsServiceLauncher_DisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
private static final Logger JINTEROP_LOGGER = Logger.getLogger("org.jinterop");
|
||||
|
||||
static {
|
||||
JINTEROP_LOGGER.setLevel(Level.WARNING);
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package hudson.os.windows;
|
||||
|
||||
import hudson.tools.JDKInstaller.FileSystem;
|
||||
import jcifs.smb.NtlmPasswordAuthentication;
|
||||
import jcifs.smb.SmbFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
/**
|
||||
* {@link FileSystem} implementation for remote Windows system.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class WindowsRemoteFileSystem implements FileSystem {
|
||||
private final String hostName;
|
||||
private final NtlmPasswordAuthentication auth;
|
||||
|
||||
public WindowsRemoteFileSystem(String hostName, NtlmPasswordAuthentication auth) {
|
||||
this.hostName = hostName;
|
||||
this.auth = auth;
|
||||
}
|
||||
|
||||
private SmbFile $(String path) throws MalformedURLException {
|
||||
return new SmbFile("smb://" + hostName + "/" + path.replace('\\', '/').replace(':', '$')+"/",auth);
|
||||
}
|
||||
|
||||
public void delete(String file) throws IOException, InterruptedException {
|
||||
$(file).delete();
|
||||
}
|
||||
|
||||
public void chmod(String file, int mode) throws IOException, InterruptedException {
|
||||
// no-op on Windows
|
||||
}
|
||||
|
||||
public InputStream read(String file) throws IOException {
|
||||
return $(file).getInputStream();
|
||||
}
|
||||
|
||||
public List<String> listSubDirectories(String dir) throws IOException, InterruptedException {
|
||||
return asList($(dir).list());
|
||||
}
|
||||
|
||||
public void pullUp(String from, String to) throws IOException, InterruptedException {
|
||||
SmbFile src = $(from);
|
||||
SmbFile dst = $(to);
|
||||
for (SmbFile e : src.listFiles()) {
|
||||
e.renameTo(new SmbFile(dst,e.getName()));
|
||||
}
|
||||
src.delete();
|
||||
}
|
||||
|
||||
public void mkdirs(String path) throws IOException {
|
||||
$(path).mkdirs();
|
||||
}
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
package hudson.os.windows;
|
||||
|
||||
import hudson.FilePath;
|
||||
import hudson.Launcher;
|
||||
import hudson.Proc;
|
||||
import hudson.Util;
|
||||
import hudson.model.Computer;
|
||||
import hudson.model.TaskListener;
|
||||
import hudson.remoting.Channel;
|
||||
import hudson.util.StreamCopyThread;
|
||||
import org.jinterop.dcom.common.JIException;
|
||||
import org.jvnet.hudson.remcom.WindowsRemoteProcessLauncher;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
/**
|
||||
* Pseudo-{@link Launcher} implementation that uses {@link WindowsRemoteProcessLauncher}
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class WindowsRemoteLauncher extends Launcher {
|
||||
private final WindowsRemoteProcessLauncher launcher;
|
||||
|
||||
public WindowsRemoteLauncher(TaskListener listener, WindowsRemoteProcessLauncher launcher) {
|
||||
super(listener,null);
|
||||
this.launcher = launcher;
|
||||
}
|
||||
|
||||
private String buildCommandLine(ProcStarter ps) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
for (String cmd : ps.cmds()) {
|
||||
if (b.length()>0) b.append(' ');
|
||||
if (cmd.indexOf(' ')>=0)
|
||||
b.append('"').append(cmd).append('"');
|
||||
else
|
||||
b.append(cmd);
|
||||
}
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
public Proc launch(ProcStarter ps) throws IOException {
|
||||
maskedPrintCommandLine(ps.cmds(), ps.masks(), ps.pwd());
|
||||
|
||||
// TODO: environment variable handling
|
||||
|
||||
String name = ps.cmds().toString();
|
||||
|
||||
final Process proc;
|
||||
try {
|
||||
proc = launcher.launch(buildCommandLine(ps), ps.pwd().getRemote());
|
||||
} catch (JIException e) {
|
||||
throw new IOException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
final Thread t1 = new StreamCopyThread("stdout copier: "+name, proc.getInputStream(), ps.stdout(),false);
|
||||
t1.start();
|
||||
final Thread t2 = new StreamCopyThread("stdin copier: "+name,ps.stdin(), proc.getOutputStream(),true);
|
||||
t2.start();
|
||||
|
||||
return new Proc() {
|
||||
public boolean isAlive() throws IOException, InterruptedException {
|
||||
try {
|
||||
proc.exitValue();
|
||||
return false;
|
||||
} catch (IllegalThreadStateException e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void kill() throws IOException, InterruptedException {
|
||||
t1.interrupt();
|
||||
t2.interrupt();
|
||||
proc.destroy();
|
||||
}
|
||||
|
||||
public int join() throws IOException, InterruptedException {
|
||||
try {
|
||||
t1.join();
|
||||
t2.join();
|
||||
return proc.waitFor();
|
||||
} finally {
|
||||
proc.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getStdout() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getStderr() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getStdin() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public Channel launchChannel(String[] cmd, OutputStream out, FilePath _workDir, Map<String, String> envVars) throws IOException, InterruptedException {
|
||||
printCommandLine(cmd, _workDir);
|
||||
|
||||
try {
|
||||
Process proc = launcher.launch(Util.join(asList(cmd), " "), _workDir.getRemote());
|
||||
|
||||
return new Channel("channel over named pipe to "+launcher.getHostName(),
|
||||
Computer.threadPoolForRemoting, proc.getInputStream(), new BufferedOutputStream(proc.getOutputStream()));
|
||||
} catch (JIException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void kill(Map<String, String> modelEnvVars) throws IOException, InterruptedException {
|
||||
// no way to do this
|
||||
}
|
||||
}
|
||||
@@ -430,6 +430,16 @@ public final class CronTab {
|
||||
}
|
||||
}
|
||||
|
||||
int daysOfMonth = 0;
|
||||
for (int i = 1; i < 31; i++) {
|
||||
if (checkBits(bits[2], i)) {
|
||||
daysOfMonth++;
|
||||
}
|
||||
}
|
||||
if (daysOfMonth > 5 && daysOfMonth < 28) { // a bit arbitrary
|
||||
return Messages.CronTab_short_cycles_in_the_day_of_month_field_w();
|
||||
}
|
||||
|
||||
String hashified = hashify(spec);
|
||||
if (hashified != null) {
|
||||
return Messages.CronTab_spread_load_evenly_by_using_rather_than_(hashified, spec);
|
||||
|
||||
Executable → Regular
File mode changed.
Executable → Regular
File mode changed.
@@ -422,6 +422,7 @@ public abstract class SCM implements Describable<SCM>, ExtensionPoint {
|
||||
|
||||
/**
|
||||
* Get a chance to do operations after the workspace i checked out and the changelog is written.
|
||||
* @since 1.534, 1.532.1
|
||||
*/
|
||||
public void postCheckout(AbstractBuild<?,?> build, Launcher launcher, FilePath workspace, BuildListener listener) throws IOException, InterruptedException {
|
||||
/* Default implementation is noop */
|
||||
|
||||
@@ -3,9 +3,12 @@ package hudson.security;
|
||||
import groovy.lang.Binding;
|
||||
import hudson.FilePath;
|
||||
import hudson.cli.CLICommand;
|
||||
import jenkins.model.Jenkins;
|
||||
import hudson.remoting.Callable;
|
||||
import hudson.util.spring.BeanBuilder;
|
||||
import java.io.Console;
|
||||
import java.io.IOException;
|
||||
import jenkins.model.Jenkins;
|
||||
import jenkins.security.SecurityListener;
|
||||
import org.acegisecurity.Authentication;
|
||||
import org.acegisecurity.AuthenticationException;
|
||||
import org.acegisecurity.AuthenticationManager;
|
||||
@@ -19,9 +22,6 @@ import org.kohsuke.args4j.Option;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
import java.io.Console;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Partial implementation of {@link SecurityRealm} for username/password based authentication.
|
||||
* This is a convenience base class if all you are trying to do is to check the given username
|
||||
@@ -76,7 +76,7 @@ public abstract class AbstractPasswordBasedSecurityRealm extends SecurityRealm i
|
||||
if (password==null)
|
||||
throw new BadCredentialsException("No password specified");
|
||||
|
||||
UserDetails d = AbstractPasswordBasedSecurityRealm.this.authenticate(userName, password);
|
||||
UserDetails d = doAuthenticate(userName, password);
|
||||
return new UsernamePasswordAuthenticationToken(d, password, d.getAuthorities());
|
||||
}
|
||||
};
|
||||
@@ -107,6 +107,17 @@ public abstract class AbstractPasswordBasedSecurityRealm extends SecurityRealm i
|
||||
*/
|
||||
protected abstract UserDetails authenticate(String username, String password) throws AuthenticationException;
|
||||
|
||||
private UserDetails doAuthenticate(String username, String password) throws AuthenticationException {
|
||||
try {
|
||||
UserDetails user = authenticate(username, password);
|
||||
SecurityListener.fireAuthenticated(user);
|
||||
return user;
|
||||
} catch (AuthenticationException x) {
|
||||
SecurityListener.fireFailedToAuthenticate(username);
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves information about an user by its name.
|
||||
*
|
||||
@@ -132,7 +143,7 @@ public abstract class AbstractPasswordBasedSecurityRealm extends SecurityRealm i
|
||||
}
|
||||
|
||||
protected UserDetails retrieveUser(String username, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException {
|
||||
return AbstractPasswordBasedSecurityRealm.this.authenticate(username,authentication.getCredentials().toString());
|
||||
return doAuthenticate(username,authentication.getCredentials().toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import hudson.Util;
|
||||
import jenkins.security.SecurityListener;
|
||||
import org.acegisecurity.Authentication;
|
||||
import org.acegisecurity.AuthenticationException;
|
||||
import org.acegisecurity.ui.webapp.AuthenticationProcessingFilter;
|
||||
@@ -85,7 +86,9 @@ public class AuthenticationProcessingFilter2 extends AuthenticationProcessingFil
|
||||
// HttpSessionContextIntegrationFilter stores the updated SecurityContext object into this session later
|
||||
// (either when a redirect is issued, via its HttpResponseWrapper, or when the execution returns to its
|
||||
// doFilter method.
|
||||
request.getSession().invalidate();
|
||||
request.getSession();
|
||||
SecurityListener.fireLoggedIn(authResult.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,7 +100,11 @@ public class AuthenticationProcessingFilter2 extends AuthenticationProcessingFil
|
||||
@Override
|
||||
protected void onUnsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response, AuthenticationException failed) throws IOException {
|
||||
super.onUnsuccessfulAuthentication(request, response, failed);
|
||||
LOGGER.log(Level.INFO, "Login attempt failed", failed);
|
||||
LOGGER.log(Level.FINE, "Login attempt failed", failed);
|
||||
Authentication auth = failed.getAuthentication();
|
||||
if (auth != null) {
|
||||
SecurityListener.fireFailedToLogIn(auth.getName());
|
||||
}
|
||||
}
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(AuthenticationProcessingFilter2.class.getName());
|
||||
|
||||
@@ -30,6 +30,7 @@ import hudson.Functions;
|
||||
import hudson.markup.MarkupFormatter;
|
||||
import hudson.model.Descriptor;
|
||||
import hudson.model.Descriptor.FormException;
|
||||
import hudson.model.Describable;
|
||||
import hudson.model.ManagementLink;
|
||||
import hudson.util.FormApply;
|
||||
|
||||
@@ -55,7 +56,7 @@ import org.kohsuke.stapler.StaplerResponse;
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
@Extension(ordinal = Integer.MAX_VALUE - 210)
|
||||
public class GlobalSecurityConfiguration extends ManagementLink {
|
||||
public class GlobalSecurityConfiguration extends ManagementLink implements Describable<GlobalSecurityConfiguration> {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(GlobalSecurityConfiguration.class.getName());
|
||||
|
||||
@@ -126,7 +127,7 @@ public class GlobalSecurityConfiguration extends ManagementLink {
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return Messages.GlobalSecurityConfiguration_DisplayName();
|
||||
return getDescriptor().getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -154,4 +155,22 @@ public class GlobalSecurityConfiguration extends ManagementLink {
|
||||
return input instanceof GlobalConfigurationCategory.Security;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @see hudson.model.Describable#getDescriptor()
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Descriptor<GlobalSecurityConfiguration> getDescriptor() {
|
||||
return Jenkins.getInstance().getDescriptorOrDie(getClass());
|
||||
}
|
||||
|
||||
@Extension
|
||||
public static final class DescriptorImpl extends Descriptor<GlobalSecurityConfiguration> {
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return Messages.GlobalSecurityConfiguration_DisplayName();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loaded 100 of 852 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user