Trigger Build automatically in TFS 2018 [duplicate] - tfs

This question already has an answer here:
Trigger builds based on TFS workitem information
(1 answer)
Closed 3 years ago.
Is it possible to trigger a build definition (automatically) from a work item transition?
How can I achieve this in TFS 2018?

There is not any built-in trigger to handle this at present.
However, as a workaround, you could use web hook to trigger builds
when work item states are changes.
Prerequisites as below:
Build related to work item states.
Your own website to receive message from VSTS web hook and send request to build related builds.
Config a web hook in VSTS.
Detail steps as below:
Create builds related to work item states as Ready to build, Ready to deployment etc.
Configure a service hook:
In the team project -> Services Hooks -> Create subscription -> Web
Hooks -> Next -> select Work item updated as trigger on this type
of event -> filter Field as State -> Next -> input your website’s
URL -> Test -> make sure it can work successful -> Finish.
Develop your own website with below functions:
Check the current state of the work item updated. You can get a work item information by REST API, and the check the value for
System.State.
Trigger related build to queue. According to the value of System.State, queue different builds. Such as if System.State is
Ready to build, then queue the build for this state.
More details take a look at this similar question: Trigger builds based on TFS workitem information
Besides, you could also file a feature request in Develop Community site. Our PM will kindly review your suggestion

Related

Link a TFS Build Definition (CI) to a TFS Pull Request

I am reading the instructions from https://learn.microsoft.com/en-us/azure/devops/repos/git/pull-request-status?view=azure-devops#status-policy.
I have a TFS Build Definition which executes tests for every branch and reports success/failure.
I'd like to link the corresponding build to the Pull Request as well (and make require a green status to merge, if possible), similar to the screenshot below.
How can I do that, do I edit the repo Policies or in some other way? The link doesn't give much detail on how to do the actual linking.
Go to your repo -> branches -> select the branch that will be the target for your PullRequests -> Open the context menu left to the commit-id -> "Branch policies".
There you define your criteria for pull requests and can add a build under "Build validation".

Can TeamCity listen to tfs builds and trigger my automation tests

We are using team foundation server for checking in the code and building the project.
Now, we would like to add to TeamCity to trigger our automation suite as soon as a build is pushed to tfs.
Question:
Can TeamCity listen to TFS build information and call my automation scripts to execute? (I checked every where, it says teamcity performs build, I want tfs to perform a build and do post actions)
VSTS/TFS 2015 and later has the feature that integrating with your favorite services by notifying them when events happen in your project. It provides a way to send a JSON representation of an event to any service. More information: https://www.visualstudio.com/en-us/docs/integrate/get-started/service-hooks/services/webhooks
You need check on TeamCity side to see whether it can receive the JSON representation of an event from TFS.

TFS, Jenkins and how to update work items with build numbers

We are using TFS and the TFS Build Service. We are considering to migrate the Build service to Jenkins but we came across some issues. According to this site, there are some things that do not work very well with the TFS and Jenkins plugins. All of them we use a lot:
Associated Change sets – Team Build automatically associates a list of change sets that are included in the build
Associated Work Items – Team Build analysis the relationships and also associates Work Items with a build. Indeed it walks the work item tree (parent) and maintains that association in the chain.
Is this still true? We have this scenario:
A developer checks in a code that fix a bug or resolve a User Story. It does that by associating his check in with the work item ID.
His check in triggers a build that will associate the work item with his changeset. For bugs, the build will update the "Integrated in Build" field with the build number. We use this field to know in witch version the bug was fixed.
Is there any way to make Jenkins behave and do what TFS build service does?
Another option is to mix the two using dummy builds on the TFS side that set the records straight and kick-off the Jenkins' builds. Some hints
How to trigger Jenkins builds remotely and to pass parameters and “Fake” a TFS Build.
This approach requires a bit of effort but has many advantages:
No big-bang, use Jenkins opportunistically
Can continue using existing builds
Having a build identifier in TFS allows you an overall monitoring and to use the Test features
I have a VSTS build definition for one of our projects that requires jenkins to build, but we still have all our other products using VSTS natively. To maintain consistency, this build definition triggers a jenkins build. We configured the build definition to not sync code as jenkins will download it (save time) and not to publish the artifacts back to the agent (i have another script for that found here). This allows developers to continue to use git as normal, and the build/release process is consistent with our other products. Along with task tracking and such.

Test TFS Build Workflow Locally

I maintain our build process on our TFS 2012 system.
Up till now I've been making changes locally to a solution that generates our custom activity DLLs. These DLLs are checked into TFS and are used by the build controllers and agents for the custom activities in our custom build template.
For all of my code and workflow activities I have a unit test library that I can locally run to put in some base test values. While this gives me a good idea at how my custom tasks will run it is not optimal.
What I would like to be able to do is run the entire build definition. Is there a way to test the whole build process locally so that I can be sure that my changes to the workflow are acceptable before checking in and kicking off a build? Right now my builds take between 30 and 40 minutes to complete and I would like to be able to start, monitor, debug, and stop the build locally without occupying one of our agents.
Edit
Another method for me to solve this problem is to come up with some manner to execute the workflow that is the build template locally. Has anyone been able to do this?
Take a look at the Ranger Build Customization Guidance. There is a HOL for doing a lot of this. It doesn't look like it is in v2 so take a look at v1.2.
http://vsarbuildguide.codeplex.com/releases/view/87995
If I am understanding the issue correctly, one way to do this may be:
Install a build agent locally and register it with the TFS Build Controller.
Give the new agent a custom tag so it doesn't get assigned other builds from the queue
Shelve your changeset
In VS, right click the build definition you want, and select queue new build. A "Queue Build" window will open
Under the general tab, "What do you want to build", select your shelveset.
Under Parameters tab ->Advanced -> agent settings, enter your agent's tag.
Click queue.
I accomplish this using a modified version of #malexander recommendation.
Create a code branch in TFS, commit your changes there, especially the changes to your custom activity DLL's (compiled binaries, not just source).
Install a TFS Build Controller and Build Agent locally, registering the controller with your TFS server.
Configure your new local controller to use your modified custom activity DLL's, stored in your new TFS code branch. Team Explorer > Builds > Actions > Manage Build Controllers >
(select your new local controller) > Properties > Version control
path to custom assemblies
4.
Queue a new build, from an existing TFS build definition: change its controller to use your new local controller.
The new build will execute on your local controller/agent, using your modified custom activity DLL's, without interfering/restarting your production agents.
Also: since you're in your own code branch, you can commit debug versions of your custom activity DLL's, without impacting your production agents.

TFS2010: Disable email alert for private builds

We are taking on new developers and encouraging them to use TFS2010's private builds feature - a build is done using a shelveset, so you can see what impact changes will have.
We have TFS set to email the dev team, and that's what's causing the problem: TFS emails the whole team with the result of the private build, which causes confusion over the current state of the 'public' build when a private build fails.
The only difference in the email is that private builds don't label the sources, so the subject line is Scrum Build 8518 failed rather than Scrum Build CI Build_20111007.5 succeeded. While this is enough to be able to distinguish the two once you're used to it, it's confusing at first.
Is it possible to disable the email alert for private builds? Alternatively, is it possible to change the subject line if the build is private to something more explicit?
I've looked at the JobStatusAgent config and the email templates, but I can't see anything there that will help. We are using the default template, if that's relevant.
Definitely recommend the Alerts Explorer as suggested by #Edward. You don't need the whole team to install the Power Tools, just a couple of team members to manage Project level Alerts should suffice.
With the Alerts Explorer, you can then set up the alert to filter for the Requested By or Requested For fields. In case of Continuous Integration builds, the Requested For field contains the user whose check-in triggered the build. The Requested By field contains the user who requested the build. In case of CI or scheduled builds, this will be the Build Agent service account. Unfortunately, this doesn't really help if you have public builds that are manually requested.
Are you configuring your alerts with the Alerts Explorer power tool? It's much more powerful than the out-of-the-box alerts functionality.
You can configure more fine-grained configuration on the alerts - for example, Title contains " CI ", build number string matching, or based on the person requesting the builds.
Please have a look here, where I 've discribe a method to insert a new build argument named "BuildType" into your Build Process Template.
Using this additional parameter we control the sending (or not) of an email to the QA-team.

Resources