CircleCI-Public / circleci-cli

Use CircleCI from the command line
https://circleci-public.github.io/circleci-cli/
MIT License
405 stars 233 forks source link

PIPE-4359 Update config compilation pipeline values to add parameters #1052

Closed liamclarkedev closed 3 months ago

liamclarkedev commented 3 months ago

Checklist

=========

Internal Checklist

Changes

=======

Rationale

=========

Config compilation now accepts pipeline values and parameters in a single map with the expected prefixes.

All standard values are now prefixed with pipeline., and all parameters are prefixed with pipeline.parameters. as described in the Pipeline Values documentation.

https://circleci.com/docs/pipeline-variables/

Considerations

==============

The parameters inside pipeline values are not currently used, there are metrics in place to reach a 100% match before we start relying on the data in a single map.

Although the service is prepared to accept the new prefixed format, should things go wrong, this could impact any command that requires config compilation where the config references a pipeline value or parameter.

liamclarkedev commented 3 months ago

Local CLI validation:

./circleci config process ../.circleci/config.yml --pipeline-parameters="foo: bar" --verbose

Pipeline values are provided with the expected prefix and parameters.

Processing config with following values:
pipeline.git.base_revision: ...
pipeline.git.branch: ...
pipeline.git.revision: ...
pipeline.git.tag:
pipeline.id:       00000000-0000-0000-0000-000000000001
pipeline.number:   1
pipeline.parameters.foo: bar
pipeline.project.git_url: ...
pipeline.project.type: github

Config is compiled successfully with the pipeline values:

version: 2
jobs:
  pipeline-values:
    docker:
    - image: cimg/base:stable
    steps:
    - run:
        name: Validate pipeline values
        command: |
          echo 'pipeline.id is 00000000-0000-0000-0000-000000000001.'
          echo 'pipeline.parameters.foo is bar.'
workflows:
  setup:
    jobs:
    - pipeline-values
  version: 2

# Original config.yml file:
# version: 2.1
#
# parameters:
#   foo:
#     type: string
#     default: \"default\"
#
# jobs:
#   pipeline-values:
#     docker:
#       - image: cimg/base:stable
#     steps:
#       - run:
#           name: Validate pipeline values
#           command: |
#             echo 'pipeline.id is << pipeline.id >>.'
#             echo 'pipeline.parameters.foo is << pipeline.parameters.foo >>.'
#
#
# workflows:
#   setup:
#     jobs:
#       - pipeline-values