Deployment Agents

Hi all,
  We've been using Teamcity as our CI for a couple of weeks and we absolutely love it.  We have a bit of a scenario that I can't seem to address, and some help would be greatly appreciated.

From my understanding Teamcity is set up in an Agent/Server architecture.  As such we can run builds on any agents.  Our systems, test, stage, and production all have a well defined deployment process, and I would like to create an agent that only performs deployments.  Here's how I envision the process.

1. Install deployment agents on all our servers, test, stage and production
2. After a build is successfull, a user in the proper group (configured via Teamcity) can log into Team city and deploy the build to any environment they choose
3. The Deployment agent is notified the build is ready, and it downloads the artifact and executes the custom deployment.

I realize that deployments are very application specific, and therefore Jetbrains cannot produce a standard deployment agent.  I've read the doc on downloading artifacts via HTTP interface of the build server, but this still requires a developer to log in to our systems to deploy.  I'd like to initiate deployment via the Teamcity web interface independently of the build process.  Is there a way I can do this with custom plugins?

Thanks,
Todd

0
9 comments

May be this blog post can help you: http://teamcitydev.blogspot.com/2008/08/you-probably-have-seen-this.html
In brief you can install agent on the same PC where a server which needs to be redeployed is installed. If agent is on the same PC the deployment process can be greatly simplified. This agent can execute special build script which not only will obtain and prepare artifacts but also will redeploy your application in the server.

0
Avatar
Permanently deleted user

Hi Pavel,
  This has been a great help, but I'm still a bit stuck.  Here's what I've done with the build agent.

  1. Install it on the server
  2. Set a dependency to be our main build.  I extract the pattern Release*/*.zip!** to C:\releases.  This works as expected
  3. Once the unzip has been performed, we normally log in via Remote desktop, then fire up a command line.  From there, I do a C:\DeploymentScripts then execute the command

    C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe . 'C:\DeploymentScripts\deploy-test.ps1'


I've set my working directory to be

C:\DeploymentScripts

and the command to execute to be

C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe . 'C:\DeploymentScripts\deploy-test.ps1'

However I receive this error every time.


Cannot run process: CreateProcess: "C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe . 'C:\DeploymentScripts\deploy-test.ps1'" error=123

[17:58:12]: com.intellij.execution.process.ProcessNotCreatedException: CreateProcess: "C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe . 'C:\DeploymentScripts\deploy-test.ps1'" error=123
com.intellij.execution.process.ProcessNotCreatedException: CreateProcess: "C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe . 'C:\DeploymentScripts\deploy-test.ps1'" error=123
at com.intellij.execution.configurations.GeneralCommandLine.createProcess(GeneralCommandLine.java:113)
at jetbrains.buildServer.agent.runner2.GenericCommandLineBuildProcess.createProcess(GenericCommandLineBuildProcess.java:96)
at jetbrains.buildServer.agent.runner2.GenericCommandLineBuildProcess.start(GenericCommandLineBuildProcess.java:69)
at jetbrains.buildServer.agent.impl.runStages.CallRunnerStage.doBuildStage(CallRunnerStage.java:35)
at jetbrains.buildServer.agent.impl.BuildRunAction.doStages(BuildRunAction.java:135)
at jetbrains.buildServer.agent.impl.BuildRunAction.access$000(BuildRunAction.java:21)
at jetbrains.buildServer.agent.impl.BuildRunAction$1.run(BuildRunAction.java:91)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.io.IOException: CreateProcess: "C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe . 'C:\DeploymentScripts\deploy-test.ps1'" error=123
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
at java.lang.ProcessImpl.start(ProcessImpl.java:30)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
at java.lang.Runtime.exec(Runtime.java:591)
at com.intellij.execution.configurations.GeneralCommandLine.createProcess(GeneralCommandLine.java:108)
... 7 more

[17:58:18]: Build finished


Any ideas?
0

Please check user under which your build agent service is working. This user may not have enough permissions to run powershell.

Also check out this bug report for possible problems with powershell: http://www.jetbrains.net/tracker/issue/TW-6021

0
Avatar
Permanently deleted user

Hi Pavel,
  I gave up on the powershell, I'm wrapping a cmd file with an MSBuild file.  Basically I only have one task, here's my file.

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="DeployBuild" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <Target Name="DeployBuild">
    <Exec Command="deploy-test.cmd" />
  </Target>

</Project>

When I run my msbuild it correctly deploys.  I've set my build file path to be C:\DeploymentScripts\deploybuild.proj and my working directory to be C:\DeploymentScripts.  However I always get the error below.

Cannot find build file by path specified in build configuration settings: 'C:\DeploymentScripts\deploybuild.proj' (absolute path on agent)

I'm running my build agent under the SYSTEM account, and I've double checked that the SYSTEM account has full CRUD permissions recursively set.  Any ideas what's going on?  I can't seem to find the cause of the error in any of the agent logs.

0

Please try to use usual user account instead of SYSTEM, or try to start agent from the agent.bat script.

0
Avatar
Permanently deleted user

So, I'm incredibly embarassed to admit that after I changed to the MSBuild config, the problems were all between my keyboard and chair.  My builds were running on my teamcity agent, not my test server agent.  I know I can go into each agent and specifically select with builds they can run.  However, I'd like to leave everything default so that new projects are distributed normally across all agents, and only force my deployment build to run on the Test Agent.  Is there a way to do this without modifying each agent individually?

0

You can specify that deployment configuration can run on Test Agent only. You need to change one agent settings only.

0
Avatar
Permanently deleted user

Thanks, for the help.  I was able to come up with the following in the deployment agent on my test server.

env.deploymentEnvironment=test

and for any development builds I have

env.supportsServerIntegrationTesting=true


This allows me to require the correct values in my build and deployment runtimes, and appropriate agents are automatically selected.  Thanks for all the guidance!

0

I meant you can explicitly select which configurations can be built on an agent. See tab Compatible agents for the agent itself, there you can change "run selected configurations only" and mark checkboxes near the desired configurations.

0

Please sign in to leave a comment.