Referencing semver in image tag for a task?


#1

I’m trying to reference the semver I get earlier in my pipeline as part of the tags when I go to use the image resource in a task. I keep getting “no versions of image available”. I know I’m missing something easy I just can’t seem to find it

Here’s the pipeline:

resources:
- name: db-build
type: git
source : &repo-source
uri: git@github.com:<project>.git
branch: develop
private_key: ((variable))
- name: version
type: semver
source:
driver: s3
initial_version: 0.0.1
access_key_id: <access key>
secret_access_key: <secret key>
bucket: <semver>
region_name: us-west-2
key: maria-ci-db/version
- name: db-update-image
type: docker-image
source:
repository:
tag: version
jobs:
- name: Build Docker Image
plan:
- get: cf-static-build
trigger: true
- get: version
params: {pre: mariadb, file: version/version}
- put: db-update-image
params: {build: cf-static-build/mariadb, tag_file: version/number}
- name: Update-CI-DB
plan:
- get: version
passed: [“Build Docker Image”]
- task: run
config:
platform: linux
image_resource:
type: docker-image
source:
repository: <ecr>
tag: ‘version’
run:
path: sh
args:
- -exc
- |
ENVIRONMENT=ci yarn migrate


#2

Hi cf-dan,

if you use the semver resource, the version file will be in your task container under <semver resource name>/version.

But you have to also get the semver resource in your task definition.
In general if you are unsure where you can find specific informations from a resource, just add them to your task and hijack the container to “explore” it a bit :slight_smile: .

P.S. if you ever be in the situation to set the semver version string manually in s3, keep in mind that
the resource will not strip any white space or newline characters.
echo "v1.2.3" > version.yml

best,
D