vbehar/rundeck-api-java-client — pull request #2 by connaryscott (2012-08-20 15:41:43+00:00)
Title: Rundeck API v5 and job logging support

Hello Vincent,

I have been working with a client of ours and Rundeck 1.4.4 release candidate:

http://build.rundeck.org/job/rundeck-development/

This version implements Rundeck API v5 and contains additional support for job logging.

The pull request contains the following changes:

* Introduced new Rundeck Output classes
* Added support for session based authentication
* Added support to obtain the user profile and generate user api token
* Adjustments to refer to v5 api

My forked:

https://github.com/connaryscott/rundeck-api-java-client

In my bamboo rundeck plugin, I have been able to get the data using the following:

private void logExecutionOutput(int outputLevel) throws TaskException {

// get the first set of output lines no more than LOG_MAXLINES starting at beginning

int offset = 0;
buildLogger.addBuildLogEntry("BEGIN RUNDECK EXECUTION OUTPUT");
while (true) {
RundeckOutput rundeckOutput = getRundeckClient().getJobExecutionOutput(getExecutionId(), offset, 0, LOG_MAXLINES);
if (null == rundeckOutput) {
buildLogger.addBuildLogEntry("WARNING, no output from job detected, rundeckOutput is null");
break;
}

List listEntries = rundeckOutput.getLogEntries();
if (null == listEntries) {
break;
}
if (listEntries.size() != 0) {
RundeckOutputEntry[] rundeckOutputEntries = listEntries.toArray(new RundeckOutputEntry[listEntries.size()]);
for (int i=0; i LOG_OUT) {
buildLogger.addErrorLogEntry(message);
} else {
buildLogger.addBuildLogEntry(message);
}
if (null != message) {
offset+=message.length();
}
}
}
if (rundeckOutput.getPercentLoaded() == 1.0) {
break;
}
}
buildLogger.addBuildLogEntry("END RUNDECK EXECUTION OUTPUT");

}

I need to obtain some test classes for these changes. Anthony Shortland and I are working with a client who cannot publish their changes to OSS projects and are working on their behalf. So in addition to your review, we can get them shortly.

Additionally, it appears that it may be required to release separate versions of your api so that it uses the desired api version of Rundeck? We can also discuss this with Greg Schueler.

Thanks,

Chuck