4

I'm trying to make Jenkins pull TFS gated checkin code but failed to do so.

I have managed to add a Jenkins build step in TFS, This build step is a "trigger" to start a build job in Jenkins, This job taking the source code from TFS and compile it, the problem is that this code is without the gated checkin.

For example:

  1. My code base is "A" and compilation is working.
  2. I'm pushing new change (lets call it "B" delta) that should break the build (invalid c# syntax).
  3. This trigger a build in TFS which call Jenkins job, this job taking only "A" code (without "B" delta).
  4. Jenkins succsusfully building the code (base only on "A") which TFS then mark this build as succsusfully and let the bad "B" delta code inside.
  5. Now every change set including a fix to this one will cause the next build to break because jenkins will take the bad "B" code and always fail.

Is there a way to make Jenkins take the code with the current gated checkin?

The reason I want to use Jenkins build instead of TFS is that the build process for .Net Core 2.0 in Jenkins is about X4 faster then TFS, and our source control is managed in TFS.

Using: TFS - Version 15.117.26714.0

Aviram Fireberger
  • 3,910
  • 5
  • 50
  • 69

1 Answers1

1

To avoid this issue, you could add a VS Build task before queue Jenkins Job task:

enter image description here

Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39
  • What do you mean by saying "the latest change"? My job is taking the recent code in TFS but without the code that a just tried to push. I added the "example" section in the question to make my scenario more clear. – Aviram Fireberger Dec 19 '17 at 10:03
  • But this is the problem I want to avoid... :\ I don't want to make a "sln" build in TFS because it's super slow. take X4 time more then the build in Jenkins – Aviram Fireberger Dec 21 '17 at 07:18
  • @AviramFireberger You would need get the shelveset on Jenkins side, and build the project, then add a script task in TFS build definition to check the Jenkins build result. If the Jenkins build fails, TFS build fails too. – Cece Dong - MSFT Dec 21 '17 at 08:03
  • But thats the question is all about... "You would need get the shelveset on Jenkins side" Jenkins doesn't the the gatedcheck in changes \ shelvset and therefore you solution is not going to work.. :\ – Aviram Fireberger Dec 21 '17 at 08:33
  • Jenkins still get the latest changeset from TFS, you would add the shelveset to the build. If the build fails, TFS won't check in the shelveset, so the Jenkins won't get the bad code from TFS. – Cece Dong - MSFT Dec 21 '17 at 09:07
  • This workaround won't require build in TFS. Jenkins get the latest changeset from TFS, you add the shelveset on Jenkins side, and build the project. Then on TFS side, you add a script task in TFS build definition to check the Jenkins build result. If the Jenkins build fails, fails TFS build. Since TFS build fail, the shelveset won't be checked in to TFS, and Jenkins won't get it. – Cece Dong - MSFT Dec 21 '17 at 09:12
  • How can I "tell" Jenkins to take the gated check in... can you explain it in your answer please? – Aviram Fireberger Dec 21 '17 at 09:24
  • You could add command line to use `tf unshelve` command to restore shelved to the Jenkins workspace: https://learn.microsoft.com/en-us/vsts/tfvc/unshelve-command – Cece Dong - MSFT Dec 22 '17 at 03:31
  • I will look into it thanks, any way I can tell Jenkins to take the shelveset associate with the current build? Not sure relaying on the latest in good enough – Aviram Fireberger Dec 24 '17 at 07:21
  • I don't see such feature. You need to add a build step on Jenkins configuration to invoke a script to use `tf unshelve` command to restore shelved to the Jenkins workspace. In this way, the script will be run with the workspace as the current directory. – Cece Dong - MSFT Dec 25 '17 at 07:46
  • Is there an existing script that you can add a reference to? – Aviram Fireberger Dec 26 '17 at 08:57
  • Check this case: https://stackoverflow.com/questions/17588678/tfs-commands-in-powershell-script, which provide a sample how to use tf command in a script. – Cece Dong - MSFT Dec 27 '17 at 03:36