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 .git/branch as additional populated file #356

Closed
jmatsushita opened this issue Mar 24, 2021 · 2 comments · Fixed by #391
Closed

Add .git/branch as additional populated file #356

jmatsushita opened this issue Mar 24, 2021 · 2 comments · Fixed by #391

Comments

@jmatsushita
Copy link

jmatsushita commented Mar 24, 2021

Would you consider adding a .git/branch file in the additionally populated files with the branch name? Unless I'm missing something I can't see how to transform the branch name that triggered the pipeline into a variable for instantiated pipelines.

This would be nice to make use of the instanced pipeline experimental feature and use set_pipeline with the branch value in this way:

- name: configure-pipelines
  public: true
  plan:
    - get: my-repo
      trigger: true

    - load_var: branch_name
      file: .git/branch

    - set_pipeline: build
      file: my-repo/.concourse.yml
      instance_vars:
        branch: ((.:branch_name))

The implementation could be

git symbolic-ref -q --short HEAD > .git/branch
@jmatsushita
Copy link
Author

I see it was discussed in this PR #257

Another implementation from that discussion:

git branch --remote --contains HEAD --format="%(refname:lstrip=-1)" > .git/branch

@n-insaidoo
Copy link

Isn't there anyway you could reference the branch attribute from the resources object elsewhere in the configuration?

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 a pull request may close this issue.

2 participants