0

I'm running a groovy script using the build flow plugin, the thing is that i'm getting erros each time one of the builds hasn't succeed when trying to run the next build, this is my script:

def RavenAppToBuild = params["project"] + "_Flow"
out.println "Building " + RavenAppToBuild
b = build(RavenAppToBuild, PlatformProject: params["PlatformProject"], PLATFORM_PATH: params["PLATFORM_PATH"])
def ProjectName= b.environment.get("JOB_NAME")
out.println "The application job name is : " + ProjectName
out.println "Updating the platdorm recommended link..."
build ("Update_Platform_Recommended_Link_Flow", PlatformProject: params["PlatformProject"] , NewBaseline: params["NewBaseline"], ProjectName: ProjectName )
out.println "Recommending ive baseline..."
build ("recommend_ive_baseline_Flow", PlatformProject: params["PlatformProject"], ProjectName: ProjectName  )
def chassisToRecommend = params["PlatformProject"] + "_Chassis_Recommended_Flow"
out.println "Building " + chassisToRecommend
build (chassisToRecommend, ProjectName: ProjectName)
out.println "Running release notes job"
build ("release_notes_Flow", PlatformProject: params["PlatformProject"], BaselineToCompare: params["BaselineToCompare"])

How can i control my this process, i'm not sure that using the build status (FAIL/SUCCESS) is quite efficient with a lot of conditions. Is there any way to stop the procees if one of the builds is failing.

Alex Brodov
  • 3,365
  • 18
  • 43
  • 66

1 Answers1

0

You can use the guard / rescue syntax as described on the Build Flow plugin page to run a series of jobs and perform cleanup operations at the end or if any of the builds fails.

You may need to run a cleanup job after a job (or set of jobs) whenever they succeeded or not. The guard/rescue structure is designed for this use-case. It works mostly like a try+finally block in Java language

Dave Bacher
  • 15,652
  • 3
  • 63
  • 86
  • The thing is that `guard` won't solve my problem because each build depends on the previous one, as you can see i have a few lines where i'm taking a few parameters from those builds such as the `JOB_NAME`. – Alex Brodov Dec 30 '14 at 08:58
  • Sorry, can you clarify why not? If you wrap the whole script in a single guard block, it will drop into the rescue block when one of the build statements fails. So statements that reference values of a failed build should not be reached. – Dave Bacher Dec 30 '14 at 17:31