Script to send email notification in Teamcity - scripting

I have a requirement to send email to particular group when Teamcity's build goes green and red.
Does anyone has any idea about it ?

It is possible to configure user group and setup email notifications for this group inside TeamCity.

There are a few TeamCity plugins that you can leverage out of the box but the buildstatusnotifier
looks the most promising. You can also setup a job that gets triggerred upon completion of every build for the project you are tracking. This build will do the following:
Make a call for last status of the build project. See TeamCity REST documentation here for context. Replace "insert-base-url-here" with your teamcity base url & "btXXX" with your build id.
http://{insert-base-url-here}/app/rest/builds/buildType:(id:btXXX)/statusIcon
Save the result of this call in a DB or in a txt file
For every subsequent call, check to see if the new value is the same as the previous; if they are do not send an email. If the values do not match then proceed to step four
Send an email to the recipient/distribution list informing them of a change of status in the build status.
My personal preference will be to do all of these in an nant script but those are the steps to take.
You can also look at the Build-status tool (build-status.appspot.com) which can be setup and displayed in a highly visible place that your team will not miss should it turn red.

Related

"How to get test run id from a specific release using TFS 2018 API"

We have a task in our release pipeline that runs Seleniumtests(Visual studio test task). The selenium tests run and we can after the run add an attachment to the testrun manually. We also manage to add an attachment with the api but we don't have a good way to extract the testrunid that is necessary for the upload.
How do we in a good way get the test run id from a release so we can bind the attachment to the right testrun. We only manage to get all test runs with the api, which is alot.
Where we want the attachment to be uploaded with the api
You can see test run id from the test log for a specific release.
So, the simplest way is getting the specific test run id with the REST API from the log.
GET https://{instance}/{project}/_apis/release/releases/{releaseId}/environments/{environmentId}/deployPhases/{releaseDeployPhaseId}/tasks/{taskId}/logs?api-version={version}
See Get task log for details.
EDIT Get Task Log v5
I am using the following API to get test results for the release,
GET https://{instance}/{project}/_apis/ResultDetailsByRelease?releaseId={RELEASE.RELEASEID}&releaseEnvId={RELEASE.ENVIRONMENTURID}
The test results included testRun ID or get failed tests only by using filter,
GET https://{instance}/{project}/_apis/ResultDetailsByRelease?releaseId={RELEASE.RELEASEID}&releaseEnvId=RELEASE.ENVIRONMENTURID}&%24filter=Outcome+eq+Failed

TeamCity filter builds by tags or time period

Is it possible, through the rest API, to request all the builds with a specific tag? Along the same lines, can I get all the builds from a specific time period? For example, request the builds from 7 am to 7 pm of a specific date?
Background, I am trying to automatically pin builds based on a parameter. I had a custom script that used the rest api to pin builds and I used this script in a command line build step. The problem is, TeamCity won't allow you to pin a build that is in progress. So to get around this I am trying to do the following: I have a build step that uses a custom script to tag a build, then the idea is that I will have a script that I will run every night or so that grabs all the tagged builds, or builds from a specific time period and pin them.
Any other ideas are welcome as well.
Please do a request to:
https://{yourdomain}/app/rest/builds?locator=tag:your-tag
That's it.
From the rest API documentation: https://confluence.jetbrains.com/display/TCD10/REST+API#RESTAPI-BuildRequests
you can use the ?locator=tag:<tagName> tag to get all the builds with a specific tag name.

TFS Link testresult to Task

I have the next structure:
Bug
Dev task
Test Result with the failed test case
Tested by
For retest the bug I have created a RETEST task and link it to the bug. When I rerun the testcase I would like to add the passed test result to the RETEST task. How can I do? Or what is the best workflow?
You don't need to create a retest task for this case.
You could directly customize a workflow using States and Reasons for the Bug work item. Such as adding a state "Ready to Retest" for a Bug. And then assign this work item to the tester or tester group. Suggest you to use the Process Editor, available with the download of TFS Power Tools. The Process Template Editor provides a graphical user interface for customizing work items (field, workflow and the form) and process templates.
More ways for customize the workflow for a process please refer the tutorial from MSDN:
Customize the workflow for a process
Add or modify a work item type
Then you just need to directly link test result to the bug workitem. And in a Bug work item, you can click the HISTORY--ALL CAHNGES to track the history and process.

MSBuild email alert to list failed tests

I'm using TFS, MSBuild and MSTest for automated build and test solution. When some unit tests fail; build partially succeeds and I get email just giving the error information.
Is there any way that I can customize the e-mail content? I want the failed test names and fail reason listed in the mail. Even the test result file as an attachment(1 MB) would do.
Thanks
There is a Jenkins plugin called "Email-ext plugin" link maybe that could help you. However, (I assume) you might need some kind of your own custom template to do what you want.
Example
You can attach a HTML page to your email, likewise you can customize as you want:
stackoverflow question

Asana API for Projects Assigned to Me

For Tasks assigned to me, I see how I can do
curl -u <api_key>: "https://app.asana.com/api/1.0/tasks?workspace=14916&assignee=me"
I am trying to make a quick page that breaks down my current tasks and links to Asana for me, so I can have my own quick dashboard.
I have my API Key
It lists all Workspaces I am a part of.
If I click a Workspace it shows all Projects inside of that space
If I click a Project I want to see only the Tasks that have been assigned to me inside of that Project.
If I add the Project ID to that above call, it sends me back every item in the Project, not just those assigned to me.
If I leave the Project ID out, it returns all tasks assigned to me, even those outside of the project.
Did I miss something?
Thanks for any help!
Note: I would add the Asana tag, but it doesn't appear to exist yet.
It seems that in the current version of the API the assignee parameter is ignored when specified for projects. Regardless of what I put below, I get the same result: all tasks.
curl -u <api-key>: "https://app.asana.com/api/1.0/projects/<pid>/tasks?assignee=here-it-can-be-anything"
I'm having trouble with this too - it seems you can't expand projects when querying tasks - and you can't get tasks by project... The former is actually preferred since you could provide a task list by project if you could expand on project.
As it is, you can get a list of tasks, then loop through and get the full task by task-id, but that takes a while...