Leroy can be integrated into any build system like Team City or Jenkins. We have been doing a lot of work with Team City lately and I wanted to share the best way we’ve gotten Leroy to integrated with Team City.

  • Install Leroy on a server that has a Team City agent.
  • For each Branch of code, and/or unique component. Create  a Team City project. The reason for this is because you can not use a parameter in Team City to determine from which project you are pulling artifacts. Go into the dependencies configuration and choose which artifacts you want to deploy from other build projects and have them copied as .zip file in the %LEROY_HOME%\artifacts folder. Leroy will error if an artifact is called in a <transfer> step that doesn’t exist in the artifacts folder to ensure integrity of the deployment.
  • For each environment you deploy to, create a build configuration in that project.
    • In “Build Parameters”, you should create WORKFLOW and ENVIRONMENT as “configuration parameters” define each workflow you have defined in your leroy’s workflows/ folder without the “.xml” part as workflow names you want to run, ensure each property is set to TYPE = SELECT and DISPLAY = NORMAL.
    • Save project as template
    • Create project from the template for each environment and change the ENVIRONMENT property-type to the value of the respective environment.
    • It is also helpful to create an additional project from the template that you detach and change the properties to prompt values and edit the choices to contain all the workflows and all the environments so you have 1 free form project where you can choose what you want.
    • Configure the project to populate the leroy configs:
      • %LEROY_ROOT%\*.xml
      • %LEROY_ROOT%\commands\*.*
      • %LEROY_ROOT%\properties\**\*.xml
    • Then execute leroy as:
      c:\leroy\controller.exe –workflow %WORKFLOW% –environment %ENVIRONMENT%*nix:
      ./controller.exe –workflow ${WORKFLOW} –environment ${ENVIRONMENT}
    • Leroy will return a non-zero status to the shell upon deployment failure.

 

There may be some benefit in creating a plugin for Team City to help manage this a bit better. With the above setup, Team City will present a project for each component you want to deploy and a build configuration for each environment you want to perform your deployment. This will keep a nice log of deployment activity per environment of your application.