CircleCI-Archived / api-preview-docs

In-progress docs about the pre-release preview of CircleCI API v2
72 stars 26 forks source link

Pipeline Parameters Ignored with API #67

Closed philnielsen closed 4 years ago

philnielsen commented 4 years ago

I'm having issues triggering jobs with pipeline parameters, I created a simplified example config to recreate. config.yml

version: 2.1
parameters:
  mark:
    type: boolean
    default: false

executors:
  go:
    docker:
      - image: circleci/golang

jobs:
  read-parameters:
    executor: go
    steps:
      - run: echo << pipeline.parameters.mark >>
workflows:
  version: 2
  if-mark:
    when: << pipeline.parameters.mark >>
    jobs:
      - read-parameters

  if-not-mark:
    unless: << pipeline.parameters.mark >>
    jobs:
      - read-parameters

Triggering with

curl -u "${CIRCLECI_BOT_TOKEN}:" -d '{"parameters":{"mark":true}}' -X POST https://circleci.com/api/v2/project/:PROJECTSLUG/pipeline

or

curl -u "${CIRCLECI_BOT_TOKEN}:" -d '{"parameters":{"mark":false}}' -X POST https://circleci.com/api/v2/project/:PROJECTSLUG/pipeline

always runs the if-not-mark, as configured above, but if I change the default value in the config it runs the if-mark, so I think it is an API issue.

Also I should add that i've been using this successfully before, so I think it is a regression with a recent behind the scenes update of v2. (I know its beta! 😁 )

ndintenfass commented 4 years ago

Can you try adding --header "Content-Type: application/json" to your curl, and see if that helps?

philnielsen commented 4 years ago

Whoops that was totally it, thanks 🙃