Skip to content

Publish IDs of generated images as a build parameters

License

Notifications You must be signed in to change notification settings

jetbrains-infra/packer-post-processor-teamcity

Repository files navigation

Packer Post-Processor for TeamСity

HashiCorp Packer generates image IDs, like ami-387dc380. When creating a build chain with separate configurations for building, testing, and deploying images, we need to reference their IDs.

This is a Packer plugin, which saves the generated image IDs as parameters in the build history: packer.artifact.id

Packer can run multiple builders in parallel, so a single build can produce several artifacts. Custom builder names can be used to distinguish them.

For AMIs in AWS, there is a special format, two parameters are published for each artifact: packer.artifact.aws.ami and packer.artifact.aws.region

Now dependent build configurations can reference these parameters and resolve the image IDs dynamically: reference

Usage

  1. Download the binaries from the Releases page.
  2. Install the plugin on build agents.
  3. Add the TeamCity post-processor to Packer configurations:
{
  "builders": [
    {
      "name":"agent",
      "type": "amazon-ebs",
      
      .......
    }
  ],
  "post-processors": [
    "teamcity"
  ]
}

Register TeamCity Cloud Agent Images

Optionally the plugin can be used to deploy new versions of TeamCity cloud agents: after the images are created Packer registrs them in cloud agent profiles on TeamCity server:

This feature works with vSphere only. See #3
{
  "builders": [
    {
      "name": "agent",
      .......
    }
  ],
  "post-processors": [
    {
      "type": "teamcity",
      "teamcity_url": "https://teamcity.local",
      "username": "admin",
      "password": "secret",
      "project_id": "_Root",
      "custom_image_name": "{{build_name}}",
      "agent_name": "{{build_name}}-{{user `build_number`}}"
    }
  ]
}

About

Publish IDs of generated images as a build parameters

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •