0
votes

I am trying to set up a new work flow. We are using TFS 2015 on premise backed by Git SCM. However, I would also like to use Jenkins for builds and deployments. We are building .NET/mono Java & Java for android, nodejs and a couple of other bits. Also, auto deploying to docker from Jenkins. So although the new TFS builds look better, I don't want to try them right now.

My issues is around TFS pull requests and code reviews. Developers can't submit to master, I have the branch policies set so they have to submit a pull request which involves pushing a branch to the remote. However, I can't set the "required build" policy as although I have linked up Jenkins, it only allows me to select TFS builds as part of the branch policy.

So I have linked Jenkins to TFS using the service hooks feature, and I can start TFS builds that way, but I don't think it helps me, as it has to monitor a specific branch. So instead I am just polling git from Jenkins and building against all branches in the repo except master.

What I would like to do is have a developer push their branch to the remote, have Jenkins build it (I have got this far), and then somehow publish the build report or a link to it back to TFS, so when other developers come to do the code review using the TFS UI, then can go and view the build report. (this is the bit where I am stuck)

Once that is done, and the merge is performed, the other builds to perform deployments etc can run against the master branch. Its just this link back to TFS I am struggling with, has anyone else got an answer

Has anyone got a solution to this? I tried adding the url to the build results to the git notes using the git publish plugin, but TFS doesn't seem to display that anywhere. I have considered setting up a TFS build to simply call the Jenkins job, but it feels a bit hacky. Is there a better way?

2

2 Answers

0
votes

I resolved this in the end. What I have done is have Jenkins add another commit to the pull request, with the comment in the commit being a link to the Jenkins build report. I also had to modify the Jenkins job to ignore commits by the Jenkins user to prevent an infinite loop of builds.

Now when a pull request is submitted, Jenkins picks that up, builds it and creates the extra commit. As a reviewer, I receive an email alerting me there has been a pull request. I click on the link to go and have a look, and when I go to commits I see the link to the Jenkins build report.

It's not perfect, but it works. It's certainly a better solution than giving up because TFS doesn't have that feature.

-1
votes

According to your description, you want to trigger Jenkins from TFS, and publish the Jenkins build result back to TFS.

As service hooks enable you to perform tasks on other services when events happen in your tfs projects. But TFS only provides build report for the build with build definition. On TFS side, there is not such feature that publish the Jenkins build result back to TFS.