I'm using TeamCity 5.1.5
I'd like to customize the email notification template on a per project basis.
Project A : use custom email notification email template to include additional info about the build and test results
Project B,C,D : use the default email notification template
I've perused through the TeamCity documentation and looked into the /config/_notifications/email directory and can't seem to find anything that indicates email templates can be configured on a per project basis. Any help is appreciated.
gracias!
As far as I know, the template files can not be configured on a per-project basis.
However, using the FreeMarker expression syntax and properties provided by TeamCity, you can update the e-mail template to conditionally provide certain information for a given project.
For example:
<#if project.name = "Project A">
Build Results: Passable
Test Results: Smelly
</#if>
Followed by #bilai, you can use build.name = "PROJECT_NAME" && buildType.name="CONFIGURATION_NAME" or buildType.externalId = "YOUR_BUILD_CONFIGURATION_ID" for more fine-grained control.
Check out my complete templete code: https://gist.github.com/YoungjaeKim/cf35ef3cba344a2f85e9
Related
How do I integrate a html test results report generated by karma-htmlfile-reporter with VSTS build summary section? Any inputs will help
There is no build-in way to achieve your requirement.
You could create your own extension to display graphical content (HTML page) in my VSTS/TFS summary page.
For example add a custom section in build result through your extension, with this way, you can add html test results report in that custom section.
There is the sample about build result extension: vsts-extension-samples
More information about how to build extension, you can refer to this article
Create your first extension for Visual Studio Team Services
A extension for your reference Publish HTML Artifact
Update
Find another workaround, according to below reply in this question:
VSTS Code coverage supports the outputted code coverage results in
Jacoco or Cobertura formats. Karma-Coverage supports Cobertura
format.
Edit your karma.config.js for ....
Once you configure the output format, you could try to use Publish Code Coverage task to upload code coverage data to VSTS.
TFS can understand a report if it is in the format of a format called TRX.
This can be achieved by using the karma-trx-reporter plugin in the karma.conf.js
Once the report is generated, we can then use MSTest to publish the results
or you can upload using the VSTS workflow function
I am using an NUnit 3 runner in a TeamCity 9.1.6 step. I've chosen "JetBrains dotCover" as the .NET Coverage tool, and now I'd like this step to use the xxx.sln.DotSettings file that we've put in source control and that we're sharing across devs in Visual Studio, rather than to duplicate settings to TeamCity Filters, Attribute Filters etc. Is this possible in TeamCity?
It is not possible from the box now. It is a great idea, could you create an issue here https://youtrack.jetbrains.com/
But there is a simple workaround:
you could parse dotSettins manually on the first step
publish configuration parameters using ##teamcity[setParameter name='ddd' value='fff'] TeamCity service message (see for details https://confluence.jetbrains.com/display/TCD9/Build+Script+Interaction+with+TeamCity)
use those configuration parameters in the appropriate fields for dotCover like %ddd%
I would like to use the Jenkins 'Build Keeper Plugin' but I don't know how. The plugin site doesn't describe how to use it. Plugin Site
On this page I found the extension points which I would like to use, e.g. the org.jenkins_ci.plugins.build_keeper.KeepFirstFailedPolicy
But in the configuration part of my project, I can't find any place to configure it to use that policy. So where do I have to add it?
Jenkins version is 1.544
Have you tried to open Job configuration page and look for settings ?
For example it is another plugin but it is very similar : Build Discard plugin, may be you will use it for your purposes:
Build discard old build settings
You can configure it in the job under the section Build Environment.
For screenshots see also https://issues.jenkins-ci.org/browse/JENKINS-25293
If used from within a pipeline, it is enough to write
'currentBuild.rawBuild.keepLog(true)'
That is unfortunately not an interface to the plugin, just a jobs setting, but can solve it when You want to keep all builds, or decide within the build if to keep it.
Version 2.15 of Jenkins plug-in Email-ext added support for attaching files to build notification e-mails. I would like to have the build log attached to build notification e-mails, but I can't figure out how to do it.
The build log appears to be stored on the Jenkins master node (in this case, Ubuntu Linux). For example, /var/lib/jenkins/jobs/<PROJECT_NAME>/builds/<DATE_TIME>/log. Naturally, the build log path changes with every build. The Email-ext file attachment feature defaults to using files from within the project workspace, which is on the Jenkins slave build machine (in this case, Mac OS X). For example, I configured my slave to use the folder /Users/<USERNAME>/Jenkins/build_agent/workspace/<PROJECT_NAME>/.
Is there any way to get Email-ext to attach a file from the master's file system, instead of the workspace on the slave build machine?
Thanks in advance to anyone who can offer some advice. The Email-ext wiki page currently does not contain an example of how to configure attachments.
You may just use ${BUILD_LOG, maxLines, escapeHtml} token in the body of the e-mail to include the build log.
Quoting the email-ext plugin doc (available here):
"To see a list of all available email tokens and what they display, you can click the "?" (question mark) associated with the Content Token Reference at the top bottom of the email-ext section on the project configuration screen"
The plugin DOES support attaching the build log, you just need to check the box in the project configuration.
After sleeping on the problem and doing more research, I came to the conclusion that Email-ext does not support the attachment of a build log to a build notification e-mail.
However, I did come up with a sneaky work-around to use until such a feature is available: I use the Jenkins build tokens to generate the appropriate command to copy the log file from the master server to the slave's build workspace (see note below).
In the project, after the main compilation step, I added a new Execute shell step to generate the appropriate scp (secure copy) command. This is the command (replace USER and HOSTNAME with your own values, and you'll probably need to tailor the path to suit your individual server):
scp USER#HOSTNAME:/var/lib/jenkins/jobs/$JOB_NAME/builds/$BUILD_ID/log build.log
Then, in the Email-ext Attachments field of the Email-ext plugin, I entered:
build.log
Now the build log is copied from the master to the slave's workspace and attached to build notification e-mail messages. I have removed the $BUILD_LOG token from the message body template.
Note: to use this particular technique, you'll need to have passwordless ssh configured between the slave and the master, perhaps using an OpenSSH key passphrase. If you need help with that, search around the web for information on the ssh-keygen command, and perhaps check tutorials like this one. A similar approach should work on platforms that do not have built-in support for SSH. RoboCopy or similar should work on Windows systems.
EDIT: The Email-ext plug-in now has the ability to attach a build log to a notification message with a check-box on the job's configuration screen. See slide's answer for an example.
When using Jenkinsfile, add attachLog: true to the emailext configuration, like:
emailext attachLog: true, body: '', subject: ''
Credit to #Spencer Malone in Jenkins pipeline - Notify with console error log through email
Firsl of all You have to install Email Ext plugin.After installing follow this step.
Now in to the 'Add post-build action’ select Editable Email Notification and in that section you have option Attach build Log.select option as below in picture.
after that apply and save.Now you will definitely get Build Log in Email attachment.
Thank You.
I have noticed that when i check the box to attach build log, it also unchecks after saving, however it is attached in my emails after the email has been submitted.
I like to send email using hudson ext-email plugin, but with diferent triger than build status. I like to set hudson evn during buil or read it from env file (using env-file plugin) and depends of his value send email or not. How to do that?
BR.Marcin
To conditionally send out an email based on an environment variable set in the build, you'll have to use a scripting language such as Groovy.
Here's an article discussing how to use a Groovy script inside Email-ext.