Using pipeline parameters

Hi all, I feel like I’ve got a fundamental misunderstanding of the purpose of pipeline parameters, and perhaps more of the CircleCI product.

A common thing that I did with Jenkins was have a job that, when run manually, would require selecting a parameter before the build.

This was handy for things like:

  • redeploying a specific version
  • running one of a number of Ansible playbooks
  • deploying to a particular environment

From what I understand, pipeline parameters (as distinct from orb parameters, or job parameters) are intended for the same purpose. In fact the API documentation seems to suggest that this is possible.

Furthermore, pipeline parameters don’t require a default option. The documentation specifically says:

If not present, the parameter is implied to be required.

Required where? I can’t find anywhere to actually use these.

When I pushed a pipeline with a parameter with no default, I expected to get the option to input this, but instead I was met with an error message about an invalid configuration, despite this being a documented as valid. When I added a default, rather than getting the option to run a pipeline with a specific parameter, CircleCI just unconditionally builds with the default every time.

From all of this, I feel like my mental model of CircleCI’s abilities does not align with the reality. Given that my mental model is informed by the documentation, API schema, data model, and UI, this puts me in a strange place when planning usage of the product, one where I have to second-guess everything I’m told about it.

Some clarity from the product team would be greatly appreciated.

Hello @danpalmer!

Pipeline parameters actually behave similarly to how templating languages like Jinja2 or Mustache do - The << pipeline.parameters.parameter_name >> entry is replaced by the value of the parameter within the configuration file itself.
This is typically used in conjunction with the API to pass values along to the configuration, and there isn’t currently a way to define these within CircleCI itself beyond the default value of the parameter.
If the default value is missing, and it’s not passed along via the API, we consider the value required, and will fail the job since it isn’t present.
Happy to answer any other questions you might have :slight_smile:

Hi @danpalmer,

If I understand you correctly you want to run specific parts of a pipeline via the API, depending on paramters you provide in the API call. This is possible using what we call Conditional Worfklows, documented here: https://circleci.com/docs/2.0/pipeline-variables/#conditional-workflows

I hope this helps!

Regards,
Stig