Skip to content
Concourse resource, which outputs build metadata to files.
Shell Dockerfile
Branch: master
Clone or download
Latest commit f86c1d4 Apr 27, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.travis.yml Bump to 2.0.1 Apr 27, 2019
Dockerfile Fix script permissions Mar 18, 2017
LICENSE Create LICENSE Apr 11, 2019
README.md Update README.md Nov 24, 2018
check Emit empty versions, fixes #1 Nov 24, 2018
in Emit proper version in get and put steps; fixes #2 Apr 27, 2019
out Emit proper version in get and put steps; fixes #2 Apr 27, 2019

README.md

Metadata Resource

Build Status

This resource outputs Concourse.ci build metadata to files to make annotations easier. One such use-case may be to add build links to the body of GitHub releases.

As Concourse documentation states, avoid using this for versioning. Use the semver resource instead.

Behavior

⚠️ Since 2.0.0 a put step has to used instead of a get to fix this issue. If you want the old behaviour, use version 1.0.0 of this resource. ⚠️

check: Not used

Always emits an empty version.

in: Output metadata to files

Outputs $BUILD_ID, $BUILD_NAME, $BUILD_JOB_NAME, $BUILD_PIPELINE_NAME, $BUILD_TEAM_NAME and $ATC_EXTERNAL_URL to files build_id, build_name, build_job_name, build_pipeline_name, build_team_name and atc_external_url respectively.

out: Not used

Example

The following example shows how a GitHub release can be created with a link pointing to the build.

# Register the metadata resource type
resource_types:
  - name: metadata
    type: docker-image
    source:
      repository: olhtbr/metadata-resource
      tag: 2.0.0

resources:
  # The resource does not need any configuration
  - name: metadata
    type: metadata

  # GitHub release resource
  # Check https://github.com/concourse/github-release-resource#source-configuration for more info
  - name: release
    type: github-release
    source:
      owner: my-github-user
      repository: my-github-repo
      acces_token: github-access-token
      # other settings...

jobs:
  - name: prepare-release
    plan:
      - put: metadata
      - get: release

      - task: setup-release-properties
        config:
          platform: linux
          image_resource:
            type: docker-image
            source:
              repository: busybox

          inputs:
            - name: metadata

          # A URL to the build and other release properties
          # will be available as files in the properties folder
          outputs:
            - name: properties

          run:
            path: sh
            args:
              - -exc
              - |
                # Grab the metadata
                url=$(cat metadata/atc_external_url)
                team=$(cat metadata/build_team_name)
                pipeline=$(cat metadata/build_pipeline_name)
                job=$(cat metadata/build_job_name)
                build=$(cat metadata/build_name)

                # Generate the build URL to a file
                echo $url/teams/$team/pipelines/$pipeline/jobs/$job/builds/$build > properties/body

                # Write the release name to a file
                echo v1.0.0 > properties/name

                # The tag must already exist in git
                echo 1.0.0 > properties/tag

      # The put step creates a new GitHub release at the specified tag and
      # its body will contain a link to the current build
      - put: release
        params:
          name: properties/name
          tag: properties/tag
          body: properties/body
You can’t perform that action at this time.