TFS Build 2015, Gihub Enterprise and Pull Requests - github

I'm trying to get TFS Build server 2015 to do continuous integration building for pull requests on our github enterprise server. I was able to get the triggers working and it was building all of the normal branches (/refs/heads/), but I can't figure out how to get it to build new and updated pull requests. In the triggers I've tried pull/, pull//head, origin/pr/, origin/pr//head, refs/pull/, refs/pull/*/head and just a plain *. * is what allowed it to build all branches.
This was pretty easy to do with our Team City build servers, but I can't figure this piece out. Does anybody have any ideas?
Thanks

In TFS 2015, you can only select External Git repo for GitHub repo, and can only specify the branches where you want to trigger builds. No option to specify pull request.

Related

Transfering the data from TFS to GitHUb

Our client is using TFS, and we are using GitHub
I would like to sync the projects from TFS to Github and from GItHub to TFS as batch process whenever the changes are made in either of them.
Can someone suggest easiest way of doing the same?
Thanks in advance
git-tfs which is a two-way bridge between TFS (Team Foundation Server) and git. However if you are using TFS2013 and later, you could use Git as the source control option. You could directly use normal git command such as git pull, git push.
For the command to the get from github, just use the normal git command such as: git-scm.com/docs/git-pull –
In Azure Devops or Github, both of them use git as their Version Control, so you can have both as separate git remotes.
You could just use some git commands to handle this. Which command please take a look at this blog.
For automated process, then you could use one CI build definition to achieve it. Detail steps as below:
Create a CI build with a PowerShell or cmd Task;
Select the VSTS git repo in Get sources step;
Enable continuous integration andspecify include all branches for
Branch filters:
Two samples for your reference:
How to synchronize VSTS and Github respositories when commits are made
Syncing my Github repo to MS Visual Studio Team Services
Besides, you could also use some 3-rd party extension to handle this, such as this one--Git Tools for Azure DevOps
Azure Pipelines Build and Release extension that helps you synchronise one Git Repository with another.
You can use this extension with any Git repository: TFS, GitHub, Azure DevOps, Git, etc.

Trigger GIT build in Visual Studio Team Services (was Visual Studio Online) via API for specific commit

I'm looking at building some integration between Github and Team Services builds so that I can get a Team Services build running when a Github pull request is created or updated; this isn't supported directly right now that I can tell.
However, looking at the documentation for the REST API for Team Services build, it says I need to pass in the name of the branch to build in the body.
Pull requests don't have a branch. I do have a commit ID though. Can I pass the SHA-1 for the commit as the branch name? Or is there some other way to tell it to go to a specific commit?
You can specify the pull request as the source branch via this format:
refs/pull/pullrequestid/head

Run CI build on pull request merge in TeamCity

I have a CI build that is setup in TeamCity that will trigger when a pull request is made in BitBucket (git). It currently builds against the source branch of the pull request but it would be more meaningful if it could build the merged pull request.
My research has left me with the following possible solutions:
Script run as part of build - rather not do it this way if possible
Server/agent plugin - not found enough documentation to figure out if this is possible
Has anyone done this before in TeamCity or have suggestions on how I can achieve it?
Update: (based on John Hoerr answer)
Alternate solution - forget about TeamCity doing the merge, use BitBucket web hooks to create a merged branch like github does and follow John Hoerr's answer.
Add a Branch Specification refs/pull-requests/*/merge to the project's VCS Root. This will cause TeamCity to monitor merged output of pull requests for the default branch.
It sounds to me like the functionality you're looking for is provided via the 'Remote Run' feature of TeamCity. This is basically a personal build with the merged sources and the target merge branch.
https://confluence.jetbrains.com/display/TCD8/Branch+Remote+Run+Trigger
"These branches are regular version control branches and TeamCity does not manage them (i.e. if you no longer need the branch you would need to delete the branch using regular version control means).
By default TeamCity triggers a personal build for the user detected in the last commit of the branch. You might also specify TeamCity user in the name of the branch. To do that use a placeholder TEAMCITY_USERNAME in the pattern and your TeamCity username in the name of the branch, for example pattern remote-run/TEAMCITY_USERNAME/* will match a branch remote-run/joe/my_feature and start a personal build for the TeamCity user joe (if such user exists)."
Then setup a custom "Pull Request Created" Webhook in Bitbucket.
https://confluence.atlassian.com/display/BITBUCKET/Tutorial%3A+Create+and+Trigger+a+Webhook
So for your particular use case with BitBucket integration, you could utilize the WebHook you create, and then have a shell / bash script (depending on your TeamCity Server OS) that runs the remote run git commands automatically, which will in turn automatically trigger the TeamCity Remote Run CI build on your server. You'll then be able to go to the TeamCity UI, +HEAD:remote-run/my_feature branch, and view the Remote Run results on a per-feature basis, and be confident in the build results of the code you merge to your main line of code.
Seems that BitBucket/Stash creates branches for pull requests under:
refs/pull-requests//from
You should be able to setup a remote run for that location, either by the Teamcity run-from-branch feature, or by a http post receive hook in BitBucket/Stash.
You can also use this plugin : https://github.com/ArcBees/teamcity-plugins/wiki/Configuring-Bitbucket-Pull-Requests-Plugin
(Full disclosure : I'm the main contributor :P, and I use it every day)

How do you build from a specific TFS 2008 Changeset in Jenkins?

I am attempting to create a manual build in Jenkins that will build a specific changeset of code from TFS for a deployment into a testing / production environment.
Currently I am only able to use TFS in Jenkins to pull everything up to the newest Changeset out of TFS.
I am running Jenkins version 1.471 with the TFS plugin version 1.20
Has anyone run into the problem, and do you know how to fix it?
Thanks in advance.
This feature is missing, but seems to be under way according to the comments of this Jira issue:
TFS Support to get labels
So, not specific changesets, but for me labels would be good enough as they can be applied at any time.

Is it possible to implement pre-tested commits in TFS?

I'm intrigued by the idea in TeamCity of pre-testing commits (i.e. verifying they don't break the build before allowing check-in to occur) and I'm wondering if there is any way to implement this in TFS. It looks like TeamCity can interface to TFS version control as a backing store but of course I'd prefer a free solution.
In TFS there is the notion of check-in policies where you can execute code on the client and that can validate check-ins before allowing them to occur. However - what you are after sounds more like the notion of a "Gated Check-in" where a build is attempted on a central build server before the check-in is committed to the main code base. Take a look at the BuddyBuild project on CodePlex to add that functionality in the current versions of TFS.
In TFS 2010, gated check-in builds will be a feature out of the box.