Is it possible to generate build emails in Visual Studio Team Services for a successful build ONLY if the previous build was a failure? - azure-devops

As far as I can tell from the current interface provided for setting up e-mail alerts for builds in visual studio team services, there is no way to set a condition on the status of the previous build.
I expect this is relevant to many development teams as teams will typically have a build server churning out builds frequently throughout the day and will want e-mail alerts of a failure. Following a failed build, it is useful to also have a success email for the next build. However, you don't want an e-mail for every successful build as you are only interested in this after a failure, the rest is just white noise.
So is there any way to create alerts conditional upon the previous build in visual studio team services, or more specifically to just get success e-mails after a failed build?

There isn't any way to do this with the alerts feature in VSTS for now. You can submit a feature request on VSTS User Voice.
And the alternative way to achieve this feature would be create an application/service to track the build event and send out email notification base on the build status you want via VSTS Rest API or TFS API.

Related

How to send SonarQube report to developers whenever the Azure DevOps build succeeded or failed

I have integrated the SonarQube tasks in Azure DevOps build pipeline. I can be able to successfully the scan my application source code using SonarQube.
I want to share the SonarQube report to Developers whenever the Sonar build succeeded or failed.
For notification settings, first of all, you need to have mail server or you can use popular ones (Gmail and etc.). Have a look at the below article for the every step you need to perform ;
https://www.fosstechnix.com/sonarqube-email-notifications/
Another possible way is if you have limitations in the Sonarqube server;
Create quality gate in Sonarqube based on your profile
https://docs.sonarqube.org/latest/user-guide/quality-gates/
Use following plugin to break your pipeline in case of code were not passed the gate
https://marketplace.visualstudio.com/items?itemName=SimondeLang.sonar-buildbreaker
Create mail notification in Azure Devops to send notification when build failed because of Sonarqube quality gate;
https://learn.microsoft.com/en-us/azure/devops/notifications/about-notifications?view=azure-devops#team-and-project-level-notifications
And as shown below you will see the reason about why pipeline build failed in the mail

Best way to send email notification in an Azure DevOps build pipeline? Do not want to use "Notifications Module"

I would like to send email notifications as a task in my Azure DevOps build so that I can copy the build to other team projects and have it work automatically. I don't want to setup notifications for every new project I create. Thanks!
You can install the Send Email task from the marketplace, and add it to your build pipline.
The extension takes care of sending email within your build or release pipeline.
But better way is configure a global notification settings for the builds.
I tried to use "Send Email" to send something from my gmail but it didn't work out. I got the error message below
The SMTP server requires a secure connection or the client was not
authenticated.
If you have a similar problem, I recommend you using SendGrid. It's more easier.
Just create a resource "SendGrid" on Azure Portal.
Create an API Key from SendGrid.
Configure the pipeline with the key.
That's it. You don't have to config any SMTP setting and figure out what it is.
For an alternative solution, you can try CatLight notification tool.
It will show desktop alerts about build and release problems, as well as new PRs and work items.
You can configure a shared dashboard for the team, and select all relevant projects and pipelines there. After that, the team members will be notified about failed builds and releases. Team members can also update those monitoring settings themselves at any time.
Azure DevOps can send too many notifications, and when developers check their inbox, many of those notifications are outdated. So, after a while they configure filters to hide them, defeating the purpose of notifications in the first place. CatLight has a dashboard that will show a summary of active alerts, and they will disappear from it as soon as alert is resolved. So it will be less noisy, and harder to ignore than emails.
The tool is free for small teams and open-source, and their is paid version for companies.

Send notification to all developers when a release fails in VSTS (prev. VSO)

I'm using Visual Studio Team Services (VSTS), previously known as Visual Studio Online (VSO) to build a Continuous Delivery pipeline. My goal is to follow as close as possible the Continuous Delivery book from Jez Humble and David Farley.
I would like that when a stage (named Environment in VSTS) fails, a notification (an email) is sent to every developers involved in this release. This notification would say either :
You broke the stage (Regression)
The stage was already broken (Failed)
You fixed the stage. (Fixed)
Currently, only the person who created the release manually (or by pushing the commit which triggered the build and after that the release) will receive this email and without the information I want.
I've played a little bit with VSTS API, and can get the associated commits (and the developers email) for a given build (but not for a given release) :
$token = "vsts token"
$endpoint = "https://acme.visualstudio.com/DefaultCollection/MyProject/_apis/build/builds/42/changes?api-version=2.0"
$b64creds = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$($token):a"))
$changes = Invoke-RestMethod -Headers #{Authorization="Basic $b64creds"} $endpoint
$changes.value | ForEach-Object { $_.author.uniqueName }
I've seen that in VSTS interface, you can see which commits were added between 2 releases. It's very close of what I want even if I didn't found this information in the API. But even with this information, a same release definition is used for all branches of my project, so for example Release-26 will be a feature branch and Release-27 will be develop. It doesn't make sense to compare these 2 releases.
I know that I can get the build ID in a release stage from the environment variable, and after that use my script above and create a PowerShell Task or a Webservice plugged on VSTS. But it will only work if a release is triggered for each build, which is not always the case.
Do you know a (better) way to send this notifications with VSTS ?
And do I use the right tool for that sort of things ?
You can only send the email alert to "Environment owner" & "Release creator" and there isn't any way to customize the content in the email alert for now, you can submit a feature request on VSTS User Voice.
Rest API is a good tool to get these information. But you mentioned that you are using the same release definition for all branches. This does not make sense. Different branches refer to different version of your project, why do you deploy all of them in one release pipeline? If you configure your workflow to one release definition per branch, the resolution would be more easy. You just need to get the Build ID for previous release, and then get the changes after that build. And you can also add a powershell task to create a lable/tag for TFVC/Git repositories for current release version so that you can get the changes between the labels/tags.

how to send email notification to developer for build failure in Jenkins

I have a continuous integration setup and integrated selenium scripts in jenkins. In case of failure in build, mail notifications should be sent to the developer who commited the changes. I run selenium scripts in jenkins to verify the status of the build. The problem is that if there is any failure, email notifications are sent to the selenium script developer instead of the application developer. It assumes that build is getting failed due to the changes made in selenium script but the actual issue is with the application code.
Is there any way to send mail to application developers for build failure instead of selenium script developer ?
I would have preferred to write this response as comment rather than answer, but due to insufficient rep, am posting it anyways.
If you want to send email notifications to particular email address, check out Email-ext plugin. With this you can add post build action of Editable Email Notifications and control which email address you send notifications and when(if your job fails or success)
First of all, use email-ext plugin as mentioned above. Secondly, ensure you select 'upstream committers' option. As per its own description: "Sends email to the list of users who committed changes in upstream builds that triggered this build." If your application build triggers a selenium build, this is what you need.

Additional Workflow Data in Project Server Workflow empty

I am trying to build a Project Server workflow using SharePoint Designer 2013.
The workflow itself is working. It can create a task in the Project Server task list and approving it progresses the workflow.
However, if you click "Additional Workflow Data" the history is always empty. I have been able to create a custom event to log in the history via designer, but I am looking for the true history of the workflow. In 2010, the history would show it entering each stage and other logging data. My 2013 workflow history shows nothing.
I have verified the account has permissions to write to the list. I have checked the IIS logs to see the workflows are running. I have checked the project server permissions and groups for the workflow proxy account. I have ensured "Workflows can use app permissions" is activated for the PWA collection. I have also tried "Copy-SPActivitesToWorkflowService" cmd to see if it needed to installation needed to be repaired. I have restarted the workflows, republished, bounced the boxes, but still not workflow history!!
Does anyone know how to resolve this issue or have other suggestions on where to look?
You need to use an 'Action' within the Workflow called 'Log to History List' and enter what you want the log to say at the point where you have added the Action.
The sticking point comes from a differences in versions.
In Project Server 2010, the workflows showed default actions and processes. In 2013, you cannot see all the various behind-the-scenes actions.
Any actions which you want to be able to trace, for example, when the project entered the stage, must be added into the custom workflow manually.