Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

How to get "the last build from yesterday"? #4255

OnQuickBuild ·

Hello Quickbuild support

I'm trying to use Groovy script to retrieve a specific build in history, to access the variables of that build.

And I don't see an easy method from "configuration" object to do this, so I use configuration.getBuilds()
and then try to identify the build I want. However, to access the collection of builds, it gives me this error

org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.pmease.quickbuild.model.Configuration.builds, could not initialize proxy - no Session
    at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(
    at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(
    at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(
    at org.hibernate.collection.internal.PersistentBag.iterator(
    at sun.reflect.GeneratedMethodAccessor28156.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(

My groovy code is just a few lines right now:

def all_builds = configuration.getBuilds() as List

Could you help me? Thank you very much

  • solved #2
  • replies 3
  • views 2086
  • stars 0
Laba42 ·

You have to run this in a session on server node.

import com.pmease.quickbuild.persistence.*
import com.pmease.quickbuild.Context; 

   def startConfiguration  = system.configurationManager.get("root/path2configuration/thatYouWant/")
   for (build in startConfiguration.getBuilds() )
        varValue  = build.getVarValue("YourVarName")     "Value of the variable YourVarName of build ( " +  build.getId() + " )\t" + varValue  ) 
OnQuickBuild ·

Thank you very much!
The session did the trick. Could you tell me why session is needed here?

robinshen ADMIN ·

QB uses the "Open Session In View" pattern to pull data from database as necessary. This pattern requires that operations pulling additional data from database should be using same database session. Hence open session here. Also please note that OSIV only works on server. If you want to run the script on agent side, instead of using "configuration.getBuilds()", please use "system.buildManager.getBuilds(configuration)".