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.

Accessing other builds inside velocity template #3707

stephasaurus ·
Hi,

I am creating a velocity template that needs to display the SCM changes for the current build, but also display the SCM changes since the previous successful build. I'm currently trying to do it by using:

#set($oldBuild = $build.getPreviousSuccessful())
#foreach ($change in $build.getChangesSince($oldBuild))

but there is nothing there. Could you please tell me what I am doing wrong? There are no errors in the logs.

And if this way is not possible, do you know of a way that is possible to do this? Thank you!
  • replies 12
  • views 1686
  • stars 0
robinshen ADMIN ·
It works at my side. Do you actually have changes since previous successful build?
stephasaurus ·
Hi - yes, I am sure I have changes. I can see them in the SCM Changes panel.

So mine is still not working in the velocity template for the email, so as an experiment in a configuration step I tried:

Build currentBuild = system.buildManager.get(7582);
logger.info("change size"+currentBuild.getChanges().size());


It comes back as 0, and I know there are SCM changes listed for that build on the SCM Changes panel for the build. Any build I tried to load via the buildManager returned 0 when I tried to access the size of their changes. getChanges().isEmpty() also returned true. The only time it seems to work is in the email, and only for the current build. Could you please try it again on your side?

BTW, we are currently using QB 6.1.25 but are going to upgrade to 7.0.1.
robinshen ADMIN ·
It displays number of changes correctly. I am testing with Subversion. What SCM are you using?
stephasaurus ·
The behavior is the same after upgrading to 7.0.2. Did you also try it outside of the email?

We are using Perforce for SCM but I believe the problem is with Quickbuild though. If in the build that has the Record Changes step, I run a step with build.getChanges().size() it prints the same number as the SCM changes list (60 for example).

Outside that build though, if I instantiate that same build object as myBuild, and do myBuild.getChanges().size(), it says 0.

Similarly, in the velocity template, if I write:

#set($oldBuild = $build.getPreviousSuccessful())
<td>Changes since last successful build: ($oldBuild.id) - $build.getChangesSince($oldBuild).size() - $build.getChangesSince($oldBuild)</td>


It prints (for example): "Changes since last successful build: (7481) - 0 - []"
robinshen ADMIN ·
Yes I tried outside of email and it displays changes correctly. So there might exist some setting at your side I am not aware of yet. Can you please reproduce the issue with a sample database and send me [robin AT pmease DOT com] and let me know the detail steps to reproduce?
stephasaurus ·
I'm not sure I'm going to be able to do that.

I did notice though that if the build I am trying to do myBuild.getChanges() on contains a Repository->Checkout Step, then doing


groovy:

import com.pmease.quickbuild.model.Build;
import com.pmease.quickbuild.entitymanager.BuildManager;
import com.pmease.quickbuild.persistence.*;

Build currentBuild = (Build)system.buildManager.get(7445);
logger.info("current "+currentBuild.getChanges().size());


will show me the changes. But, if that build only as a Repository->Record Changes step, then getChanges() returns nothing. Is there something different between how Repository->Record Changes and Repository->Checkout stores the changes?

Can you please confirm that a build with only a Repository->Record Changes step displays changes for you in the way I am doing it above?
robinshen ADMIN ·
I finally get it reproduced. This is a bug of change recording step and we will get it fixed in QB 7.0.4. Thanks for reporting.
stephasaurus ·
Thank you! And thank you for your time on this, I really appreciate it.

Is there an ETA on QB 7.0.4?
robinshen ADMIN ·
I plan to get it released after the other issue you raised (passing default variable across promotion) got resolved.
robinshen ADMIN ·
7.0.4 is released with the fix:
https://build.pmease.com/build/3483
Note that I forgot to create an corresponding issue so the issue list does not reflect the fix
stephasaurus ·
Hi,

So I tried 7.0.4, and now I can get changes from a record changes step. However, I'm still having problems with the build.getChangesSince() command.

If I have 2 builds, currentBuild and previousBuild, and say they're 20 builds apart (so there are definitely changes), if I do currentBuild.getChangesSince(previousBuild), and both builds are using a Repository->Checkout step, it will get the changes. However, if currentBuild and previousBuild are using Repository->Record Changes steps to get the changes (and no checkout) then it does not work and does not get the changes.

Can you please take a look? Thank you!
robinshen ADMIN ·
Now fixed in 7.0.6:
https://build.pmease.com/build/3526/build_overview