API v2: Is it possible to retrieve the parameters that were passed in?

I’ve looked through the API v2 response schemas for each of the following:

  • GET /pipeline/{pipeline-id}
  • GET /workflow/{id}
  • GET /project/{project-slug}/job/{job-number}

I’d like to be able to retrieve the parameters that were passed into a pipeline (or workflow or job), but I’m not seeing “parameters” in any of these schemas.

Apologies if I’m missing it, but is there a way to retreive those?

2 Likes

Hey there @dale.francum,

You can access the pipeline parameters passed in VIA the API using the parameters definition inside your config.yml.

See the below example:

version: 2.1
parameters:
  image-tag:
    type: string
    default: "latest"
  workingdir:
    type: string
    default: "~/main"

jobs:
  build:
    docker:
      - image: circleci/node:<< pipeline.parameters.image-tag >>
    environment:
      IMAGETAG: << pipeline.parameters.image-tag >>
    working_directory: << pipeline.parameters.workingdir >>
    steps:
      - run: echo "Image tag used was ${IMAGETAG}"
      - run: echo "$(pwd) == << pipeline.parameters.workingdir >>"

Here we define image-tag and workingdir, which are passed in using the Trigger a new pipeline endpoint. Then we can access them from the build using << pipeline.parameters.image-tag >>.

More information on using these paramters are available on this doc: Pipeline Variables

Hey Scott, thanks for the response. I actually meant accessing them via an API call.

Hey @dale.francum!

Apologies for misunderstanding, that isn’t available in the current API. I welcome you to create a feature request on our idea’s board: https://ideas.circleci.com

It is weird because as you can see on the CircleCI v2 API docs for the GET /pipeline/:pipeline-id it does mention a trigger_parameters property. But from my tests, it never returns anything. Maybe someone from CircleCI team can provide some insights here.

It is especially frustrating here because I need to consume the results of a pipeline from my webhooks handler and CircleCI sends only the pipeline id as part f the webhook payload, not the parameters so I need an API to retrieve it

1 Like

The same question. How to get trigger_parameters via API?

I’ll flag this to the staff member who runs the volunteer members program so that some feedback from someone in the development team could be possible.

1 Like

Thanks for flagging @rit1010

I just ran a quick test looking at a pipeline with parameters set and unset and can confirm that trigger_parameters isn’t showing - will check with internal teams & get back to you!

Hi everyone,

Looks like we have miscommunicated in the API docs, sorry.

Trigger Parameters will only show up in the responses for our GitLab pipelines and our upcoming GitHub App pipelines.
Existing GitHub Oauth pipelines that most of you are likely using are using what we call Pipeline Parameters, and they are only available from within pipelines themselves.

We are updating the docs accordingly.

1 Like

It means, it isn’t possible to use << pipeline.trigger_parameters.circleci.project_id >> or even "<< pipeline.trigger_parameters.circleci.event_time >> when my project is set on Github ?

Hi @jefflemos-ezy, here you can find the currently supported trigger parameters for all different types of projects:

circleci.project_id is not supported, but circleci.event_time is supported for Gitlab and Github App type projects.

Hope this helps!

1 Like