Wednesday, July 22, 2015

Creating and using the new build Agent for VSO on MS Azure

 

Introduction:

  • Lets welcome the new build mechanism that get rid of workflow foundation, and that has a much more “open” state of mind (many people were ambarrassed when I stood up for many years agains WF in build, and “just” use the old style batch. Now, with this new build mechanism, I will do proper and neat job!).
  • Time to complete the installation and configuration of an agent (if nothing goes wrong) : 30 min from start to finish
  • Time to get this post done and tested : many hours !!
  • No more agent that was dedicated to a Team Project Collection. Hello Agent that can build SO MANY type of applications easily without JENKINS (Xamarin, iOS, JS…): See appendices at the very end.

 

Pre-requisites :

  1. Presentation of the agent: http://nakedalm.com/configure-a-build-vnext-agent-on-vso/
    official MSDN: https://msdn.microsoft.com/Library/vs/alm/Build/agents/windows
  2. Have a VSO or a TFS ready
  3. Have a Build server ready. For instance, use a VM or an OnPrem server. Then, go to : https://www.visualstudio.com/downloads/download-visual-studio-vs (or any other link / drive) to install TFS 2015 (RC 2 in this example). Note: It is a matter of 5 min to download using the Azure infrastructure

image image imageimage

 

 

Create an Agent Pool

For instance call it VISEOBuildPool (this name is going to be called later below).
image

Installing the Agent on your server

  1. In your TFS/VSO browser, go the the gear icon (top right) to manage the Default Collection.
  2. In the “Build” Tab, you will find an Agent to be downloaded as a Zip file :

imageimage

This Zip file used to contain many files in the Beta version, but only contains one Powershell script ‘ConfigureAgent.ps1’ ; it calls in turn many other files

image

By default, you cannot run the script on a Windows Server (Technical Preview) machine.
Here is the error message:

  • PS C:\Users\AzurePSellerDvDotNet\Downloads\agent> .\ConfigureAgent.ps1
    .\ConfigureAgent.ps1 : File C:\Users\AzurePSellerDvDotNet\Downloads\agent\ConfigureAgent.ps1 cannot be loaded. The
    file C:\Users\AzurePSellerDvDotNet\Downloads\agent\ConfigureAgent.ps1 is not digitally signed. You cannot run this
    script on the current system. For more information about running scripts and setting execution policy, see
    about_Execution_Policies at
    http://go.microsoft.com/fwlink/?LinkID=135170.
    At line:1 char:1
    + .\ConfigureAgent.ps1
    + ~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : SecurityError: (:) [], PSSecurityException
        + FullyQualifiedErrorId : UnauthorizedAccess

 

Indeed, for security reasons your will have to explicitly tell that

    • PS C:\Users\AzurePSellerDvDotNet\Desktop\Install\agent> Set-ExecutionPolicy Unrestricted
      Execution Policy Change
      The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
      you to the security risks described in the about_Execution_Policies help topic at
      http://go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
      [Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y

 

Now you will be able to run the installation

  • image

 

Answer few questions from a new batch pop-up command prompt:

  • Enter the name for this agent (default is Agent-VISBT-TF15BUILD) SuperVISEOAgentOnAzure
  • Enter the URL for the Team Foundation Server (default is ) https://viseo-bt-int.visualstudio.com
  • Configure this agent against which agent pool? (default pool name is 'default') VISEOBuildPool
  • Enter the path of the work folder for this agent (default is 'C:\Users\AzurePSellerDvDotNet\Desktop\Install\agent\_work') C:\TFSBuild\AgentWorkFolder
    Would you like to install the agent as a Windows Service (Y/N) (default is N) Y
  • Enter the name of the user account to use for the service (default is NT AUTHORITY\LOCAL SERVICE)

    A web browser will popup, and enter your credentials to access VSO, if everthing goes fine (i.e. no cookies problems, “no high level security”, not an Admin of the VM where you cannot open the Microsoft Edge Brower to configure it,… see trouble shooting at the end…).
    Then wait few seconds the time your server is contacting VSO with your credentials, and configures the necessary agent.
                                   image
  • CONGRATULATION !! You should have a nice result such as:

image

 

CHECK THAT EVERYTHING IS WORKING FINE

  image

(see in the appendices at the end, all the system capabilities that are present by default)

if not present, add on the top of the SYSTEM CAPABILITIES the 3 following USER CAPABILITIES to be able to build and run the unit tests.

image

  • Now your build definition becomes available:

 image

 

NOW LETS RUN A BUILD !

image

Here is the result of the Build:

image

 

Now, thanks to the new “VISEOBuildPool” we created above, your project is protected against code that does not build, or does not pass the Unit Test, or does go through quality checks.

image

TROUBLE SHOOTING

PROBLEM

RESOLUTION

Enter the name for this agent (default is Agent-VISBT-TF15BUILD) SuperVISEOAgentOnAzure
Enter the URL for the Team Foundation Server (default is )
https://viseo-bt.visualstudio.com
Configure this agent against which agent pool? (default pool name is 'default') VISEOBuildPool
Enter the path of the work folder for this agent (default is 'C:\Users\AzurePSellerDvDotNet\Desktop\Install\agent\_work') C:\TFSBuild\AgentWorkFolder
Would you like to install the agent as a Windows Service (Y/N) (default is N) Y
Enter the name of the user account to use for the service (default is NT AUTHORITY\LOCAL SERVICE)
SP324098: Your browser could not complete the operation.

  Decrease the security level of your browser to ‘low’
The popup Microsoft Edge is showing up

    image
Server connect operation has beed canceled by user
A task was canceled.
  It is the Microsoft Edge  that is now part of the OS (Windows server or Win10).
And as a VM admin, I cannot run it to allos the Cookies.

Rather, choose IE or Chrome as default brower.
image


image

Issues

No agent could be found with the following capabilities: msbuild, visualstudio, vstest

image

 

 

- Either your Agent machine does not have the required executables

- or it is not defined in the “system capabilities” (see appendices”).

How to reconfigure an existing Agent on a server ?
  Simply re-execute the Powershell.

image

 

APPENDIX 1 : SYSTEM CAPABILITIES THAT ARE PRESENT BY DEFAULT

(sorry, it’s an image because, it is Javascript generated, I cannot easily copy/past)

 

imageimage

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.