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.

Perforce changeset summary #4266

zoywiki ·

I have some repository definition that I would like to run a daily summary against and generate change sets for.

I have a configuration setup like this:
--- root/Build
----- in root/Build lives a repository definition for perforce "My Repo"
--- root/Build/Summary

I would like for root/Build/Summary to populate changesets and send out a email at the end of each day. I have the start and end cl.

I am attempting the following groovy script:

def repo = repositories.get(vars.getValue("RepositoryName"));
def startCL = new com.pmease.quickbuild.plugin.scm.perforce.PerforceRevision( vars.getValue("LastSuccessfulCL") )
def endCL = new com.pmease.quickbuild.plugin.scm.perforce.PerforceRevision( vars.getValue("LatestCL") );

repo.setRevision( startCL );
repo.takeSnapshot();

// What do here?

repo.getChanges(); /// ????

I want to refrain from causing root/Build/Summary to sync at night.

Everything I seem to be trying is not actually populating any change sets into the build root/Build/Summary. Could you assist me where I might have made an error?

  • solved #10
  • replies 10
  • views 3235
  • stars 0
robinshen ADMIN ·

You may add a record changes step referencing your perforce repository. The record changes step will not sync files from Perforce, but can still show changes between builds.

When using this step, groovy script will not be necessary.

zoywiki ·

How do I configure the start and end changelist for the Record Changes step type?

robinshen ADMIN ·

Changing starting/ending changeset is a bit cubersome. By default QB will use changeset number of last successful build as starting changeset, and current changeset in p4 repository as ending changeset.

zoywiki ·

This is why I am trying to do a groovy based solution.

Also If I run reporting configuration while a build is in progress, I want to make sure my change numbers are correct for the period I want to report on.

I could also calculate this manually (via parsing p4 changes output with script), but then how would I add the changeset data to Quickbuild? A much easier solution seems would be telling the reporting functions a starting and ending point.

robinshen ADMIN ·

From your groovy script, looks like that you just want to get changes between last successful build and current build. This is what QB currently does. Or am I misunderstanding something here?

zoywiki ·

You are misunderstanding. I would like a custom range; the names of variables are just used for understanding which 2 variables are being modified.

vars.getValue("LastSuccessfulCL") // start CL
vars.getValue("LatestCL") // end CL

I am using these as example since that is what is most relevant. However I want to do complete custom range (not what quickbuild does out of the box with repository step type), because there may be some build failed before there is a successful builds. Also I want to make a report for users each night containing all changes for the day (or ideally since the last promoted build).

I either need some sample code for:

  1. Making the change set work with a starting and ending changelist number.
  2. Add to the change set dynamically

I have tried to locate some similar code to this on the forum and searching java doc, but I am not sure what to do beyond that.

robinshen ADMIN ·

Unfortunately QB repository will always report changes between last build and current build. Getting changes between arbitrary change number is not supported.

zoywiki ·

If I parse p4 changes, can I add to the change set manually?

robinshen ADMIN ·

Checked again, and it turns out that QB can be forced to report changes between arbitrary change lists. To do it, use below groovy script as pre-execute action of the record changes step:

groovy:
import com.pmease.quickbuild.plugin.scm.perforce.*;
def startCL = new PerforceRevision(vars.getValue("LastSuccessfulCL"));
def endCL = new PerforceRevision(vars.getValue("LatestCL"));
def repo = repositories.get("repo");
repo.getChanges().clear();
repo.getChanges().addAll(repo.getChangesBetween(startCL, endCL));
zoywiki ·

Thanks again Robin! Ultra helpful as always.