Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' of github.com:jenkinsci/jenkins into JENKINS-18434
  • Loading branch information
akiellor committed Oct 8, 2013
2 parents 87f99fa + 8c4288c commit c4e2e59
Show file tree
Hide file tree
Showing 34 changed files with 770 additions and 484 deletions.
19 changes: 13 additions & 6 deletions changelog.html
Expand Up @@ -54,6 +54,14 @@

<!-- 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.535>What's new in 1.535</a> <!--=DATE=--></h3>
<ul class=image>
<li class=bug>
Windows JDK installer failed in a path with spaces.
Expand All @@ -68,6 +76,9 @@
Split matrix authorization strategies into an independent plugin.
<li class='rfe'>
UI Samples plugin fully separated from core. To view samples during plugin development or at any other time, just install from the update center.
<li class=bug>
View description should be clearly separated from the Jenkins system message.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-18633">issue 18633</a>)
<li class=bug>
SCM polling sometimes broken since 1.527 due to a change in how environment variables are calculated.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-19307">issue 19307</a>)
Expand All @@ -86,11 +97,8 @@
Visualize queued jobs in view.
(<a href="https://github.com/jenkinsci/jenkins/pull/531">pull request 531</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.534>What's new in 1.534</a> <!--=DATE=--></h3>
</div><!--=END=-->
<h3><a name=v1.534>What's new in 1.534</a> (2013/10/07)</h3>
<ul class=image>
<li class='major bug'>
Default crumb issuer configurations saved in older releases did not load as of Jenkins 1.531.
Expand All @@ -108,7 +116,6 @@ <h3><a name=v1.534>What's new in 1.534</a> <!--=DATE=--></h3>
Added postCheckout method for SCMs
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-19740">issue 19740</a>)
</ul>
</div><!--=END=-->
<h3><a name=v1.533>What's new in 1.533</a> (2013/09/29)</h3>
<ul class=image>
<li class=rfe>
Expand Down
2 changes: 1 addition & 1 deletion cli/pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>pom</artifactId>
<groupId>org.jenkins-ci.main</groupId>
<version>1.535-SNAPSHOT</version>
<version>1.536-SNAPSHOT</version>
</parent>

<artifactId>cli</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Expand Up @@ -29,7 +29,7 @@ THE SOFTWARE.
<parent>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>pom</artifactId>
<version>1.535-SNAPSHOT</version>
<version>1.536-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
9 changes: 2 additions & 7 deletions core/src/main/java/hudson/cli/BuildCommand.java
Expand Up @@ -86,11 +86,8 @@ public String getShortDescription() {
@Option(name="-v",usage="Prints out the console output of the build. Use with -s")
public boolean consoleOutput = false;

@Option(name="-r", usage="Number of times to retry reading of the output log if it does not exists on first attempt. Defaults to 0. Use with -v.")
public String retryCntStr = "0";

// hold parsed retryCnt;
private int retryCnt = 0;
@Option(name="-r") @Deprecated
public int retryCnt = 10;

protected int run() throws Exception {
job.checkPermission(Item.BUILD);
Expand Down Expand Up @@ -124,8 +121,6 @@ protected int run() throws Exception {
a = new ParametersAction(values);
}

retryCnt = Integer.parseInt(retryCntStr);

if (checkSCM) {
if (job.poll(new StreamTaskListener(stdout, getClientCharset())).change == Change.NONE) {
return 0;
Expand Down
174 changes: 20 additions & 154 deletions core/src/main/java/hudson/init/InitializerFinder.java
Expand Up @@ -23,184 +23,50 @@
*/
package hudson.init;

import hudson.model.Hudson;
import jenkins.model.Jenkins;
import org.jvnet.hudson.annotation_indexer.Index;
import org.jvnet.hudson.reactor.Milestone;
import org.jvnet.hudson.reactor.Task;
import org.jvnet.hudson.reactor.TaskBuilder;
import org.jvnet.hudson.reactor.MilestoneImpl;
import org.jvnet.hudson.reactor.Reactor;
import org.jvnet.localizer.ResourceBundleHolder;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.MissingResourceException;
import java.util.Set;
import java.util.logging.Logger;

import static java.util.logging.Level.WARNING;

/**
* Discovers initialization tasks from {@link Initializer}.
*
* @author Kohsuke Kawaguchi
*/
public class InitializerFinder extends TaskBuilder {
private final ClassLoader cl;

private final Set<Method> discovered = new HashSet<Method>();
public class InitializerFinder extends TaskMethodFinder<Initializer> {

public InitializerFinder(ClassLoader cl) {
this.cl = cl;
super(Initializer.class,InitMilestone.class,cl);
}

public InitializerFinder() {
this(Thread.currentThread().getContextClassLoader());
}

public Collection<Task> discoverTasks(Reactor session) throws IOException {
List<Task> result = new ArrayList<Task>();
for (Method e : Index.list(Initializer.class,cl,Method.class)) {
if (filter(e)) continue; // already reported once

if (!Modifier.isStatic(e.getModifiers()))
throw new IOException(e+" is not a static method");

Initializer i = e.getAnnotation(Initializer.class);
if (i==null) continue; // stale index

result.add(new TaskImpl(i, e));
}
return result;
@Override
protected String displayNameOf(Initializer i) {
return i.displayName();
}

/**
* Return true to ignore this method.
*/
protected boolean filter(Method e) {
return !discovered.add(e);
@Override
protected String[] requiresOf(Initializer i) {
return i.requires();
}

/**
* Obtains the display name of the given initialization task
*/
protected String getDisplayNameOf(Method e, Initializer i) {
Class<?> c = e.getDeclaringClass();
String key = i.displayName();
if (key.length()==0) return c.getSimpleName()+"."+e.getName();
try {
ResourceBundleHolder rb = ResourceBundleHolder.get(
c.getClassLoader().loadClass(c.getPackage().getName() + ".Messages"));
return rb.format(key);
} catch (ClassNotFoundException x) {
LOGGER.log(WARNING, "Failed to load "+x.getMessage()+" for "+e.toString(),x);
return key;
} catch (MissingResourceException x) {
LOGGER.log(WARNING, "Could not find key '" + key + "' in " + c.getPackage().getName() + ".Messages", x);
return key;
}
@Override
protected String[] attainsOf(Initializer i) {
return i.attains();
}

/**
* Invokes the given initialization method.
*/
protected void invoke(Method e) {
try {
Class<?>[] pt = e.getParameterTypes();
Object[] args = new Object[pt.length];
for (int i=0; i<args.length; i++)
args[i] = lookUp(pt[i]);
e.invoke(null,args);
} catch (IllegalAccessException x) {
throw (Error)new IllegalAccessError().initCause(x);
} catch (InvocationTargetException x) {
throw new Error(x);
}
@Override
protected Milestone afterOf(Initializer i) {
return i.after();
}

/**
* Determines the parameter injection of the initialization method.
*/
private Object lookUp(Class<?> type) {
if (type==Jenkins.class || type==Hudson.class)
return Jenkins.getInstance();
throw new IllegalArgumentException("Unable to inject "+type);
@Override
protected Milestone beforeOf(Initializer i) {
return i.before();
}

/**
* Task implementation.
*/
public class TaskImpl implements Task {
final Collection<Milestone> requires;
final Collection<Milestone> attains;
private final Initializer i;
private final Method e;

private TaskImpl(Initializer i, Method e) {
this.i = i;
this.e = e;
requires = toMilestones(i.requires(), i.after());
attains = toMilestones(i.attains(), i.before());
}

/**
* {@link Initializer} annotaion on the {@linkplain #getMethod() method}
*/
public Initializer getAnnotation() {
return i;
}

/**
* Static method that runs the initialization, that this task wraps.
*/
public Method getMethod() {
return e;
}

public Collection<Milestone> requires() {
return requires;
}

public Collection<Milestone> attains() {
return attains;
}

public String getDisplayName() {
return getDisplayNameOf(e, i);
}

public boolean failureIsFatal() {
return i.fatal();
}

public void run(Reactor session) {
invoke(e);
}

public String toString() {
return e.toString();
}

private Collection<Milestone> toMilestones(String[] tokens, InitMilestone m) {
List<Milestone> r = new ArrayList<Milestone>();
for (String s : tokens) {
try {
r.add(InitMilestone.valueOf(s));
} catch (IllegalArgumentException x) {
r.add(new MilestoneImpl(s));
}
}
r.add(m);
return r;
}
@Override
protected boolean fatalOf(Initializer i) {
return i.fatal();
}

private static final Logger LOGGER = Logger.getLogger(InitializerFinder.class.getName());
}

0 comments on commit c4e2e59

Please sign in to comment.