Config

Config language
Provide env variable for branch name targeted by pull request
For many reasons, it is necessary to determine the branch target pull request that triggered the current workflow. This has been a frequently requested feature, and has cropped up on the discuss.circleci site in numinous requests and formats. Example: Conditioning the selected image tag used by the docker executor via base branch name from PR, given that this is otherwise intractable given the otherwise lack of propagating such conditional logic to a jobs executed prior to the job being able to even run.Please see the reference here: https://discuss.circleci.com/t/conditioning-docker-image-via-base-branch-name-from-pr/28426 Issue: Currently, as of CircleCi 2.0, no environment variables provide a basic means to aquise the branch name targeted by a pull request, be it from a forked repository or internal from the local repo. https://circleci.com/docs/2.0/env-vars/ The closest contenders include the CIRCLECI_BRANCH that for pull requests, instead returns the name of branch intended to be merged from with the new commits, not the base branch for which the commits would like to be merged into. Additionally, CIRCLE_PULL_REQUEST only contains the URL of the associated pull request, which has no-or-limited utility for the case example described above, given the branch name would first need to be parsed from the URL before useable. Alternatives: If we take a comparative look at Travis, provided is the TRAVIS_BRANCH env variable that returns the the branch targeted by the pull request if triggered by such a PR. https://docs.travis-ci.com/user/environment-variables/ TRAVIS_BRANCH: for push builds, or builds not triggered by a pull request, this is the name of the branch. for builds triggered by a pull request this is the name of the branch targeted by the pull request. for builds triggered by a tag, this is the same as the name of the tag (TRAVIS_TAG). Proposal: Given the current pattern of available variables from CircleCI, including: CIRCLE_PR_NUMBER Integer The number of the associated GitHub or Bitbucket pull request. Only available on forked PRs. CIRCLE_PR_REPONAME String The name of the GitHub or Bitbucket repository where the pull request was created. Only available on forked PRs. CIRCLE_PR_USERNAME String The GitHub or Bitbucket username of the user who created the pull request. Only available on forked PRs. I'd suggest adding CIRCLE_PR_BRANCH that provides such a feature as follows: CIRCLE_PR_BRANCH String The target branch name in the GitHub or Bitbucket repository where the pull request was created. Only available on forked PRs. Alternatively, it might be nice to follow the logical switching of TRAVIS_BRANCH to allow for in branch commits to use the same conditioning logic as described in the case example link without compilation then the job trigger does not arise from a PR. CCI-I-894
28
allow empty workflow jobs
It would be useful to allow "empty" (need a better name) workflow steps with the following properties: can take part in dependency chains, i.e. can require other jobs to complete can be required by other jobs to complete no build steps and require no build agent to run (similar to "approval" jobs) Such jobs could be useful in structuring and organising workflows.They would save repetition allowing cleaner, DRYer workflow codeand the diagrams would be more unserstandable.For example, imagine the following scenario: 3 build steps which run in parallel when all 3 succeed, you want 3 deploy steps to run in parallel Currently you'd do it like this: workflows: version: 2.1 build_then_deploy: jobs: - build1 - build2 - build3 - deploy1: requires: - build1 - build2 - build3 - deploy2: requires: - build1 - build2 - build3 - deploy3: requires: - build1 - build2 - build3 The resultant, confusing diagram would look like this: build1 --+-- deploy1 |build2 --+-- deploy2 |build3 --+-- deploy3 Adding an "empty" job would allow you to refactor, like this: workflows: version: 2.1 build_then_deploy: jobs: - build1 - build2 - build3 - builds_completed: type: empty requires: - build1 - build2 - build3 - deploy1: requires: - builds_completed - deploy2: requires: - builds_completed - deploy3: requires: - builds_completed The code is more natural to read and the diagram would be less confusing: build1 --+ +-- deploy1 | |build2 --+-- builds_completed --+-- deploy2 | |build3 --+ +-- deploy3 CCI-I-855
2
Load More