concourse / semver-resource

automated semantic version bumping
Apache License 2.0
96 stars 105 forks source link

Output version to different directory #58

Closed pms1969 closed 6 years ago

pms1969 commented 6 years ago

I have some tasks that span jobs in a pipeline that do exactly the same thing except for version number resources. What I'd really like to do is use the semver resource to output to a different directory so that I only need the one task file, and can have version/version as one input to it.

my setup is something like this:

task-requiring-version.yml

---
platform: linux

image_resource:
  type: docker-image
  source:
    repository: custom-docker-image

inputs:
  - name: pipelines
  - name: version

run:
  path: /bin/bash
  args: 
  - -cel
  - |
    # Do stuff requiring the version
    export version=$(cat ${version/version})
    # and so on

another-task-requiring-different-version.yml

---
platform: linux

image_resource:
  type: docker-image
  source:
    repository: custom-docker-image

inputs:
  - name: pipelines
  - name: different-version

run:
  path: /bin/bash
  args: 
  - -cel
  - |
    # Do stuff requiring the version
    export version=$(cat ${different-version/version})
    # and so on

pipeline.yml

- name: deploy app 1
  plan:
  - aggregate:
    - get: pipelines
    - get: version
      passed: ["previous step"] # where the version got bumped

  - task: Deploy
    file: pipelines/tasks/deploy-app-1.yml

  - task: Check application health
    file: pipelines/tasks/task-requiring-version.yml

- name: deploy app 2
  plan:
  - aggregate:
    - get: pipelines
    - get: different-version
      passed: ["previous other step"] # where the different-version got bumped

  - task: Deploy
    file: pipelines/tasks/deploy-app-2.yml

  - task: Check application health
    file: pipelines/tasks/another-task-requiring-different-version.yml.yml

# and so on

where as what I think I'd like is:

pipeline.yml

- name: deploy app 1
  plan:
  - aggregate:
    - get: pipelines
    - get: version
      passed: ["previous step"] # where the version got bumped

  - task: Deploy
    file: pipelines/tasks/deploy-app-1.yml

  - task: Check application health
    file: pipelines/tasks/task-requiring-version.yml

- name: deploy app 2
  plan:
  - aggregate:
    - get: pipelines
    - get: different-version
      params: {out-dir: version}
      passed: ["previous other step"] # where the different-version got bumped

  - task: Deploy
    file: pipelines/tasks/deploy-app-1.yml

  - task: Check application health
    file: pipelines/tasks/task-requiring-version.yml

# and so on

If there's already a known way of doing this that doesn't require another task to copy the versions to task outputs (which would require the same custom tasks, just doing something different), I'd appreciate being told how. Otherwise, does this sound like a feasible enhancement?

vito commented 6 years ago

The resource doesn't control the directory name; it just puts a version file in there. What you're seeing as the directory name is actually determined by the usage within the plan. You could use input_mapping for this, or rename the get step by explicitly specifying a different get value and the resource name as resource:

get: version
resource: different-version
pms1969 commented 6 years ago

@vito Champion. Just what I was looking for. Cheers. I'm continually learning new things about concourse.