Skip to content
Permalink
Browse files
Add check if node is offline - Try to fix JENKINS-17566
  • Loading branch information
gboissinot committed May 3, 2013
1 parent a27ae73 commit 2a270bb56f2be489b2729229c7d66a41b2e5c14a
Showing 2 changed files with 31 additions and 25 deletions.
@@ -99,6 +99,9 @@ public Boolean call() throws ScriptTriggerException {
final String[] cmd = batchRunner.buildCommandLine(tmpFile);

final FilePath rootPath = executingNode.getRootPath();
if (rootPath == null) {
throw new ScriptTriggerException("The node is offline.");
}
return rootPath.act(new FilePath.FileCallable<Integer>() {
public Integer invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
try {
@@ -87,31 +87,34 @@ protected Action[] getScheduledActions(Node pollingNode, final XTriggerLog log)

if (propertiesFilePath != null) {
try {
return pollingNode.getRootPath()
.act(new FilePath.FileCallable<Action[]>() {

public Action[] invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
File propFile = new File(propertiesFilePath);
if (!propFile.exists()) {
log.info(String.format("Can't load the properties file '%s'. It doesn't exist.", f.getPath()));
return null;
}

Properties properties = new Properties();
FileInputStream fis = new FileInputStream(propFile);
properties.load(fis);
fis.close();

List<ParameterValue> parameterValueList = new ArrayList<ParameterValue>();
for (Map.Entry property : properties.entrySet()) {
ParameterValue parameterValue = new StringParameterValue(
String.valueOf(property.getKey()),
String.valueOf(property.getValue()));
parameterValueList.add(parameterValue);
}
return new Action[]{new ParametersAction(parameterValueList)};
}
});
FilePath rootPath = pollingNode.getRootPath();
if (rootPath == null) {
throw new ScriptTriggerException("The node is offline.");
}
return rootPath.act(new FilePath.FileCallable<Action[]>() {

public Action[] invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
File propFile = new File(propertiesFilePath);
if (!propFile.exists()) {
log.info(String.format("Can't load the properties file '%s'. It doesn't exist.", f.getPath()));
return null;
}

Properties properties = new Properties();
FileInputStream fis = new FileInputStream(propFile);
properties.load(fis);
fis.close();

List<ParameterValue> parameterValueList = new ArrayList<ParameterValue>();
for (Map.Entry property : properties.entrySet()) {
ParameterValue parameterValue = new StringParameterValue(
String.valueOf(property.getKey()),
String.valueOf(property.getValue()));
parameterValueList.add(parameterValue);
}
return new Action[]{new ParametersAction(parameterValueList)};
}
});
} catch (IOException ioe) {
throw new ScriptTriggerException(ioe);
} catch (InterruptedException ie) {

0 comments on commit 2a270bb

Please sign in to comment.