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 change trigger, get latest revision #2596

bakerb ·
We need to add a process to our existing QuickBuild configurations that will require variable values to be "inherited" from current configurations. The first thought is to use a build promotion. However we also need this new process to trigger when a specific file is updated in the Perforce repository. Is there a way to trigger promoted builds when a repository change occurs? If not, is there a way to pass variable values from a parent configuration to a child?

Also, this process will need to get the latest file from the repository regardless of what P4 revision the parent build used. I can't seem to find any examples of how to get the latest Perforce revision number and update the workspace accordingly.
  • replies 10
  • views 4444
  • stars 0
robinshen ADMIN ·
You may consider scripting pre-queue script of the child configuration to have it use variable values in source build, for instance:
groovy:
def sourceBuild = configuration.parent.latestBuild;
vars.get("someVar").setValue(sourceBuild.getVarValue("someVar"));
vars.get("someOtherVar").setValue(sourceBuild.getVarValue("someOtherVar"));
bakerb ·
Thanks Robin. This is just what I needed, and I was able to get builds to trigger with Perforce checkin's as well.
bakerb ·
Actually I've now discovered that builds are not being triggered by Perforce checkins.

The Build Condition under "General Settings" is set to "If changes found in referenced repositories". I have some grooy code in the build condition to determine the parent configuration. I tested this code in a text input variable to make sure that the repository is correct. The formatting matches what is shown for Perforce repositories in the QuickBuild 5.0 documentation (it is a single line repository path and filename).

Is there something I may be missing that is preventing the repository change from triggering a build?
robinshen ADMIN ·
Can you please show me the build condition you are using?
bakerb ·
This is in the General Settings Build Condition for the configuration. This same configuration is a child configuration of MAIN and other parents:

Build Condition: "If changes found in referenced repositories"

${groovy:
String config_trailer = "/BuildScripts/PortReview/TicketList.txt"

if ( configuration.parent.getName() == "MAIN") {
result = "//ISW/" + configuration.parent.getName() + config_trailer;
\} else {
result = "//ISW/REL/" + configuration.parent.getName() + config_trailer;
\}

return result;
}
robinshen ADMIN ·
I guess this configuration does not contain any step actually doing sync from the perforce repository? If so, referenced repository will return an empty set to cause nothing can be detected for change. If so, you may modify snapshot taking script of the configuration to use below script:
repositories.get("your perforce repo name").takeSnapshot();

And then configure the build condition to evaluate a script (instead of using the default "If changes found in referenced repositorie"):
groovy:
def config_trailer = "/BuildScripts/PortReview/TicketList.txt"
def result
if ( configuration.parent.getName() == "MAIN") {
result = "//ISW/" + configuration.parent.getName() + config_trailer;
} else {
result = "//ISW/REL/" + configuration.parent.getName() + config_trailer;
}
return repositories.get("your perforce repo name").isChanged(result);
bakerb ·
I may be misunderstanding the use of the build condition in this case. What I'm trying to do is to have the build configuration run automatically if there is a Perforce change submitted for the referenced file. The job itself just copies the same file to two locations.

The configuration has a Repository Checkout step (the repository is set to NORMAL_SYNC). I tried modifying the build condition as you mentioned, and it still didn't run the job when the TicketList.txt file was updated.
robinshen ADMIN ·
Do you have a schedule setting up for this configuration to run automatically? Or you can demonstrate the issue with a test database telling me instructions to reproduce the problem.
bakerb ·
There is no shcedule, we want the build configuration to run automatically if there is a Perforce change submitted for the "TicketList.txt" file referenced.

The build condition above is set to run "If changes found in referenced repositories". I would expect that when a change to the TicketList.tx file is made in Perforce, that the build configuration is then run automatically.
robinshen ADMIN ·
The build condition only gets evaluated when the configuration is triggered via a schedule or triggered by some other configurations via trigger build step. Only define the condition does not cause it to be run automatically.