Forum Discussion

scottkib's avatar
scottkib
Occasional Contributor
10 years ago

Need Help Creating QC release with Groovy

Hi all,

 

I am not able to create a release in QC with Groovy

 

I have created a release folder, but get errors when I try to add a release to that folder.  All examples that I have seen are VB which is listed below:  Groovy will not allow me to pass 'null' when adding an item.

 

// Creates the release Folder

Set oReleaseFolderFactory = tdc.ReleaseFolderFactory
Set rootReleaseFolder = oReleaseFolderFactory.Root
Set oReleaseFolderFactory = rootReleaseFolder.ReleaseFolderFactory
Set relFolder = oReleaseFolderFactory.AddItem(Null)
relFolder.Name = "Release Folder 1"
relFolder.Post

 

// Creates the Release

Set relFac = relFolder.ReleaseFactory
Set rel = relFac.AddItem(Null)
rel.Name = "Release 1"
rel.StartDate = DateTime.Now
rel.EndDate = DateTime.Now + 90
rel.Post

 

The work around for Adding a folder is by passing the parent folder ID along with the name, but I am still unable to figure out a way to create a release.  My code is below and the folderID is the Parent ID of the Folder that I want to place the release in.  According to QC's OTA documentation, I should be able to pass Null(which doesnt work with groovy) or Parent folderID.

I keep getting the error, 'Description: Failed to Post Simple Key Entity'

 

// MY - Create the release

relFactory = folder.ReleaseFactory
release = relFactory.AddItem(folderID)
release.Name = "Sprint 51"
release.StartDate = DateTime.Now
release.EndDate = DateTime.Now + 90
release.Post()

2 Replies

  • scottkib's avatar
    scottkib
    Occasional Contributor

    Has anyone been able to accomplish this?..   Creating Releases/Cycles in QC with Groovy

    • scottkib's avatar
      scottkib
      Occasional Contributor

      I figured it out.

       

      The 'Null' that VB is passing is a variant Null where all required fields must be populated in order to later post.  The traditional 'null' parameter in Groovy is not the same, and I needed a variant.

       

      Using scriptom:  

       

      import org.codehaus.groovy.scriptom.*

       

      groovyNull = VariantNull.VARIANTNULL
      defect = bugFactory.AddItem(groovyNull)