Skip to content

Commit

Permalink
Add check if node is offline - Try to fix JENKINS-17566
Browse files Browse the repository at this point in the history
  • Loading branch information
gboissinot committed May 3, 2013
1 parent a27ae73 commit 2a270bb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 25 deletions.
Expand Up @@ -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 {
Expand Down
Expand Up @@ -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) {
Expand Down

0 comments on commit 2a270bb

Please sign in to comment.