It's all about the answers!

Ask a question

Buildforge Java API. I need to traverse a Build Forge Project based on Environment Vars


Gerald Gordon (7011319) | asked Jun 21 '13, 6:50 a.m.
edited Jun 21 '13, 6:51 a.m.
 Greetings,

I have a question regarding the build forge java api.  I need to get the results from a build forge job that was executed.  The job is being executed from Rational Asset Manager using a build forge policy.  We can successfully kick off the job but now I want to capture the results of the job and its steps via the build forge java api.  I've been able to capture the build forge logs and steps but only for the last job that was executed in a buildList.  Fortunately, RAM pushes a RAM GUID into the build forge projects parent environment called RAM->RAM_GUID.

What I need to do is the following:  Search all the RAM->RAM_GUID environment vars per project.  When there is a string match of the RAM GUID and the pushed RAM->RAM_GUID id in build forge then I need to list all of the job and step information using the Build Forge API.  I'm assuming that this problem would be solved quickly if I understood better how Buildforge project UUIDs work and how I can use them to traverse all of a projects environments, but none the less, please find my example code below, thank you in advance for your support.

package com.buildforge.client;

import java.util.List;

import com.buildforge.services.client.api.APIClientConnection;
import com.buildforge.services.client.dbo.Build;
import com.buildforge.services.client.dbo.Log;
import com.buildforge.services.client.dbo.Project;
import com.buildforge.services.client.dbo.Result;
import com.buildforge.services.client.dbo.Step;

public class BuildForge {

public void printLogResult(List<Log> lg) {
for (Log lgr : lg) {
System.out.println(lgr.getLineId() + " " + lgr.getType() + " " + lgr.getMessageText());
}
}

public void printStepDesc(List<Step> stp, int pos) {
System.out.println("\tStep:" + pos + " Name[ " + stp.get(pos).getDescription() + " ]");
System.out.println("\tStep:" + pos + " CommandExecuted[ " + stp.get(pos).getCommandText() + " ]");
}

public void printJobResult(APIClientConnection conn, List<Build> buildList, List<Step> ls) {
Boolean stillRunning = true;

try {
int len = buildList.size();
int waitCount = 0;
while (stillRunning) {
waitCount++;
List<Result> result = buildList.get(len - 1).getResults();
for (int i = 0; i < result.size(); i++) {
String jResult = result.get(i).getResult().toString();
printStepDesc(ls, i);
if (jResult.contains("RUNNING")) {
System.out.println("Job Step is still in a " + jResult + " state");
stillRunning = true;
synchronized (this) {
this.wait(180000);
}
// fail safe.
if (waitCount > 10) {
stillRunning = false;
System.out.println("System Error... Deployment is taking longer than expected to complete... Program is Exiting...");
break;
}
} else if (jResult.contains("FAILED")) {
System.out.println(jResult);
System.out.println("Fatal error, job failed check logs fix problem and run project again");
printLogResult(result.get(i).getLogs());
//Deployment failed, hard exit.
System.exit(-1);
break;
} else {
if (jResult.contains("PASSED")) {
System.out.println(jResult);
printLogResult(result.get(i).getLogs());
}
// if this is the last element in the list then exit the
// while loop for passed statements we are done
if (i <= result.size() - 1)
stillRunning = false;
}
}
}// end While
} catch (Exception e) {
e.printStackTrace();
}

}

public void buildDeploymentReport(String rafServer, int rafAutoPort, String user, String pass, String rafProject) {
try {
APIClientConnection conn = new APIClientConnection(rafServer, rafAutoPort);
conn.authUser(user, pass);

// projList = Project.findByName(conn, "TestScriptExecution");
Project projList = Project.findByName(conn, rafProject);
List<Build> buildList = projList.getBuilds();
List<Step> stepList = projList.getSteps();

// build deployment status report
printJobResult(conn, buildList, stepList);

} catch (Exception ex) {
ex.printStackTrace();
}

}

public static void main(String[] args) {
BuildForge bf = new BuildForge();
if (args.length < 5) {
System.out.println("usage: BuildForge <server> <port> <user> <pass> <rafProject>");
System.exit(-1);
}

bf.buildDeploymentReport(args[0], Integer.parseInt(args[1]), args[2], args[3], args[4]);
}
}

Kind regards,

Gerald


Comments
Gerald Gordon commented Jun 21 '13, 3:27 p.m.

 Does anyone have any ideas?  Please reply.


Rich Kulp commented Jun 21 '13, 3:31 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

There is nobody around at this time who can answer the question. We have only one person who knows the build forge integration and he is out of the office right now.


Gerald Gordon commented Jun 24 '13, 6:51 p.m.

Anyone around to help me with this request.  Really hoping for an answer soon. 


Gerald Gordon commented Jun 25 '13, 1:30 p.m.

Buildforge Dev team.  Has someone looked at this request?  Wondering if someone can answer my question, please or point me to a solution. 

2 answers



permanent link
Spencer Murata (2.3k115970) | answered Jun 28 '13, 8:31 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
Is the value pushed in the Build Environment or the master environment?  Either way you want the Result object and use the getBuildEnvironmentUuid or the getEnvironmentUuid depending on where the environment was updated.

Then use the matching BuildEnvironment or the Environment to get the object from the uuid.  Then iterate through the entries to get your environment entry with the result uuid.  Then use the Result object again to get that result back.

~Spencer

Comments
Gerald Gordon commented Jun 28 '13, 9:21 a.m.

Thanks Spencer can you provide a quick example.  I'm not sure how to translate the a Project Environment UUID to a Result Object.   However, I'm now looking at the Result Object to see if I can get this to work based on your recommendation.  


permanent link
Max Börebäck (16122) | answered Aug 12 '13, 2:29 p.m.
 Hi
Here is some code that is working, is is taken from my rest api, that is part of my operations gui solution for RAF.
It makes a nice operations interface that offers a tree table over the envornments and all cells

import java.io.IOException;


import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriInfo;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;


import com.buildforge.services.client.dbo.*;
import com.buildforge.services.common.ServiceException;
import com.buildforge.services.common.dbo.*;


@Path("/Build")
public class ApiBuild {
private ApiConnection raf;
private static final String CLASS_NAME = ApiBuild.class.getName();
public static Logger logger = Logger.getLogger(CLASS_NAME);
    private static DateFormat df = DateFormat.getDateInstance(3, Locale.ENGLISH);
    private static DateFormat tf = DateFormat.getTimeInstance(1, Locale.ENGLISH);
 
private String getListValue(MultivaluedMap<String, String> queryParams,String key,Boolean remove) {
String value = "";
//logger.log(Level.WARNING, "msg" );

if (queryParams.containsKey(key)) {
List<String> values;
values = queryParams.get(key);
if (values.size() > 0) {
value = values.get(0);
}
if (remove) {
queryParams.remove(key);
}
}
return value;
}


private String secondsToTime(Integer secs) {
Integer hours = secs / 3600;
Integer remainder = secs % 3600,
minutes = remainder / 60,
seconds = remainder % 60; 

String disHour = (hours < 10 ? "0" : "") + hours,
disMinu = (minutes < 10 ? "0" : "") + minutes ,
disSec = (seconds < 10 ? "0" : "") + seconds ;
return disHour + ":" + disMinu + ":" + disSec;
}
@Path("/jobStepLog")
@Produces(MediaType.APPLICATION_JSON)
public ExtjsResponse getJobStepLog(
@Context HttpServletRequest request,
@Context UriInfo ui) {

ExtjsResponse res = new ExtjsResponse();

MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
String stepUuid = this.getListValue(queryParams, "uuid",true);

List<NodeLogEntry> resultNodeList = new ArrayList<NodeLogEntry>();

   DateFormat df = DateFormat.getDateInstance(3, Locale.ENGLISH);
   DateFormat tf = DateFormat.getTimeInstance(1, Locale.ENGLISH);
   Date d;
   long date;

// Validate the cell and that user has access rights to it
raf = ApiConnection.getInstance(request,true);
try {
java.util.List<Log> logList = Log.findByResultUuid(raf.conn, stepUuid);
res.success = true;
   if (logList == null) {
       return res;
   }

//    StringBuffer stepResultLog = mapLog(logs);
for (Log node : logList) {
NodeLogEntry entry = new NodeLogEntry();
entry.uuid = node.getUuid();
entry.text  = node.getMessageText();
entry.line = node.getLineId();

date = node.getStamp() * 1000L;
   d = new Date(date);
   entry.timeStamp  = df.format(d) + " " + tf.format(Long.valueOf(date));
entry.type = node.getType();
resultNodeList.add(entry);
}
res.success = true;
res.data.addAll(resultNodeList);
return res;
} catch (IOException e) {
e.printStackTrace();
res.success = false;
res.message = "IOexception";
// Redirect user to login page
return res;
} catch (ServiceException e) {
e.printStackTrace();
res.success = false;
res.message = "ServiceException";
// Redirect user to login page
return res;
}
}
@Path("/progress")
@Produces(MediaType.APPLICATION_JSON)
public ExtjsResponse getJobProgress(
@Context HttpServletRequest request,
@Context UriInfo ui) {
long date;
   Date d;

ExtjsResponse res = new ExtjsResponse();

MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
String buildUuid = this.getListValue(queryParams, "uuid",true);
logger.log(Level.INFO, "progress of build uuid " + buildUuid );
List<NodeResultEntry> resultNodeList = new ArrayList<NodeResultEntry>();

// Validate the cell and that user has access rights to it
raf = ApiConnection.getInstance(request,true);
try {
Build build = Build.findByUuid(raf.conn, buildUuid);
if (build != null){
logger.log(Level.INFO, "build found ");
}
java.util.List<Result> resultList = build.getResults();
logger.log(Level.INFO, "build result " + resultList.toString() );
for (Result node : resultList) {
NodeResultEntry entry = new NodeResultEntry();
entry.uuid = node.getUuid();
entry.description = node.getDirectory();
entry.duration = this.secondsToTime(node.getDuration());

date = node.getFinish() * 1000L;
   d = new Date(node.getStartTimestamp() * 1000L);
   entry.endTime = df.format(d) + " " + tf.format(Long.valueOf(date));

entry.cmd = node.getCommandText();
logger.log(Level.INFO, "step uuid " + entry.uuid );
Integer i = node.getIteration();
Integer m = node.getMaxIterations();
entry.iteration = i.toString() + " ( " + m.toString() + " )";
ResultDBO.StepResult sr = node.getResult();
String result = "";
if (sr == ResultDBO.StepResult.CANCELLED) {
result = "CANCELED";
} else if (sr == ResultDBO.StepResult.FAILED) {
result = "FAILED";
} else if (sr == ResultDBO.StepResult.FAILWARN) {
result = "FAILWARN";
} else if (sr == ResultDBO.StepResult.FILTWARN) {
result = "FILTWARN";
} else if (sr == ResultDBO.StepResult.CANCELLED) {
result = "CANCELLED";
} else if (sr == ResultDBO.StepResult.NONE) {
result = "NONE";
} else if (sr == ResultDBO.StepResult.PASSED) {
result = "PASSED";
} else if (sr == ResultDBO.StepResult.RUNNING) {
result = "RUNNING";
} else if (sr == ResultDBO.StepResult.SKIPPED) {
result = "SKIPPED";
} else if (sr == ResultDBO.StepResult.STOPPED) {
result = "STOPPED";
}
entry.result = result;
//entry.startTime = node.getStartTimestamp();
date = node.getStartTimestamp() * 1000L;
   d = new Date(node.getStartTimestamp() * 1000L);
   entry.startTime = df.format(d) + " " + tf.format(Long.valueOf(date));
resultNodeList.add(entry);
}
res.success = true;
res.data.addAll(resultNodeList);
return res;
} catch (IOException e) {
e.printStackTrace();
res.success = false;
res.message = "IOexception";
// Redirect user to login page
return res;
} catch (ServiceException e) {
e.printStackTrace();
res.success = false;
res.message = "ServiceException";
// Redirect user to login page
return res;
}
}

@Path("/jobCancel")
@Produces(MediaType.APPLICATION_JSON)
public ExtjsResponse getJobCancel(
@Context HttpServletRequest request,
@Context UriInfo ui) {
ExtjsResponse res = new ExtjsResponse();

MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
String buildUuid = this.getListValue(queryParams, "uuid",true);

// Validate the cell and that user has access rights to it
raf = ApiConnection.getInstance(request,true);
try {
Build build = Build.findByUuid(raf.conn, buildUuid);
// Observe that cancel is only valid for running and waiting jobs
// Add check on this
build.cancel();
res.success = true;
res.message = "Job is canceled";
return res;
} catch (IOException e) {
e.printStackTrace();
res.success = false;
res.message = "IOexception";
// Redirect user to login page
return res;
} catch (ServiceException e) {
e.printStackTrace();
res.success = false;
res.message = "ServiceException";
// Redirect user to login page
return res;
}
}

@Path("/jobs")
@Produces(MediaType.APPLICATION_JSON)
public ExtjsResponse getJobs( 
@Context HttpServletRequest request,
@QueryParam("sDate") String sDateString,
@QueryParam("eDate") String eDateString)
{
logger.log(Level.INFO, "in Jobs "  );
ExtjsResponse res = new ExtjsResponse();

List<NodeBuildEntry> buildList = new ArrayList<NodeBuildEntry>();

// Validate the cell and that user has access rights to it
raf = ApiConnection.getInstance(request,true);

try {
logger.log(Level.INFO, "sDateSting " + sDateString );
logger.log(Level.INFO, "eDateString " + eDateString );
Date sDate = new SimpleDateFormat("yyyy-MM-dd").parse(sDateString.substring(0, 10));
Date eDate = new SimpleDateFormat("yyyy-MM-dd").parse(eDateString.substring(0, 10));
logger.log(Level.INFO, "sDate " + sDate.toString() );
//java.util.List<Build> jobList = Build.findAll(raf.conn);
java.util.List<Build> jobList = Build.findBetween(raf.conn,sDate,eDate);
for (Build job : jobList) {
NodeBuildEntry entry = new NodeBuildEntry();
entry.uuid = job.getUuid();
entry.tag = job.getTag();
entry.duration = this.secondsToTime(job.getDuration());

   long date = job.getStartTime() * 1000L;
   Date d = new Date(date);
   entry.startTime = df.format(d) + " " + tf.format(Long.valueOf(date));
if (job.getCancellation()) {
entry.status = "Canceled";
} else {
entry.status = job.getStage();
}
entry.userName = User.findByUuid(raf.conn, job.getUserUuid()).getName();
buildList.add(entry);
}
} catch (IOException e) {
e.printStackTrace();
res.success = false;
res.message = "IOexception";
// Redirect user to login page
return res;
} catch (ServiceException e) {
e.printStackTrace();
res.success = false;
res.message = "ServiceException";
// Redirect user to login page
return res;
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
res.success = false;
res.message = "ParseException " + sDateString;
// Redirect user to login page
return res;
}
res.data.addAll(buildList);
res.total=buildList.size();
res.success = true;
return res;
}
@Path("/jobsUnfinished")
@Produces(MediaType.APPLICATION_JSON)
public ExtjsResponse getJobsUnfinished(
@Context HttpServletRequest request,
@Context UriInfo ui) {
ExtjsResponse res = new ExtjsResponse();

List<NodeBuildEntry> buildList = new ArrayList<NodeBuildEntry>();

   DateFormat df = DateFormat.getDateInstance(3, Locale.ENGLISH);
   DateFormat tf = DateFormat.getTimeInstance(1, Locale.ENGLISH);
   Date d;
   long date;

// Validate the cell and that user has access rights to it
raf = ApiConnection.getInstance(request,true);

try {
java.util.List<Build> jobList = Build.findRunning(raf.conn);
for (Build job : jobList) {
NodeBuildEntry entry = new NodeBuildEntry();
entry.uuid = job.getUuid();
entry.tag = job.getTag();
entry.duration = this.secondsToTime(job.getDuration());

date = job.getStartTime() * 1000L;
   d = new Date(date);
   entry.startTime = df.format(d) + " " + tf.format(Long.valueOf(date));

entry.status = "Running";
entry.userName = User.findByUuid(raf.conn, job.getUserUuid()).getName();
buildList.add(entry);
}
jobList = Build.findWaiting(raf.conn);
for (Build job : jobList) {
NodeBuildEntry entry = new NodeBuildEntry();
entry.uuid = job.getUuid();
entry.tag = job.getTag();
entry.duration = this.secondsToTime(job.getDuration());

date = job.getStartTime() * 1000L;
   d = new Date(date);
   entry.startTime = df.format(d) + " " + tf.format(Long.valueOf(date));

   entry.status = "Waiting";
entry.userName = User.findByUuid(raf.conn, job.getUserUuid()).getName();
buildList.add(entry);
}
jobList = Build.findLocked(raf.conn);
for (Build job : jobList) {
NodeBuildEntry entry = new NodeBuildEntry();
entry.uuid = job.getUuid();
entry.tag = job.getTag();
entry.duration = this.secondsToTime(job.getDuration());

date = job.getStartTime() * 1000L;
   d = new Date(date);
   entry.startTime = df.format(d) + " " + tf.format(Long.valueOf(date));

entry.status = "Locked";
entry.userName = User.findByUuid(raf.conn, job.getUserUuid()).getName();
buildList.add(entry);
}
} catch (IOException e) {
e.printStackTrace();
res.success = false;
res.message = "IOexception";
// Redirect user to login page
return res;
} catch (ServiceException e) {
e.printStackTrace();
res.success = false;
res.message = "ServiceException";
// Redirect user to login page
return res;
}
res.data.addAll(buildList);
res.total=buildList.size();
res.success = true;
return res;

}
@Path("/jobsFinished")
@Produces(MediaType.APPLICATION_JSON)
public ExtjsResponse getJobsFinished(
@Context HttpServletRequest request) {

ExtjsResponse res = new ExtjsResponse();

List<NodeBuildEntry> buildList = new ArrayList<NodeBuildEntry>();

// Validate the cell and that user has access rights to it
raf = ApiConnection.getInstance(request,true);

try {
java.util.List<Build> jobList = Build.findCompleted(raf.conn);
for (Build job : jobList) {
NodeBuildEntry entry = new NodeBuildEntry();
entry.uuid = job.getUuid();
entry.tag = job.getTag();
entry.duration = this.secondsToTime(job.getDuration());

   long date = job.getStartTime() * 1000L;
   Date d = new Date(date);
   entry.startTime = df.format(d) + " " + tf.format(Long.valueOf(date));
if (job.getCancellation()) {
entry.status = "Canceled";
} else {
entry.status = job.getStage();
}
entry.userName = User.findByUuid(raf.conn, job.getUserUuid()).getName();
buildList.add(entry);
}
} catch (IOException e) {
e.printStackTrace();
res.success = false;
res.message = "IOexception";
// Redirect user to login page
return res;
} catch (ServiceException e) {
e.printStackTrace();
res.success = false;
res.message = "ServiceException";
// Redirect user to login page
return res;
}
res.data.addAll(buildList);
res.total=buildList.size();
res.success = true;
return res;

}
@POST
@Path("/fire")
@Produces(MediaType.APPLICATION_JSON)
@Consumes("application/x-www-form-urlencoded")
public ExtjsResponse getFireBuild(
@Context HttpServletRequest request,
//@Context UriInfo ui,
MultivaluedMap<String,String> formData,
@FormParam("dummy") String dummy
) {
ExtjsResponse res = new ExtjsResponse();
//Map<String, String[]> params = request.getParameterMap();

//MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
String planUuid = formData.getFirst("uuid");//this.getListValue(queryParams, "uuid",true);
String ENVIRONMENT = formData.getFirst("ENVIRONMENT");//this.getListValue(queryParams, "ENVIRONMENT",false);
String CELL_NAME = formData.getFirst("CELL_NAME");//this.getListValue(queryParams, "CELL_NAME",false);

// Validate the cell and that user has access rights to it
raf = ApiConnection.getInstance(request,true);
Environment newEnv = null;

try {
Environment env = Environment.findByName(raf.conn, "RAFW_" + ENVIRONMENT + "_" + CELL_NAME);
if (env == null) {
res.success = false;
res.message = "CELL " + formData.toString() + " not found " + CELL_NAME;
// Redirect user to login page
return res;
}

EnvironmentEntry tEntry = env.getEntry("CELL_NAME");
if (tEntry == null) {
res.success = false;
res.message = "CELL_NAME not found in RAFW_" + CELL_NAME;
// Redirect user to login page
return res;
}
tEntry = env.getEntry("ENVIRONMENT");
if (tEntry == null) {
res.success = false;
res.message = "ENVIRONMENT not found in RAFW_" + CELL_NAME;
// Redirect user to login page
return res;
}
} catch (IOException e) {
e.printStackTrace();
res.success = false;
res.message = "IOexception when finding RAFW_" + CELL_NAME;
// Redirect user to login page
return res;
} catch (ServiceException e) {
e.printStackTrace();
res.success = false;
res.message = "ServiceException when finding RAFW_" + CELL_NAME;
// Redirect user to login page
return res;
}

try {
//Build.Request buildRequest = new Build.Request(raf.conn, planUuid);
//Build buildJob = Build.create(raf.conn, planUuid);
//String buildEnvUuid = buildJob.getBuildEnvironmentUuid();
// job created lets add environment entrys
//BuildEnvironment env = BuildEnvironment.findByUuid(raf.conn, buildEnvUuid);
//Environment env = Environment.findByUuid(raf.conn, buildEnvUuid);
//if( env == null){
// res.success = false;
// res.message = "No environment defined for project ";
// Redirect user to login page
// return res;
//}
logger.log(Level.WARNING, "find project by uuid" );
Project proj = Project.findByUuid(raf.conn, planUuid);
if (proj == null) {
res.success = false;
res.message = "Project with uuid " + planUuid + " Not found";
return res;
}
//Environment oldEnv = Environment.findByUuid(raf.conn, proj.getEnvironmentUuid());
//Environment newEnv = oldEnv.clone();
newEnv = new Environment(raf.conn);
newEnv.setLevel(proj.getLevel());
logger.log(Level.WARNING, "have set project level on new env to " + proj.getLevel());
newEnv.setName("11111");
logger.log(Level.WARNING, "have set name on new env to " + "1111");
//logger.log(Level.WARNING, "Cloned existing environment" );
//for (Integer i = 0; i < newEnv.getEntryCount();i++) {
// newEnv.removeEntry(i);
//}
//logger.log(Level.WARNING, "Removed all old entrys" );
//newEnv.update();
//logger.log(Level.WARNING, "Updated new environment" );

//Environment newEnv = new Environment(raf.conn);
// Add all environment entrys from quearyParams
for (Entry<String, List<String>> entry  : formData.entrySet()) {
entry.getKey();
EnvironmentEntry envEntry = new EnvironmentEntry(raf.conn,newEnv);
envEntry.setParameterName(entry.getKey());
List<String> values = entry.getValue();
if (values.size() > 0) {
envEntry.setParameterValue(values.get(0));
} else {
envEntry.setParameterValue("");
}
envEntry.setVariableType(EnvironmentEntryDBO.VariableType.STANDARD);
envEntry.setMode(EnvironmentEntryDBO.Mode.READ_ONLY);
envEntry.update();
newEnv.addEntry(envEntry);
}
logger.log(Level.WARNING, "Added entrys from form" );
//newEnv.update();
//logger.log(Level.WARNING, "Updated new environment" );
//newEnv.setName(newEnv.getName() + 1);
//newEnv.setName("12121212");
//logger.log(Level.WARNING, "Seting name of newEnv" );
newEnv.create();
//newEnv.update();
logger.log(Level.WARNING, "New env created" );
Build.Request br = new Build.Request(proj);
logger.log(Level.WARNING, "created a build request" );
logger.log(Level.WARNING," Org env " + br.getEnvironmentUuid());
br.setEnvironmentUuid(newEnv.getUuid());
logger.log(Level.WARNING, "attached the new environment " + newEnv.getUuid() );
logger.log(Level.WARNING," New env " + br.getEnvironmentUuid());
//Build buildJob = Build.create(br);
//logger.log(Level.WARNING, "created a job " + buildJob.getUuid());
//buildJob.unlock();
//logger.log(Level.WARNING, "Unlocked the build ");
// fire job
//Build.fire(raf.conn, buildJob.getUuid());
Build.fire(br);
logger.log(Level.WARNING, "job fired" );
newEnv.delete();
logger.log(Level.WARNING, "Temporary environment deleted" );

res.success = true;
//res.message = buildJob.getUuid();
res.message = "Jobb scheduled";
// Redirect user to login page
return res;
} catch (IOException e) {
e.printStackTrace();
res.success = false;
res.message = "IOexception when creating job";
// Redirect user to login page
return res;

} catch (ServiceException e) {
e.printStackTrace();
res.success = false;
res.message = "ServiceException when creating job";
// Redirect user to login page
return res;
} finally {
if (newEnv != null){
try {
newEnv.delete();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
res.success = false;
res.message = "IOException when deleting new Env";
// Redirect user to login page
return res;
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
res.success = false;
res.message = "ServiceException when deleting new Env";
// Redirect user to login page
return res;
}
}
}

}

}

Your answer


Register or to post your answer.