Jenkins requires TFS EULA acceptance - tfs

I created a build job on Jenkins that is attached to a TFS server. I used Team Explorer Everywhere to facilitate this. The first time I ran the job, I got the following message:
Error: You must accept the End User License Agreement for this product.
Which is fine, I ran the tf eula command and accepted the EULA.
The problem is that I'm still getting the same error when running the job.

Here is the solution that I used to resolve the issue:
Set the Source Code Management to None
Add build step and choose Execute Windows batch command
type tf eula -accept in the command window
Run the build
Remove the above build step
Set Source Code Management back to Team Foundation Server and enter the details
Run the build again and it ran without error
Hope it helps

To date we've had to perform this a couple times now, and so we've created a project which performs the acceptance of the EULA.
In the Build section of this new project, we have an Execute Windows batch command step which is as follows:
"C:\Team Explorer Everywhere for Team Foundation Server\TEE-CLC-11.0.0.1306\TEE-CLC-11.0.0\tf.cmd" eula -accept
Obviously you might need to change your path accordingly.
Now when we encounter this problem, we 'build' that project and it accepts the EULA for us.

I had the same issue on Jenkins/TFS server.
I used:
tf eula -accept

On mac make sure when you add the full path and choose Execute shell script
not just
tf eula -accept
I created a simple seperate build with only one Build task
Execute shell
/Applications/TEE_CLC_14_0_1/tf eula -accept
Ran it
Then ran my larger build

Related

Is there a way to generate an Intellitrace file from a TFS Build?

I currently have an on-premises TFS 2017, a TFS build and a test that fails on the build agent but not when running locally. I heard about historical debugging but I couldn't find instructions on how to enable it on a TFS build, if that's even possible.
Is it possible to configure my build so that it generates an intellitrace file for me to debug the test run afterwards?
For intellitrace which related to the old testsettings file and could add some variables to configure this.
You could also manually enable such option in the VS on your build agent.
Also find a link mentioned it seems also work with Msbuild arguments. Even not documented anywhere in Msbuild command doc. I wonder whether IntelliTrace is still running even though it's not explicitly specified to do so
However, looks like you just want to find the root cause why your tests failed on tfs build even it passed locally.
To narrow down the issue, suggest you directly remote to your build agent. Instead of through TFS build, manually build your project, run the tests in the Visual Studio on build agent.
It will come out whether it's an environment issue. You must make sure it's the same environment for build agent and your local.
TFS is just using build service account to invoke msbuild/vstest command in build agent to run build/test.
Also make sure build service account have appropriately permission if your tests required some permission.

Set up Team Foundation Server Build service to do automatic builds and testing

Our plan is to use Team Foundation Build service to do automatic builds, then use the testing facility to automatically perform testing on the build server then release that build onto the application server.
So far we have
Team Foundation Server with TF Build Controller configured
Build server with win2012, Visual Studio 2013 and Build agent configured.
SQL Server with SQL 2013 installed
Application Server with Win2012 and .netframework installed
My question is what do I need to do to set up automatic builds, and to execute the unit test harness once compilation is successful.
Also the deployment target machine will initially be DEV, however we would like to quickly build for test env and prod etc.
This is what I got so far.
Build Controller (Already set up I believe)
Build Agent (Already installed on build server)
Build Process Template (Do I need to do anything with this. Is this what controls the whole lot)
Team Build Definition (I had a look at this, and it seems to use the build process template)
Drop Folder (I am assuming this is where the executables will be dropped into).
At the moment I have bits and pieces of info, what I would like to know is how this whole thing is hanging together. From the moment the developer wants to do the build to the moment that exe is placed into the DEVAPPSERV (Development application server).
Is anyone able to point me in the right direction or give a summary of what I need to make this happen?
Many thanks,
Dalibor
Install TFS Server (TFS Disk) Create a Team Project Collection and any desired Projects
Install TFS Controller + Agents onto a dedicated machine (TFS Disk) Configure only the build options if on a different machine to the TFS Server
Configure Build Controller to connect to a Specific Team Collection on your TFS Server
Install VS Premium or higher on build machine, if you want code coverage results for your tests
Add some code to TFS Source Control
Create a Build Definition using the default template.
Configure the build definition.
Set the working folder for the build, include only what you need as this will speed up the process
Point the definition to your .sln or proj file.
Ensure testing is enabled and that your test assembly names will match the regex used to identify test dll's i.e. name your test assemblies with the word test.
Set the trigger to be CI or what ever flavour of build you require i.e. gated build
Save the build definition
Trigger a manual build and debug any issues
you should have the basics done and a repeatable build created.
That should cover the basics, you may want to customise the build template (see Ewald Hoffman's guide for tips), you may want to narrow down your code coverage (look for runsettings file info).
If you follow these steps you should be able to get a basic build created and running from these, if you hit any issues you can come back and ask specific questions about a particular area
In order to do automatic builds you should check the CI build option ( under the trigger build option ) and third party automated testing can be run by executed by a post build script.
See the following TFS article about post build scripts.
http://msdn.microsoft.com/en-us/library/dn376353.aspx

How to re-run automated tests triggered by TFS Team Build without re-running the entire build?

We're using TFS Build and are having the TFS Build process run tests through a Test Controller on a Test Agent on a remote machine. We do this via a testsettings file in which we specify the test controller. This testsetting file is specified as an argument in the default TFS 2012 Build process template.
Everything works fine. However, our build takes about an hour. In the event that a test should fail because of an environmental issue (so in the event where it fails only on the test agent and not on our Dev machines), I'd like to be able to re-run the tests and diagnose the environmental issue that happened. However I can't seem to figure out how to do that WITHOUT re-running the entire build. Once the environmental problem is fixed, I'd like to be able to re-run the tests again to make sure everything is ok. I'd like to do all this without re-running the entire build. Ideally when I re-run my tests they should run in as similar a configuration as possible as to when TFS Build runs the tests.
Is there a way to do this? Is using MSTest command line an option to re-run the tests? If so, how do I know which arguments to pass to it? Ideally i'd want the same arguments TFS passed to the QTAgent process which ran the tests?
Create build specific, based on sequential workflow specific whose you delete from designer WWF all activities that don't need.
I suggest theses steps : 1. Select link 'Create Build Definition' 2.Create Process Template by copy pasting on Source Control, 3.Open your copied Workflow on designer 4.Delete all activities that you don't need. 5.Finish by associating this workflow to build definition (Select Process Tab)
The easiest way to prevent the whole build from running is to set "Clean Workspace" to None.
That means if you want to re-run the tests you can just queue the existing build definition manually, change to the Parameters tab and set Clean Workspace to None before click the "Queue" button.
In this case existing build outputs remain as well as source code files that have not changed since the most recent build (by performing a tf get without the /all switch).
It's probably not exactly what you want because if there were some check-ins since the most recent build the changed source files will be fetched and built.
But if it is not important for you to re-run the tests using exactly the same build output each time it could be a good solution for you since it usually reduces build time significantly.
One way for you to possibly do this is:
Open the build that had failed tests in Visual Studio
Scroll down to the test runs section.
Click on the failed test run. The Test Results window should open.
Select the failed tests you want to rerun.
click the "Run checked tests" button
Supposedly this should work: vstest to tfs logger. I can verify that the test are run and published to our tfs, but I could not see the test result on the tfs build page only using the link that is produced (the one with mtm as protocol)

Execute sonar-runner in TFS build

How do I make the command to run sonar-runner at the end of the build TFS (Team Foundation Server) in continuous integration?
Info: TFS 2013, Windows Server 2008 R2, sonar-runner 2.3
The only way to execute arbitrary commands as part of the build process is to add an InvokeProcess activity to the BuildProcessTemplate. This isn't as difficult as it may seem at first.
Make a copy of the DefaultTemplate.xaml which is located in the /BuildProcessTemplates folder of your team project. Name it whatever you want - SonarRunnerTemplate.xaml or something.
Open up the new template in Visual Studio
Hit "Collapse All" at the top right to ease navigation to the proper activity.
Browse to Process > Sequence > Run On Agent > Try Compule, Test, and Associate Changesets and Work Items > in the Finally clause > Revert Workspace and Copy Files > If DropBuild And DropLocation is Set
In the "Then" box you will see a Copy Files to Drop Location activity. Move this into the "Else" box temporarily.
Add a Sequence activity from the Toolbox into the (now empty) Then box
Move the Copy Files to Drop Location (which we moved earlier) back into the Sequence activity you just added to the Then box.
Add a InvokeProcess activity from the Toolbox to run AFTER the "Copy Files to Drop Location" activity
Open the Properties for the InvokeProcess activity. The FileName field is the command which you need to execute. In this case, the command to execute your Sonar runner. It might be easiest to write a batch or powershell script which runs Sonar... and then invoke that.
Save the build process template and add it to TFS. You can then use this template for your build definition.
One issue with this approach is that the build will not "finish" until after the InvokeProcess command has returned. So if your sonar run takes a really long time (I know I have seen it take over 24 hours for a large codebase) the build will take forever to complete. This can be mitigated by having your script spawn off the Sonar process asynchronously.
There is now an official way to get MsBuild and TeamBuild to work with SonarQube, as part of a collaboration between Microsoft and SonarQube. You can find all the details on the SonarQube website:
http://www.sonarqube.org/announcing-sonarqube-integration-with-msbuild-and-team-build/
And on the Microsoft ALM website:
http://blogs.msdn.com/b/visualstudioalm/archive/2015/04/28/technical-debt-management-announcing-sonarqube-integration-with-msbuild-and-team-build.aspx
There is also documentation prepared by the ALM rangers that describe how to install SonarQube and integrate it with an existing TFS server:
https://vsarguidance.codeplex.com/downloads/get/1452516

TFS Check-in Policy - Force a shell command to have been run

On the project that I'm currently working I have a requirement to run a shell command over some static files prior to check-in into TFS.
Is it possible to use TFS checkin policies to force a developer to run a shell script prior to check-in?
Check-in Policies are designed for this purpose: to check for something in order to "authorize" the check-in.
You'll find an interesting video here about how to develop one. You'll see that it's really easy and once you did your first you will want to customize more TFS.
In you case you will have two options (IMHO):
Run the shell command in the Evaluate method of the check-in policy.
Make the check if the user manually ran the shell command in the Evaluate method.
The first should be the best but it bothers me a bit because it's not the true purpose of the check-in policies to perform a task upfront, but I can't think about why it shouldn't work. And maybe you'll have to go that way it the second solution is not possible.
In the end we didn't need to use a Checkin policy.
Instead we turned the resolution on its head as I found that running tf.exe checkin from a command prompt, without any further arguments, causes the TFS checkin dialog to popup.
This means that we can add an additional step at the end of our shell script that runs:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\tf.exe checkin

Resources