git-resource icon indicating copy to clipboard operation
git-resource copied to clipboard

Why is the "branch" parameter defined in the source field and not defined as mandatory in the "param" field?

Open bheemann opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe.

I have a multibranch pipeline like this:

resource_types:
  - name: git-branches
    type: registry-image
    source:
      repository: aoldershaw/git-branches-resource

resources:
  - name: issue-branches
    type: git-branches
    source:
      uri: <uri>
      password: <user>
      username: <pw>
      branch_regex: 'Foo-(?P<issue>.*)'

  - name: project
    type: git
    source:
      uri: <uri>
      password: <user>
      username: <pw>
      fetch_tags: true


jobs:
  - name: set-issue-pipelines
    plan:
    - get: issue-branches
      trigger: true # creates pipeline for new branch      
    - get: project
    - load_var: branches
      file: issue-branches/branches.json
    - across:
      - var: branch
        values: ((.:branches))
      do:
      - get: semver-repo 
      - task: create-initial-version-file
        file: project/pipelines/tasks/create-initial-release-version.yml
        vars:
          branch: ((.:branch.name))
      - put: semver-repo
        params:
          repository: semver-repo
      - set_pipeline: issues-tests
        file: project/pipelines/branch_pipeline.yml
        instance_vars: {issue: ((.:branch.groups.issue))}
        vars: 
          branch: ((.:branch.name))
          version_bump_style: {pre: ((.:branch.name))}
          pre_release: true

At the moment I can only use the same branch template for every pipeline created via set_pipeline.

Describe the solution you'd like

What i would like to do:

resource_types:
  - name: git-branches
    type: registry-image
    source:
      repository: aoldershaw/git-branches-resource

resources:
  - name: issue-branches
    type: git-branches
    source:
      uri: <uri>
      password: <user>
      username: <pw>
      branch_regex: 'Foo-(?P<issue>.*)'

  - name: project
    type: git
    source:
      uri: <uri>
      password: <user>
      username: <pw>
      fetch_tags: true



jobs:
  - name: set-issue-pipelines
    plan:
    - get: issue-branches
      trigger: true # creates pipeline for new branch       
    - load_var: branches
      file: issue-branches/branches.json
    - across:
      - var: branch
        values: ((.:branches))
      do:
      - get: semver-repo 
      - get: project
        branch: ((.:branch.name))          <-- NOT POSSIBLE BUT DESIRED AS NEW FEATURE
      - task: create-initial-version-file
        file: project/pipelines/tasks/create-initial-release-version.yml
        vars:
          branch: ((.:branch.name))
      - put: semver-repo
        params:
          repository: semver-repo
      - set_pipeline: issues-tests
        file: project/pipelines/branch_pipeline.yml
        instance_vars: {issue: ((.:branch.groups.issue))}
        vars: 
          branch: ((.:branch.name))
          version_bump_style: {pre: ((.:branch.name))}
          pre_release: true

Describe alternatives you've considered

I can't think of any alternatives that aren't very complex at the same time, although the proposed solution seems so elegant to me?

However, there must be something that I am overlooking as to why it is not already implemented in this way, or am I the only one with this requirement?

Additional context

I am happy to receive suggestions, ideas or tips.

Happy coding!

bheemann avatar Jan 26 '24 12:01 bheemann