Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add params.branch to in/get for use in an "across" step #396

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Houlistonm
Copy link

use case:

jobs:
  - name: set-feature-pipelines
    plan:
      - in_parallel:
          - get: automation-image
            params:
              unpack: true
          - get: ytt
            params:
              globs:
                - ytt-linux-amd64
          - get: cli-tool-feature-branches
            trigger: true
      - load_var: branches
        file: cli-tool-feature-branches/branches.json
      - across:
          - var: branch
            values: ((.:branches))
        do:
        - get: cli-tools
          trigger: true
          get_params:
            branch: ((.:branch.name))
        - task: render-pipeline
          image: automation-image
          file: cli-tools/ci/tasks/render-ytt/task.yml
          params:
            YTT_FLAGS: |
              -f cli-tools/ci/cli_tools.yml
              -f cli-tools/ci/cli_tools_vars.yml
        - set_pipeline: package-cli-tools
          file: ytt-output/output.yml
          instance_vars: {feature: ((.:branch.groups.feature))}
          vars: {branch: ((.:branch.name))}

@taylorsilva
Copy link
Member

cool butttttt this kinda breaks the contract that resource-types have with Concourse. The get step is always given a specific version to fetch. In this case, it's always a commit sha. If that commit sha isn't on that branch then the get step will fail. I don't think it makes sense for us to merge this into the resource.

@Houlistonm
Copy link
Author

I understand the contract. But this is different.
We're trying to set a new pipeline based on the branch name which the resource has already discovered prior to reaching this step.

If you're firm about not/unable to accept this PR, can you propose an alternate solution to set multiple pipelines across feature branches w/o resorting to ytt or some other external tool?

@taylorsilva
Copy link
Member

Leaving this open still because I do like the idea, but I don't like the way it goes against the resource-types contract. I agree that doing something like this would make this workflow WAY easier to achieve. I just don't like the behavioural change it makes to the resource.

@taylorsilva
Copy link
Member

taylorsilva commented Nov 28, 2024

I'd probably create a task that would do the git checkout to the other branch.

jobs:
  - name: set-feature-pipelines
    plan:
      - in_parallel:
          - get: automation-image
            params:
              unpack: true
          - get: ytt
            params:
              globs:
                - ytt-linux-amd64
          - get: cli-tool-feature-branches
            trigger: true
          - get: cli-tools
            trigger: true
      - load_var: branches
        file: cli-tool-feature-branches/branches.json
      - across:
          - var: branch
            values: ((.:branches))
        do:
        - task: switch-branch
          image: automation-image
          file: cli-tools/ci/tasks/switch-branch/task.yml
          input_mapping:
            repo: cli-tools
          output_mapping:
            repo: cli-tools
          params:
            # Git auth info here if required (ssh key/username/password)
            branch: ((.:branch.name))
        - task: render-pipeline
          image: automation-image
          file: cli-tools/ci/tasks/render-ytt/task.yml
          params:
            YTT_FLAGS: |
              -f cli-tools/ci/cli_tools.yml
              -f cli-tools/ci/cli_tools_vars.yml
        - set_pipeline: package-cli-tools
          file: ytt-output/output.yml
          instance_vars: {feature: ((.:branch.groups.feature))}
          vars: {branch: ((.:branch.name))}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants