TeamCity - Download Artifact

Octopus.Script exported 2015-01-23 by bobjwalker belongs to ‘TeamCity’ category.

Downloads the TeamCity artifact from the most recent build of the specified branch.

Parameters

When steps based on the template are included in a project’s deployment process, the parameters below can be set.

TeamCity Host

TeamCityHost =

The domain name and optional port of the TeamCity build server. (ex. teamcity.mycompany.com:8080)

TeamCity Username

TeamCityUsername

The TeamCity username that is used to authenticate the request. This user must have permissions to download the specified artifact.

TeamCity Password

TeamCityPassword

The TeamCity password that is used to authenticate the request.

Build Type ID

BuildType

The unique identifier of the TeamCity build configuration.

Branch Name

BranchName = master

The name of the branch whose artifact is being download.

Artifact Name

ArtifactName

The filename of the artifact being downloaded.

Output Location

OutputLocation

The name of the folder where the artifact will be downloaded. The resulting file will match the filename of the artifact being downloaded.

Script body

Steps based on this template will execute the following PowerShell script.

# Expected parameters:
#  $TeamCityHost     - The domain name and optional port (teamcity.mycompany.com:8080) of the TeamCity build server.
#  $TeamCityUsername - The TeamCity username.
#  $TeamCityPassword - The TeamCity password.
#  $BuildType        - The unique identifier of the TeamCity build configuration.
#  $BranchName       - The name of the branch.
#  $ArtifactName     - The filename of the artifact.
#  $OutputLocation   - The name of the folder where the artifact will be downloaded.

$secure_password = ConvertTo-SecureString $TeamCityPassword -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($TeamCityUsername, $secure_password)

$resource_identifier = "buildType:$BuildType,branch:$BranchName"

$source = "http://$TeamCityHost/httpAuth/app/rest/builds/$resource_identifier/artifacts/content/$ArtifactName"
$destination = "$OutputLocation\$Artifactname"

Invoke-WebRequest $source -OutFile $destination -Credential $credential

Provided under the Apache License version 2.0.

Report an issue

To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.

{
  "Id": "55a172cc-de3d-45f9-90b1-be51042754b0",
  "Name": "TeamCity - Download Artifact",
  "Description": "Downloads the TeamCity artifact from the most recent build of the specified branch.",
  "Version": 2,
  "ExportedAt": "2015-01-23T04:15:51.361+00:00",
  "ActionType": "Octopus.Script",
  "Author": "bobjwalker",
  "Parameters": [
    {
      "Name": "TeamCityHost",
      "Label": "TeamCity Host",
      "HelpText": "The domain name and optional port of the TeamCity build server.\n(ex. teamcity.mycompany.com:8080)",
      "DefaultValue": "",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "TeamCityUsername",
      "Label": "TeamCity Username",
      "HelpText": "The TeamCity username that is used to authenticate the request.  This user must have permissions to download the specified artifact.",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "TeamCityPassword",
      "Label": "TeamCity Password",
      "HelpText": "The TeamCity password that is used to authenticate the request.",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "BuildType",
      "Label": "Build Type ID",
      "HelpText": "The unique identifier of the TeamCity build configuration.",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "BranchName",
      "Label": "Branch Name",
      "HelpText": "The name of the branch whose artifact is being download.",
      "DefaultValue": "master",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "ArtifactName",
      "Label": "Artifact Name",
      "HelpText": "The filename of the artifact being downloaded.",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "OutputLocation",
      "Label": "Output Location",
      "HelpText": "The name of the folder where the artifact will be downloaded.  The resulting file will match the filename of the artifact being downloaded.",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    }
  ],
  "Properties": {
    "Octopus.Action.Script.ScriptBody": "# Expected parameters:\n#  $TeamCityHost     - The domain name and optional port (teamcity.mycompany.com:8080) of the TeamCity build server.\n#  $TeamCityUsername - The TeamCity username.\n#  $TeamCityPassword - The TeamCity password.\n#  $BuildType        - The unique identifier of the TeamCity build configuration.\n#  $BranchName       - The name of the branch.\n#  $ArtifactName     - The filename of the artifact.\n#  $OutputLocation   - The name of the folder where the artifact will be downloaded.\n\n$secure_password = ConvertTo-SecureString $TeamCityPassword -AsPlainText -Force\n$credential = New-Object System.Management.Automation.PSCredential($TeamCityUsername, $secure_password)\n\n$resource_identifier = \"buildType:$BuildType,branch:$BranchName\"\n\n$source = \"http://$TeamCityHost/httpAuth/app/rest/builds/$resource_identifier/artifacts/content/$ArtifactName\"\n$destination = \"$OutputLocation\\$Artifactname\"\n\nInvoke-WebRequest $source -OutFile $destination -Credential $credential",
    "Octopus.Action.Script.Syntax": "PowerShell"
  },
  "Category": "TeamCity",
  "HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/teamcity-download-artifact.json",
  "Website": "/step-templates/55a172cc-de3d-45f9-90b1-be51042754b0",
  "Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAwBQTFRF////AAAADLDykFz7O+piv7+/Ayw9DbLuQEBAMd6BhmL6Jc6mDbHwDbLvNeJ1WueRDbHvFbvW8Pr+18X9E7jdDLHxELXlDLHwOullFLrZMsrGDLDxIMi12PnnWn73DrPsr677ELXmErfhFr3SEbbjDrPrEbbiiGH6GL/MD7TpdW35pOH6E7jeJM2pD7ToKNKdFrzUMt9+RLO2MNyEOedqFLnbYnn4LNeSbXL4Isuu6uX+GcDLG8LFWd6vjl37w6v9KtSYb4f5ErfgEbbkDbLtN+RwHsa6HcW/jV77fumzLdiPHMTAfmf54vX9L9uJSZrbY9bWGL7OF73ReWr5LtqKg2T6cm75au+HH8e5KtWXJtCjNOF4I8ysJ9GhnXH8ELXnVoD3gICAG7XzKdOaXnz4BzEyDrPqN+VuuZr9fGj5EBAQScT1zrf9HMPC0fD8K9aUZXf4e2n5TYf3Z873wuv8GsHIErffM+B749b+LtmMIsqwGc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