How to trigger jenkins build when changes are commited to TFS? - jenkins

I have a maven project in Jenkins (which is a selenium- java project), web-Developers use TFS , I want to execute my selenium tests as soon as developers push their code change to TFS.

If you are using Visual Studio Team Services, then you can store your code in Visual Studio Team Services and continue to use Jenkins for your continuous integration builds. You can trigger a Jenkins build when you push code to your team project's Git repository or when you check code in to Team Foundation version control:
If you haven't already, set up a Jenkins server. If you're setting up Jenkins on-premises, enable HTTPS.
In Jenkins, create a new item. Create the type of build that's appropriate for your project.
Set the URL for your Git repository in Visual Studio Team Services. The URL is in the form https://{VSTS account}.visualstudio.com/DefaultCollection/_git/{team project}.
If you haven't already, enable alternate credentials in your Visual Studio Team Services profile. Be sure to set a secondary user name because you won't be able to use your email account to connect Visual Studio Team Services to Jenkins.
Go to your team project's administration page. On the Service Hooks tab, create a subscription. Add Jenkins.
Pick the event from Visual Studio Team Services that you want to trigger a Jenkins build.
Configure the action to take in Jenkins. Now, when that event occurs in Visual Studio Team Services, your Jenkins build will be triggered.
Check:https://www.visualstudio.com/en-us/get-started/integrate/service-hooks/jenkins-and-vso-vs

Related

Visual Studio Online - Error TFS 22501 with XAML Build Definition 2

Currently, we are using TFS 2012 and we have a heavily customized build process as described below.
1. Build the source
2. Run an EXE as console to host WCF services
3. Restore databases on local sql server
4. Run functional test
5. delete databases
6. close the exe started in step 2.
7. Create an Installable exe using WiX ( Wix with custom bootstratpper)
8. Update version number file to TFS
Now we want to move to Visual Studio online from onpremise. Trying to setup a build process with Private Build agent. I have created an VM , installed and registerd agent. I do see agent name back in website.
When I go back to Visual studio and try to create new xaml build definition I am getting below error.
TFS22501: Creating a build definition requires a build controller be defined for this team project collection. There may not be any controllers configured or you may not have permissions to view them. contact your team foundation server administrator.
can somebody please help ?
If you're using XAML build, you have to use the old-style XAML build controller/agent. The VSTS agent is for the new build system.
I would strongly recommend migrating your builds to the new build system as part of your migration to VS Team Services, as the XAML build system is effectively dead.

How to get the TFS build repository url?

I am new to TFS. However, I have created a new TFS Account in Visual Studio and under visual studio 2013, I have created a new team project checked in. However, when I am trying to create a new job in jenkins, I am not able to file the Url for the repository of my solution that I have build. My code is under the url:
https://himanshuaccount.visualstudio.com/Himanshu_Workspace/_versionControl?path=%24%2FHimanshu_Workspace%2FTFS%20Information%2FTFSApplication1&version=T&_a=contents
The repository url is not being taken by jenkins. Any idea where I can find my TFS repository url in Visual Studio 2013 or under Microsoft Account?
Enable alternate credentials in your Visual Studio Team Services profile. Be sure to set a secondary user name because you won't be able to use your email account to connect Visual Studio Team Services to Jenkins.
Go to your team project's administration page. On the Service Hooks tab, create a subscription and add Jenkins.
Pick the event from Visual Studio Team Services that you want to trigger a Jenkins build. Configure the action to take in Jenkins.
In Jenkins, create a new item. Create the type of build that's appropriate for your project.
Set the URL for your TFVC repository in Visual Studio Team Services. Details: https://github.com/jenkinsci/tfs-plugin

How do I install prerequisites for TeamCity to connect to Team Foundation Server Version Control?

I've installed the prerequisite (Team Explorer 2013) to the best of my knowledge, but when I try to set up a VCS root to connect to our TFS Version Control server, I continue to get this error message:
"No TFS assemblies were found on the system. Please make sure you have
Microsoft Team Explorer installed. Supported versions: 2015 2013 2012
2010 2008 2005"
The Team Explorer I downloaded from Microsoft just seemed to be a plugin for Visual Studio, which doesn't make much sense as a server-side component. Anyway, I configured a connection to our TFS box within Team Explorer/Visual Studio on my TeamCity server.
So I have two questions that seem to be undocumented by JetBrains:
What does it mean to set up and configure Team Explorer? How can I validate that I have set up and configured Team Explorer on my TeamCity server correctly?
How does TeamCity know how to find the Team Explorer assemblies? Is there some sort of configuration I am supposed to do? Where is this documented?
I guess I'm looking for a true step-by-step set of instructions that make no assumptions about my understanding of TFS or Team Explorer, or any assumptions about what I may have already installed on my TeamCity box.
I've read the two articles on the JetBrains site regarding how to set this up, and they don't cover actually installing and configuring the prerequisites or configuring TeamCity to discover the Team Explorer assemblies it needs.
Team Explorer is the client software that you use to access Visual Studio Team Foundation Server functionality from Visual Studio. You can simply launch Team Explorer on your TeamCity server to create a team project and check in a project, to validate whether it is installed correctly.
I couldn't find any documentation that mentioned how does TeamCity find Team Explorer assemblies. But, based on my understanding, there is no configuration needed to detect Team Explorer. Please make sure your TeamCity server is running under Windows.
If the issue that can't find Team Explorer persists, you can install VS Premium instead of Team Explorer.
Setting up Jetbrains TeamCity for CI with Team Foundation Server:
Install Jetbrains TeamCity
If you are planning on using IIS or TFS on the same server, configure Jetbrains TeamCity to run on a port other than 80 or 8080
Once TeamCity is up and running, you can begin configuring your TeamCity installation for CI Builds.
Log into TeamCity with your user name and password
Create a new TeamCity Project
Create a new build configuration
You will now see a series of build configuration settings that you will have to complete presented in a Wizard-style navigation view.
Enter General Settings
Enter VCS Settings
After entering VCS Settings, Create and attach new VCS Root
Enter the relevant information for your TFS instance
Create a Build Step using Visual Studio as your build runner. You can create as many build steps as you need and specify the order of the steps (similar to a TFS Build Workflow).
For setting up Continuous Integration builds, you will need to specify a Build Trigger. CI Builds will generally use a VCS Trigger that is triggered on each source control check-in.
If you need to pass any parameters to your build, you can configure these in your Build Parameters.
That is all! You can then either run your Builds manually by clicking on the Run button in TeamCity or simply verify that your builds are triggered by the next check-in into TFS.

How to add a (TFS 2008) build agent to a TFS 2013 build controller that is also a build agent?

We're working on migrating our build solution from TFS 2008 to TFS 2013. As a part of that process, I am trying to add a clone of (one of) the current build agents (based on TFS 2008 and Visual Studio 2010) to the new TFS 2013 build controller, to make sure that we have the ability to run builds with the same environment that we do now. (This capability will be needed for some time e.g. for minor updates, hotfixes etc.) The clone has been created, started, and given a separate DNS name on the network, to allow it to be addressed.
Currently, our new environment has a TFS server, as well as a build server that hosts both the build controller and one build agent; all TFS 2013. (I'd rather see that the build controller at least ran on the TFS server VM, or ideally on a completely separate VM, but this is what it's like right now.)
When I log in to the new build controller/agent and run the Team Foundation Server Administration Console, then go into Build Configuration under that host's root node, it shows the build controller as well as the build agent (both with the same name because they are running on the same VM).
When I click "New Agent...", I expect to be able to add a new build agent (that's what the link says, after all). This is also what Microsoft indicates you should do in their documentation. However, what happens is that I get a window titled "Build Agent Properties" that appears to show the details for the existing build agent configuration. Specifically, it pre-populates the "Computer Name" field with the name of the existing build agent and has selected the existing (TFS 2013) build controller. The "Build Agent service is enabled" checkbox is checked, but the box immediately underneath that checkbox says "Build Agent status is Offline". In the main administration console window, both the controller and agent show as "Ready", and they have executed builds previously. I also cannot edit the "Computer Name" field.
So, to recap:
When the TFS 2013 build controller is also a TFS 2013 build agent, how do I add a second (TFS 2008-based, in my case) build agent to the build controller?
I imagine I'm missing something really trivial, but I just cannot see what, and Googling has turned up seemingly nothing of relevance.
Click "New Agent...", change the 'display name', click ok and you'll get a new (2013) build agent.
You're going to have to upgrade your existing 2008 build agent. IIRC 2010 build agents only connect to 2012 controllers if they're patched with sp1 so you've got no chance with 2008.

Running MSBuild script from TeamCity fails

I'm migrating my team's CI from TFS to TeamCity.
As part of my build I need to update a few files and check the changes back to TFS.
I've created a simple MSBuild script that checkout the files, update them and check the changes back in.
The script works great on my machine but when I run it fro TeamCity I get the following error:
TF30063: You are not authorized to access ...
Is there a way I can run only the MSBuild step and another user?
Is there a way to grant TeamCity's Agent the needed permissions to connect to TFS
Did you add the Team City Agent account to the team project security groups in Team Foundation Server?

Resources