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.

Email Notification in a step #2053

amn ·
I want to be able to run this command or create a step that produces similar results.

echo "The message body here." | mail -s "${configuration.getPathName()} new file differs." user@gmail.com

What would be the best way to handle this, because as is, it is not working as intended.
  • replies 41
  • views 11906
  • stars 0
robinshen ADMIN ·
A bit script will be required for this to work:
groovy:
import com.pmease.quickbuild.util.*
import com.pmease.quickbuild.entitymanager.*

def receivers = ["user1@gmail.com", "user2@gmail.com"]
def attachments = []
def emailSetting = SettingManager.instance.getEmailSetting()

MiscUtils.sendMail(receivers, "Mail Subject", "Mail Body", attachments, emailSetting, "text/html")
amn ·
This did not work, saying the argument types do not match.

No signature of method: static com.pmease.quickbuild.util.MiscUtils.sendMail() is applicable for argument types: (java.util.ArrayList, java.lang.String, java.lang.String, java.util.ArrayList, com.pmease.quickbuild.setting.system.EmailSetting$$EnhancerByCGLIB$$2cc5e5fa, java.lang.String) values: [[user1@gmail.com, user2@gmail.com], Subject, Body, [], com.pmease.quickbuild.setting.system.EmailSetting$$EnhancerByCGLIB$$2cc5e5fa@32f349fb, text/html]
Possible solutions: sendMail(java.lang.String, java.lang.String, java.lang.String, java.util.Collection, com.pmease.quickbuild.setting.system.EmailSetting)
robinshen ADMIN ·
Sorry, ought to be write as below:

groovy:
import com.pmease.quickbuild.util.*
import com.pmease.quickbuild.entitymanager.*

def receivers = "user1@gmail.com,user2@gmail.com"
def attachments = []
def emailSetting = SettingManager.instance.getEmailSetting()

MiscUtils.sendMail(receivers, "Mail Subject", "Mail Body", attachments, emailSetting)
amn ·
This code sends the email it seems, but QuickBuild thinks the step returns with a failure.

${groovy:

import com.pmease.quickbuild.util.*
import com.pmease.quickbuild.entitymanager.*

def receivers = "user1@gmail.com,user2@gmail.com"
def attachments = []
def emailSetting = SettingManager.instance.getEmailSetting()

MiscUtils.sendMail(receivers, "${configuration.getPathName()\} text...", "The text...", attachments, emailSetting)

}


12:09:04,823 [master>Verify Application Envname>script compare envname email notification@buildap01exdu:8810] INFO - Checking step execute condition...
12:09:04,824 [master>Verify Application Envname>script compare envname email notification@buildap01exdu:8810] INFO - Step execute condition satisfied, executing...
12:09:05,889 [master>Verify Application Envname>script compare envname email notification@buildap01exdu:8810] INFO - Executing pre-execute action...
12:09:05,889 [master>Verify Application Envname>script compare envname email notification@buildap01exdu:8810] INFO - Running step...
12:09:06,231 [master>Verify Application Envname>script compare envname email notification@buildap01exdu:8810] INFO - Sending email: root/~test text...
12:09:06,288 [master>Verify Application Envname>script compare envname email notification@buildap01exdu:8810] INFO - Sent email with 0 attachments
12:09:06,288 [master>Verify Application Envname>script compare envname email notification@buildap01exdu:8810] INFO - Executing post-execute action...
12:09:06,288 [master>Verify Application Envname>script compare envname email notification@buildap01exdu:8810] ERROR - Step 'master>Verify Application>script email notification' is failed.
java.lang.NullPointerException
at java.io.StringReader.<init>(StringReader.java:33)
at com.pmease.quickbuild.util.StringUtils.parseQuoteTokens(StringUtils.java:63)
at com.pmease.quickbuild.plugin.basis.CommandBuildStep.run(CommandBuildStep.java:152)
at com.pmease.quickbuild.plugin.basis.CommandBuildStep$$EnhancerByCGLIB$$ee107f11.CGLIB$run$0(<generated>)
at com.pmease.quickbuild.plugin.basis.CommandBuildStep$$EnhancerByCGLIB$$ee107f11$$FastClassByCGLIB$$c9e45831.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
at com.pmease.quickbuild.DefaultScriptEngine$Interpolator.intercept(DefaultScriptEngine.java:270)
at com.pmease.quickbuild.plugin.basis.CommandBuildStep$$EnhancerByCGLIB$$ee107f11.run(<generated>)
at com.pmease.quickbuild.stepsupport.Step.execute(Step.java:478)
at com.pmease.quickbuild.stepsupport.StepExecutionJob.executeStepAwareJob(StepExecutionJob.java:29)
at com.pmease.quickbuild.stepsupport.StepAwareJob.executeBuildAwareJob(StepAwareJob.java:47)
at com.pmease.quickbuild.BuildAwareJob.execute(BuildAwareJob.java:61)
at com.pmease.quickbuild.grid.GridJob.run(GridJob.java:78)
at java.lang.Thread.run(Thread.java:619)
robinshen ADMIN ·
The step should be "Misc/Execute script", and the surrounding ${} can be removed as the text field itself is assumed to be a script.
amn ·
Instead of emailing a hard-coded string, how would I build the list to email every user of a specified permissions group like the one that has access to the configuration?
robinshen ADMIN ·
Assume you want to send email to all users belonging to group "dev":

groovy:
import com.pmease.quickbuild.util.*
import com.pmease.quickbuild.entitymanager.*

def emails = []
for (membership in MembershipManager.instance.getAll()) {
if (membership.group.name == "dev")
if (membership.user.email != null)
emails.add(membership.user.email)
}

def attachments = []
def emailSetting = SettingManager.instance.getEmailSetting()

MiscUtils.sendMail(emails.join(","), "Mail Subject", "Mail Body", attachments, emailSetting)
amn ·
Is there a way for me to change who is sending the email?

Right now it is sending it from quickbuild@host which causes an issue because this can be sometimes interpreted as an invalid sender because it is not the fully qualified hostname. I don't want to change the system default to have hostname return the fully qualified domain name though. Being able to send the email from quickbuild@`hostname -f` instead of `hostname` is the goal.
robinshen ADMIN ·
To achieve this, please edit email setting in QuickBuild administration page, and specify sender address as:
quickbuild@${groovy:"hostname -f".execute().text}
amn ·
Is there a way for me to change this step if placed in a post-build script to have the message body the same as or similar to the table provided by the notification email sent when a user subscribes to a configuration?
robinshen ADMIN ·
This almost duplicates the functionality of what QB notifier does in groovy code. Any reason why the default email notifier does not fit here?
amn ·
Yes, we need to be able to notify a number of users/mailing lists when specific configurations are run without them having to subscribe to every configuration and without them subscribing to them all and having to filter out the ones that don't mean anything to them.

The idea is if it is a developer install to email all of the developers with permission to that configuration. (Could be handled by the notifications probably, but we don't want to rely on them subscribing.)

The test installs will email all of the developers plus another mailing list.

The production installs will email all of the developers plus a number of other mailing lists.

With the last two there are people in those lists that don't have a real reason to ever log in to QuickBuild. Building the notification this way allows us to basically define the subscriptions as administrators instead of relying on the users and non-users to do it.
robinshen ADMIN ·
QB does be able to send notifications to users even if they do not subscribe to get notifications. Check the notifications tab in configuration settings page. Here you may define forcible notifications, and even you can send email to non QB users, as long as you create a pseudo QB user and define the email as a mailing list or comma separated email list.
amn ·
Right, but this also creates extra setup for each new project or environment we define whereas the code I added was to the Post-Build Script at the root level and is inherited down and will only send the notifications for specific configuration names to a specific permissions group as well as three Microsoft Outlook mailing lists that are not defined in QuickBuild. This way also allowed for greater customization of these specific emails to match what our previous install scripts showed in the subject to be familiar to those receiving them and ease the transition from one process to the next without messing with the default notifications in QuickBuild.

Basically, I created a second notification template for only specific configuration names to send to people who may or may not be in QuickBuild that was only needed to be defined once and never touched again. If I used the forced subscriptions we would have to make sure to add them for every specific configuration.
robinshen ADMIN ·
OK, I understand your point now to achieve flexibility. To evaluate a Velocity, add below code in your groovy script:

import com.pmease.quickbuild.*
import com.pmease.quickbuild.util.*

def evaluatedEmailBody = VelocityUtils.evalTemplate("#parse (\"default_html_notification.vm\")", Context.buildEvalContext(null, null))


Then you may proceed to send email using evaluatedEmailBody.
jsahoo1980 ·
HI

Requirement:
I ahve 2 sample project. I want to create one more project called sample3 and when I want to build sample3 it should build sample1 and sample2 and changes of these two projects output will display sample3 project notification mail. Could you please let me know the steps define for this task.

Quick response appriciated ....!

Currently when I am getting sample3 project notification mail i am getting sample1 and sample2 latest build version and displayed in changeset portion in notification mail of sample3. But I am not getting sample1 changes and sample2 changes details in this mail.
robinshen ADMIN ·
If sampe1 and sample2 are triggered by sample3 via trigger build step, you may edit email notification velocity template to include changes from triggered build. For instance, put below section in "asset/default_html_notification.vm":

#foreach ($step in $build.steps)
#if ($step.class.name.contains("TriggerBuildStep"))
#set ($triggeredBuildId = $step.runtime.customData)
#if ($triggeredBuildId)
#set ($triggeredBuild = $system.buildManager.load($triggeredBuildId))
#foreach ($change in $triggeredBuild.changes)
// format changes information from the triggered build as the changes printting section of current build in this file
#end
#end
#end
#end
jsahoo1980 ·
Hi Robinson,
As you have mentioned the vlocity template code for getting consolidate mail.I have tried to modify ...\asset\default_html_notification.vm But I am not able to achive my goal.

Could you please let us know wheteher we can write the value came from each project(Sample1,sample2) build reports to one txt file and read the value from this txt file and consolidated in sample3 project build reports.
amn ·
Did the MiscUtils.sendMail change in QuickBuild 5? After upgrading it is now complaining about the arguments being specified.
robinshen ADMIN ·
[quote="amn"]Did the MiscUtils.sendMail change in QuickBuild 5? After upgrading it is now complaining about the arguments being specified.[/quote]
It now inlcudes a cclist as second param. So please change your code accordingly.
robinshen ADMIN ·
[quote="jsahoo1980"]Hi Robinson,
As you have mentioned the vlocity template code for getting consolidate mail.I have tried to modify ...\asset\default_html_notification.vm But I am not able to achive my goal.

Could you please let us know wheteher we can write the value came from each project(Sample1,sample2) build reports to one txt file and read the value from this txt file and consolidated in sample3 project build reports.[/quote]

What problem with the template? Writing build reports of each project to a text file should also work, but seems to be more verbose.
amn ·
[quote="robinshine"][quote="amn"]Did the MiscUtils.sendMail change in QuickBuild 5? After upgrading it is now complaining about the arguments being specified.[/quote]
It now inlcudes a cclist as second param. So please change your code accordingly.[/quote]

There seems to be more than just this. It is telling me there are two additional arguments. This is what I was using before:

MiscUtils.sendMail(to, subject, body, attachments, emailSetting)

This is what it is suggesting as a possible solution:

Possible solutions: sendMail(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.util.Collection, com.pmease.quickbuild.setting.system.EmailSetting, java.lang.String)
amn ·
If I add "text/html" as the last java.lang.String argument I then receive a different error.

com.pmease.quickbuild.QuickbuildException: java.lang.NoClassDefFoundError: Could not initialize class com.pmease.quickbuild.CacheManager

I'm not sure what is trying to call this class though. I only import the following two classes.

import com.pmease.quickbuild.util.*
import com.pmease.quickbuild.entitymanager.*

I tried adding "import com.pmease.quickbuild.CacheManager.*" to the top, but it did not change the error.
robinshen ADMIN ·
This is odd, can you please show me the full script you are using? And in which place?
jsahoo1980 ·
[quote="robinshine"][quote="jsahoo1980"]Hi Robinson,
As you have mentioned the vlocity template code for getting consolidate mail.I have tried to modify ...\asset\default_html_notification.vm But I am not able to achive my goal.

Could you please let us know wheteher we can write the value came from each project(Sample1,sample2) build reports to one txt file and read the value from this txt file and consolidated in sample3 project build reports.[/quote]

What problem with the template? Writing build reports of each project to a text file should also work, but seems to be more verbose.[/quote]


HI Robinson,
The Problem with template is we are always pointing to ...\asset\default_html_notification.vm .Even if our parent project and our chield projects all are pointing to this(...\asset\default_html_notification.vm ) file. But Our requirement was when we triggered build for parents we will get one notification mail and it will show all the changes made in child projects and parent projects. Current configuartion always showing each individual mail notification. For taht reason I have queried you whether its possible if we will write the value of each child project build output in to a txt file and when parent project will give the final out put as a notification mail, we can take the value from txt file and will display in consolidate mail report to users. Please let us know any idea how we can achive our goal .As you are telling it seems to be more verbose .could you pleas let us know how we will wrtie the value to txt file and read the file and consolidated out default_html_notification.vm file.
amn ·
It is an Execute Script step and is run from the configuration at this level: root/project/install/deploy/environment

groovy:

import com.pmease.quickbuild.util.*
import com.pmease.quickbuild.entitymanager.*

def path = configuration.getPathName()
logger.info("path: " + path)
def m = path =~ /root\/(.*)\/install.*/
def group = m[0][1]
group = group.replaceAll("/","_")
logger.info("group: " + group)
def emails = []

for (membership in MembershipManager.instance.getAll()) {
if (membership.group.name == group) {
if (membership.user.email != null) {
logger.info("email: " + membership.user.email)
emails.add(membership.user.email)
}
}
}

if (configuration.getName() =~ /production1/ || configuration.getName() =~ /production2/) {
emails.add('group1@oclc.org')
emails.add('group2@oclc.org')
}

def attachments = []
def emailSetting = SettingManager.instance.getEmailSetting()

def current = new File (vars.getValue("deployRoot") + "/prod/ini/build.ini")
def next = new File (vars.getValue("deployRoot") + "/new/ini/build.ini")
def current_envName
def next_envName

logger.info("Running envName compare...")

if (current.exists()) {
logger.info("Current exists...")
def lines = current.readLines()
def words = lines.toList()
for (word in words) {
if (word.contains("envName=")) {
current_envName = word
}
}
if (next.exists()) {
lines = next.readLines()
words = lines.toList()
for (word in words) {
if (word.contains("envName=")) {
next_envName = word
}
}
}
if (current_envName.toString().equals(next_envName.toString())) {
logger.info("The ENVNAME parameters match.")
return true
} else {
logger.info("The ENVNAME parameters do not match.")
MiscUtils.sendMail(emails.join(","), "", "** QuickBuild 5 - ENVNAME does not match - ${configuration.getParent().getName()}/" + group + " ${configuration.getName()} **", "The envname parameter of the current install and new install do not match so a rolling install is not possible. Verify that the install/rollout plan is specified correctly.<br><br> prod: $current_envName <br> new: $next_envName <br><br> Build overview: http://hostname:8810/build/${build.getId()}/overview", attachments, emailSetting, "text/html")
}
} else {
logger.info("Current does not exist...")
MiscUtils.sendMail(emails.join(","), "", "** QuickBuild 5 - No current installation - ${configuration.getParent().getName()}/" + group + " ${configuration.getName()} **", "There is no current install of this service under the specified install directory. Verify that the install/rollout plan is specified correctly.<br><br> Build overview: http://hostname:8810/build/${build.getId()}/overview", attachments, emailSetting, "text/html")
}
robinshen ADMIN ·
[quote="jsahoo1980"][quote="robinshine"][quote="jsahoo1980"]Hi Robinson,
As you have mentioned the vlocity template code for getting consolidate mail.I have tried to modify ...\asset\default_html_notification.vm But I am not able to achive my goal.

Could you please let us know wheteher we can write the value came from each project(Sample1,sample2) build reports to one txt file and read the value from this txt file and consolidated in sample3 project build reports.[/quote]

What problem with the template? Writing build reports of each project to a text file should also work, but seems to be more verbose.[/quote]


HI Robinson,
The Problem with template is we are always pointing to ...\asset\default_html_notification.vm .Even if our parent project and our chield projects all are pointing to this(...\asset\default_html_notification.vm ) file. But Our requirement was when we triggered build for parents we will get one notification mail and it will show all the changes made in child projects and parent projects. Current configuartion always showing each individual mail notification. For taht reason I have queried you whether its possible if we will write the value of each child project build output in to a txt file and when parent project will give the final out put as a notification mail, we can take the value from txt file and will display in consolidate mail report to users. Please let us know any idea how we can achive our goal .As you are telling it seems to be more verbose .could you pleas let us know how we will wrtie the value to txt file and read the file and consolidated out default_html_notification.vm file.[/quote]

What I am suggesting is to use a different html template for email for your parent projects, for instance you may create a separate email notification template in "asset" directory as "aggregated_html_notification.vm" containing the modification I suggested earlier. And then modify your parent projects to use this template by editing email notification template in general setting to use below value:
#parse ("aggregated_html_notification.vm")

For other configurations you do not want aggregated notification, you may simply revert to use
#parse ("default_html_notification.vm")
robinshen ADMIN ·
[quote="amn"]It is an Execute Script step and is run from the configuration at this level: root/project/install/deploy/environment

groovy:

import com.pmease.quickbuild.util.*
import com.pmease.quickbuild.entitymanager.*

def path = configuration.getPathName()
logger.info("path: " + path)
def m = path =~ /root\/(.*)\/install.*/
def group = m[0][1]
group = group.replaceAll("/","_")
logger.info("group: " + group)
def emails = []

for (membership in MembershipManager.instance.getAll()) {
if (membership.group.name == group) {
if (membership.user.email != null) {
logger.info("email: " + membership.user.email)
emails.add(membership.user.email)
}
}
}

if (configuration.getName() =~ /production1/ || configuration.getName() =~ /production2/) {
emails.add('group1@oclc.org')
emails.add('group2@oclc.org')
}

def attachments = []
def emailSetting = SettingManager.instance.getEmailSetting()

def current = new File (vars.getValue("deployRoot") + "/prod/ini/build.ini")
def next = new File (vars.getValue("deployRoot") + "/new/ini/build.ini")
def current_envName
def next_envName

logger.info("Running envName compare...")

if (current.exists()) {
logger.info("Current exists...")
def lines = current.readLines()
def words = lines.toList()
for (word in words) {
if (word.contains("envName=")) {
current_envName = word
}
}
if (next.exists()) {
lines = next.readLines()
words = lines.toList()
for (word in words) {
if (word.contains("envName=")) {
next_envName = word
}
}
}
if (current_envName.toString().equals(next_envName.toString())) {
logger.info("The ENVNAME parameters match.")
return true
} else {
logger.info("The ENVNAME parameters do not match.")
MiscUtils.sendMail(emails.join(","), "", "** QuickBuild 5 - ENVNAME does not match - ${configuration.getParent().getName()}/" + group + " ${configuration.getName()} **", "The envname parameter of the current install and new install do not match so a rolling install is not possible. Verify that the install/rollout plan is specified correctly.<br><br> prod: $current_envName <br> new: $next_envName <br><br> Build overview: http://hostname:8810/build/${build.getId()}/overview", attachments, emailSetting, "text/html")
}
} else {
logger.info("Current does not exist...")
MiscUtils.sendMail(emails.join(","), "", "** QuickBuild 5 - No current installation - ${configuration.getParent().getName()}/" + group + " ${configuration.getName()} **", "There is no current install of this service under the specified install directory. Verify that the install/rollout plan is specified correctly.<br><br> Build overview: http://hostname:8810/build/${build.getId()}/overview", attachments, emailSetting, "text/html")
}
[/quote]

This script works fine at my side. Please make sure you are running this script at server side instead of on agent.
jsahoo1980 ·
Hi Robinshine

As you have suggest us for using below code. I have created "aggregated_html_notification.vm" under "asset" directory.And I have changed my parent project configuration to use this template by editing email notification template in general
setting.But still I am not able to get my child project changes/modification value in my parent email notification.I think we
are not able to access child project value in parent project. My Query again is that .....Is there any mechanism when child
project build will complet it will store the changes/modification data in somewhere. If yes, is it possible to access this
value in our parent notification vm file (aggregated_html_notification.vm). Then I think we cana chive our goal.Waiting your response as earliest.

(aggregated_html_notification.vm).....

#foreach ($step in $build.steps)
#if ($step.class.name.contains("TriggerBuildStep"))
#set ($triggeredBuildId = $step.runtime.customData)
#if ($triggeredBuildId)
#set ($triggeredBuild = $system.buildManager.load($triggeredBuildId))
#foreach ($change in $triggeredBuild.changes)
// format changes information from the triggered build as the changes printting section of current build in this file
#end
#end
#end
#end
amn ·
[quote="robinshine"][quote="amn"]It is an Execute Script step and is run from the configuration at this level: root/project/install/deploy/environment

groovy:

import com.pmease.quickbuild.util.*
import com.pmease.quickbuild.entitymanager.*

def path = configuration.getPathName()
logger.info("path: " + path)
def m = path =~ /root\/(.*)\/install.*/
def group = m[0][1]
group = group.replaceAll("/","_")
logger.info("group: " + group)
def emails = []

for (membership in MembershipManager.instance.getAll()) {
if (membership.group.name == group) {
if (membership.user.email != null) {
logger.info("email: " + membership.user.email)
emails.add(membership.user.email)
}
}
}

if (configuration.getName() =~ /production1/ || configuration.getName() =~ /production2/) {
emails.add('group1@oclc.org')
emails.add('group2@oclc.org')
}

def attachments = []
def emailSetting = SettingManager.instance.getEmailSetting()

def current = new File (vars.getValue("deployRoot") + "/prod/ini/build.ini")
def next = new File (vars.getValue("deployRoot") + "/new/ini/build.ini")
def current_envName
def next_envName

logger.info("Running envName compare...")

if (current.exists()) {
logger.info("Current exists...")
def lines = current.readLines()
def words = lines.toList()
for (word in words) {
if (word.contains("envName=")) {
current_envName = word
}
}
if (next.exists()) {
lines = next.readLines()
words = lines.toList()
for (word in words) {
if (word.contains("envName=")) {
next_envName = word
}
}
}
if (current_envName.toString().equals(next_envName.toString())) {
logger.info("The ENVNAME parameters match.")
return true
} else {
logger.info("The ENVNAME parameters do not match.")
MiscUtils.sendMail(emails.join(","), "", "** QuickBuild 5 - ENVNAME does not match - ${configuration.getParent().getName()}/" + group + " ${configuration.getName()} **", "The envname parameter of the current install and new install do not match so a rolling install is not possible. Verify that the install/rollout plan is specified correctly.<br><br> prod: $current_envName <br> new: $next_envName <br><br> Build overview: http://hostname:8810/build/${build.getId()}/overview", attachments, emailSetting, "text/html")
}
} else {
logger.info("Current does not exist...")
MiscUtils.sendMail(emails.join(","), "", "** QuickBuild 5 - No current installation - ${configuration.getParent().getName()}/" + group + " ${configuration.getName()} **", "There is no current install of this service under the specified install directory. Verify that the install/rollout plan is specified correctly.<br><br> Build overview: http://hostname:8810/build/${build.getId()}/overview", attachments, emailSetting, "text/html")
}
[/quote]

This script works fine at my side. Please make sure you are running this script at server side instead of on agent.[/quote]

I want to be running this on an agent and always have in the past. Is there some reason this is no longer possible? The entire purpose is to check a part of the application install done by the agent on the host it is running on.
robinshen ADMIN ·
[quote="jsahoo1980"]Hi Robinshine

As you have suggest us for using below code. I have created "aggregated_html_notification.vm" under "asset" directory.And I have changed my parent project configuration to use this template by editing email notification template in general
setting.But still I am not able to get my child project changes/modification value in my parent email notification.I think we
are not able to access child project value in parent project. My Query again is that .....Is there any mechanism when child
project build will complet it will store the changes/modification data in somewhere. If yes, is it possible to access this
value in our parent notification vm file (aggregated_html_notification.vm). Then I think we cana chive our goal.Waiting your response as earliest.

(aggregated_html_notification.vm).....

#foreach ($step in $build.steps)
#if ($step.class.name.contains("TriggerBuildStep"))
#set ($triggeredBuildId = $step.runtime.customData)
#if ($triggeredBuildId)
#set ($triggeredBuild = $system.buildManager.load($triggeredBuildId))
#foreach ($change in $triggeredBuild.changes)
// format changes information from the triggered build as the changes printting section of current build in this file
#end
#end
#end
#end[/quote]

Yes, it is easy to write changes to external file after child project finishes (just call some groovy code to navigate throug build.changes and write the content), but it is not easy to read these files in velocity. Velocity is more good at navigating in-memory objects. Are your child projects triggered via the "trigger build step" and "wait for finish" flag is set to "yes", or via QuickBuild repository?
robinshen ADMIN ·
[quote="amn"][quote="robinshine"][quote="amn"]It is an Execute Script step and is run from the configuration at this level: root/project/install/deploy/environment

groovy:

import com.pmease.quickbuild.util.*
import com.pmease.quickbuild.entitymanager.*

def path = configuration.getPathName()
logger.info("path: " + path)
def m = path =~ /root\/(.*)\/install.*/
def group = m[0][1]
group = group.replaceAll("/","_")
logger.info("group: " + group)
def emails = []

for (membership in MembershipManager.instance.getAll()) {
if (membership.group.name == group) {
if (membership.user.email != null) {
logger.info("email: " + membership.user.email)
emails.add(membership.user.email)
}
}
}

if (configuration.getName() =~ /production1/ || configuration.getName() =~ /production2/) {
emails.add('group1@oclc.org')
emails.add('group2@oclc.org')
}

def attachments = []
def emailSetting = SettingManager.instance.getEmailSetting()

def current = new File (vars.getValue("deployRoot") + "/prod/ini/build.ini")
def next = new File (vars.getValue("deployRoot") + "/new/ini/build.ini")
def current_envName
def next_envName

logger.info("Running envName compare...")

if (current.exists()) {
logger.info("Current exists...")
def lines = current.readLines()
def words = lines.toList()
for (word in words) {
if (word.contains("envName=")) {
current_envName = word
}
}
if (next.exists()) {
lines = next.readLines()
words = lines.toList()
for (word in words) {
if (word.contains("envName=")) {
next_envName = word
}
}
}
if (current_envName.toString().equals(next_envName.toString())) {
logger.info("The ENVNAME parameters match.")
return true
} else {
logger.info("The ENVNAME parameters do not match.")
MiscUtils.sendMail(emails.join(","), "", "** QuickBuild 5 - ENVNAME does not match - ${configuration.getParent().getName()}/" + group + " ${configuration.getName()} **", "The envname parameter of the current install and new install do not match so a rolling install is not possible. Verify that the install/rollout plan is specified correctly.<br><br> prod: $current_envName <br> new: $next_envName <br><br> Build overview: http://hostname:8810/build/${build.getId()}/overview", attachments, emailSetting, "text/html")
}
} else {
logger.info("Current does not exist...")
MiscUtils.sendMail(emails.join(","), "", "** QuickBuild 5 - No current installation - ${configuration.getParent().getName()}/" + group + " ${configuration.getName()} **", "There is no current install of this service under the specified install directory. Verify that the install/rollout plan is specified correctly.<br><br> Build overview: http://hostname:8810/build/${build.getId()}/overview", attachments, emailSetting, "text/html")
}
[/quote]

This script works fine at my side. Please make sure you are running this script at server side instead of on agent.[/quote]

I want to be running this on an agent and always have in the past. Is there some reason this is no longer possible? The entire purpose is to check a part of the application install done by the agent on the host it is running on.[/quote]

You are right, please upgrade to below build to fix the issue (not able to run from agent):
https://build.pmease.com/build/2302/overview
jsahoo1980 ·
Hi Robinshine

Could you please let us know how we will write the value to external file.We are not triggered child project as "triggered build step".We are to able to define how to "trifgger build step" and "wait for finish" flag set.Please let us know briefly if you do not mind.

[quote="robinshine"][quote="jsahoo1980"]Hi Robinshine

As you have suggest us for using below code. I have created "aggregated_html_notification.vm" under "asset" directory.And I have changed my parent project configuration to use this template by editing email notification template in general
setting.But still I am not able to get my child project changes/modification value in my parent email notification.I think we
are not able to access child project value in parent project. My Query again is that .....Is there any mechanism when child
project build will complet it will store the changes/modification data in somewhere. If yes, is it possible to access this
value in our parent notification vm file (aggregated_html_notification.vm). Then I think we cana chive our goal.Waiting your response as earliest.

(aggregated_html_notification.vm).....

#foreach ($step in $build.steps)
#if ($step.class.name.contains("TriggerBuildStep"))
#set ($triggeredBuildId = $step.runtime.customData)
#if ($triggeredBuildId)
#set ($triggeredBuild = $system.buildManager.load($triggeredBuildId))
#foreach ($change in $triggeredBuild.changes)
// format changes information from the triggered build as the changes printting section of current build in this file
#end
#end
#end
#end[/quote]

Yes, it is easy to write changes to external file after child project finishes (just call some groovy code to navigate throug build.changes and write the content), but it is not easy to read these files in velocity. Velocity is more good at navigating in-memory objects. Are your child projects triggered via the "trigger build step" and "wait for finish" flag is set to "yes", or via QuickBuild repository?[/quote]
robinshen ADMIN ·
Sorry I am a bit confused with "We are not triggered child project as "triggered build step".We are to able to define how to "trifgger build step" and "wait for finish" flag set". I am still not sure how you configure QB to run child configurations in parent configuration.
jsahoo1980 ·
Hi Robin
We are defining our parent project and child project such a manner that ,once all child project completed parent project will sent a notification as a mail to administrator. in our build step we have defined like that. As I have discussed with you, we can write all the results value to external txt file for each child project build complete. we need the grovey code how we can write the value in external file.
Again I am giving the requirement.if youa re not able to clear our requirement please let me know.

Example:
I have parent project called "A". Under the A project we have 3 child projects called(B,C,D).And we have made the build step like once A build will trigerred same time B,C,D project will triggered and wait for completion of all child project completion. Once completing of child project each changeset value will write to an external file. And When parent project A build will complet that time we can read the value from the external file and thru velocity we can display in notification email(...\asset\default_html_notification.vm).

Now we are achiving each build changeset for each project build completion.But we are not cumulative the value in one notification mail. we are getting each mail notification for each chield project build changeset.
robinshen ADMIN ·
So you are triggering child configurations in parent configuration via the step "Trigger Other Builds"?
jsahoo1980 ·
[quote="robinshine"]So you are triggering child configurations in parent configuration via the step "Trigger Other Builds"?[/quote]


yes we are triggering child configuration in parent configuration via the step
robinshen ADMIN ·
[quote="jsahoo1980"][quote="robinshine"]So you are triggering child configurations in parent configuration via the step "Trigger Other Builds"?[/quote]


yes we are triggering child configuration in parent configuration via the step[/quote]

I've sent you an email including a demo database and velocity template demonstrating how to accomplish this.
jsahoo1980 ·
Hi Robin

I did not get any mail till now,Could you please sent mail in this address(jsahoo1980@gmail.com)

[quote="robinshine"][quote="jsahoo1980"][quote="robinshine"]So you are triggering child configurations in parent configuration via the step "Trigger Other Builds"?[/quote]


yes we are triggering child configuration in parent configuration via the step[/quote]

I've sent you an email including a demo database and velocity template demonstrating how to accomplish this.[/quote]
robinshen ADMIN ·
Strange. Got it resent.
gene ·
Hello Robin,
I would like to do that too, can you please send me that demo database and velocity template demonstrating to my email id - ajay_spark99@yahoo.com