Octopus.Script exported 2015-03-16 by bjorgvino belongs to ‘TeamCity’ category.
Trigger a specific Team City build from an Octopus Deploy process.
Parameters
When steps based on the template are included in a project’s deployment process, the parameters below can be set.
null
BuildConfigurationId
The Id of the build configuration to trigger.
null
TeamCityUrl
The URL of the Team City server.
E.g. http://teamcity.example.com
.
null
TeamCityUsername =
The username to use for accessing TeamCity.
null
TeamCityPassword
The password for the TeamCity user.
Script body
Steps based on this template will execute the following PowerShell script.
$buildConfId = $OctopusParameters['BuildConfigurationId']
$teamCityUrl = $OctopusParameters['TeamCityUrl']
$teamCityUsername = $OctopusParameters['TeamCityUsername']
$teamCityPassword = $OctopusParameters['TeamCityPassword']
$url = $teamCityUrl + '/httpAuth/app/rest/buildQueue'
$contentTemplate = '<build><buildType id="{0}"/></build>'
$content = $contentTemplate -f $buildConfId
$encodedContent = [System.Text.Encoding]::UTF8.GetBytes($content)
Write-Host "================================================================================"
Write-Host "Triggering build with Id $buildConfId in TeamCity. Server:" $teamCityUrl
Write-Host "================================================================================"
$req = [System.Net.WebRequest]::Create($url)
$req.Credentials = new-object System.Net.NetworkCredential($teamCityUsername, $teamCityPassword)
$req.Method ="POST"
$req.ContentType = "application/xml"
$req.ContentLength = $encodedContent.length
$requestStream = $req.GetRequestStream()
$requestStream.Write($encodedContent, 0, $encodedContent.length)
$requestStream.Close()
$resp = $req.GetResponse()
$reader = new-object System.IO.StreamReader($resp.GetResponseStream())
$reader.ReadToEnd() | Write-Host
Provided under the Apache License version 2.0.
To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.
{
"Id": "22483ce2-1444-4c02-861c-fb9533959e16",
"Name": "Trigger TeamCity Build",
"Description": "Trigger a specific Team City build from an Octopus Deploy process.",
"Version": 1,
"ExportedAt": "2015-03-16T10:47:31.328+00:00",
"ActionType": "Octopus.Script",
"Author": "bjorgvino",
"Parameters": [
{
"Name": "BuildConfigurationId",
"Label": null,
"HelpText": "The Id of the build configuration to trigger.",
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "TeamCityUrl",
"Label": null,
"HelpText": "The URL of the Team City server.\nE.g. `http://teamcity.example.com`.",
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "TeamCityUsername",
"Label": null,
"HelpText": "The username to use for accessing TeamCity.",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "TeamCityPassword",
"Label": null,
"HelpText": "The password for the TeamCity user.",
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "Sensitive"
}
}
],
"Properties": {
"Octopus.Action.Script.ScriptBody": "$buildConfId = $OctopusParameters['BuildConfigurationId']\n\n$teamCityUrl = $OctopusParameters['TeamCityUrl']\n$teamCityUsername = $OctopusParameters['TeamCityUsername']\n$teamCityPassword = $OctopusParameters['TeamCityPassword']\n\n$url = $teamCityUrl + '/httpAuth/app/rest/buildQueue'\n$contentTemplate = '<build><buildType id=\"{0}\"/></build>'\n$content = $contentTemplate -f $buildConfId\n$encodedContent = [System.Text.Encoding]::UTF8.GetBytes($content)\n\nWrite-Host \"================================================================================\"\nWrite-Host \"Triggering build with Id $buildConfId in TeamCity. Server:\" $teamCityUrl \nWrite-Host \"================================================================================\"\n\n$req = [System.Net.WebRequest]::Create($url)\n$req.Credentials = new-object System.Net.NetworkCredential($teamCityUsername, $teamCityPassword)\n$req.Method =\"POST\"\n$req.ContentType = \"application/xml\"\n\n$req.ContentLength = $encodedContent.length\n$requestStream = $req.GetRequestStream()\n$requestStream.Write($encodedContent, 0, $encodedContent.length)\n$requestStream.Close()\n\n$resp = $req.GetResponse()\n$reader = new-object System.IO.StreamReader($resp.GetResponseStream())\n$reader.ReadToEnd() | Write-Host\n",
"Octopus.Action.Script.Syntax": "PowerShell"
},
"Category": "TeamCity",
"HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/teamcity-trigger-build.json",
"Website": "/step-templates/22483ce2-1444-4c02-861c-fb9533959e16",
"Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAwBQTFRF////AAAADLDykFz7O+piv7+/Ayw9DbLuQEBAMd6BhmL6Jc6mDbHwDbLvNeJ1WueRDbHvFbvW8Pr+18X9E7jdDLHxELXlDLHwOullFLrZMsrGDLDxIMi12PnnWn73DrPsr677ELXmErfhFr3SEbbjDrPrEbbiiGH6GL/MD7TpdW35pOH6E7jeJM2pD7ToKNKdFrzUMt9+RLO2MNyEOedqFLnbYnn4LNeSbXL4Isuu6uX+GcDLG8LFWd6vjl37w6v9KtSYb4f5ErfgEbbkDbLtN+RwHsa6HcW/jV77fumzLdiPHMTAfmf54vX9L9uJSZrbY9bWGL7OF73ReWr5LtqKg2T6cm75au+HH8e5KtWXJtCjNOF4I8ysJ9GhnXH8ELXnVoD3gICAG7XzKdOaXnz4BzEyDrPqN+VuuZr9fGj5EBAQScT1zrf9HMPC0fD8K9aUZXf4e2n5TYf3Z873wuv8GsHIErffM+B749b+LtmMIsqwGcDJBi81il/7D7TnD7TqOOZsGsHGMcHi7+/vx/jWaHX4F77PMK3TIcmzK7PNgGb6F77QGsLGL9uHq4X8IcqyFLran5+fhdf4leThK9aTz8/PKrr0Hsa8J9GfgWX6O+pjLdmNG8PDWMn1NuNzI8yrRKbKROh1H8i3HcW9IcqxTI3scHD5UIT3ICAgU4L3M+B8cHBwMDAwYGBgd2v5+PX/yfPoLNiQOehoCDIunPO1K9WVOr/0j4+Pa3P4g+6ms4/85vzt39/fhGP6s+b78v33d9P4HsW8ru7ar6+vMNyG8Oz+l2b7BS44kpb7Gb/LpXv8emr59ff/VO12lNz5R+tstffFLtmLanX2hfKdH8e3xcz8UFBQk7L6PORrqfa6E7nbHbjsVuKfbHjwiHD6d6f4WIziIb3T29z9IjY/sfHTQN+A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