提交 4039345b 编写于 作者: M mindless

[HUDSON-4066] Add version# is slave.jar and report this in log when a node is launched.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@23750 71c3de6d-444a-0410-be80-ed276b4c234a
上级 0d39e761
......@@ -35,6 +35,7 @@ import hudson.FilePath;
import hudson.lifecycle.WindowsSlaveInstaller;
import hudson.Util;
import hudson.AbortException;
import hudson.remoting.Launcher;
import static hudson.slaves.SlaveComputer.LogHolder.SLAVE_LOG_HANDLER;
import hudson.slaves.OfflineCause.ChannelTermination;
......@@ -296,6 +297,9 @@ public class SlaveComputer extends Computer {
if(listener!=null)
channel.addListener(listener);
String slaveVersion = channel.call(new SlaveVersion());
log.println("Slave.jar version: " + slaveVersion);
boolean _isUnix = channel.call(new DetectOS());
log.println(_isUnix? hudson.model.Messages.Slave_UnixSlave():hudson.model.Messages.Slave_WindowsSlave());
......@@ -476,6 +480,12 @@ public class SlaveComputer extends Computer {
private static final Logger logger = Logger.getLogger(SlaveComputer.class.getName());
private static final class SlaveVersion implements Callable<String,IOException> {
public String call() throws IOException {
try { return Launcher.VERSION; }
catch (Throwable ex) { return "< 1.335"; } // Older slave.jar won't have VERSION
}
}
private static final class DetectOS implements Callable<Boolean,IOException> {
public Boolean call() throws IOException {
return File.pathSeparatorChar==':';
......
......@@ -91,8 +91,29 @@ THE SOFTWARE.
<groupId>org.jvnet.maven-antrun-extended-plugin</groupId>
<artifactId>maven-antrun-extended-plugin</artifactId>
<executions>
<execution>
<id>generate-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<tstamp>
<format property="now" pattern="MM/dd/yyyy hh:mm" unit="hour" />
</tstamp>
<property name="build.version" value="${version} (private-${now}-${user.name})" />
<!-- default to release version -->
<!-- put the version file -->
<mkdir dir="target/classes/hudson/remoting" />
<echo file="target/classes/hudson/remoting/hudson-version.properties">version=${build.version}
</echo>
</tasks>
</configuration>
</execution>
<execution>
<!-- rejar args4j contents -->
<id>process-classes</id>
<phase>process-classes</phase>
<goals>
<goal>run</goal>
......
......@@ -68,6 +68,7 @@ import java.security.cert.CertificateException;
import java.security.NoSuchAlgorithmException;
import java.security.KeyManagementException;
import java.security.SecureRandom;
import java.util.Properties;
/**
* Entry point for running a {@link Channel}. This is the main method of the slave JVM.
......@@ -157,6 +158,7 @@ public class Launcher {
}
public static void main(String... args) throws Exception {
computeVersion();
Launcher launcher = new Launcher();
CmdLineParser parser = new CmdLineParser(launcher);
try {
......@@ -173,9 +175,9 @@ public class Launcher {
public void run() throws Exception {
if(auth!=null) {
final int idx = auth.indexOf(':');
if(idx<0) throw new CmdLineException("No ':' in the -auth option");
if(idx<0) throw new CmdLineException(null, "No ':' in the -auth option");
Authenticator.setDefault(new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
@Override public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(auth.substring(0,idx), auth.substring(idx+1).toCharArray());
}
});
......@@ -432,4 +434,21 @@ public class Launcher {
public static boolean isWindows() {
return File.pathSeparatorChar==';';
}
private static void computeVersion() {
Properties props = new Properties();
try {
InputStream is = Launcher.class.getResourceAsStream("hudson-version.properties");
if(is!=null)
props.load(is);
} catch (IOException e) {
e.printStackTrace();
}
VERSION = props.getProperty("version", "?");
}
/**
* Version number of Hudson this slave.jar is from.
*/
public static String VERSION = "?";
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册