Triggering Builds from Local Config Files

I have been triggering CircleCI jobs from my local config files dynamically.
The post below has helped me a lot in it.
@fernfernfern

“I tried to put in the link, but it isn’t allowing me to”

However, recently I am unable to pass any build_parameters to the config files. Though a curl request triggers the job with the correct config.yml , it doesn’t pass any environment variable to it. They are all empty.

This is the curl request that I have used till now :

curl -X POST  -H "Circle-Token: CIRCLE_TOKEN" \
--form "config=@/path_to_config_file/test.yml" \
--form "build_parameters[environment_var_name]=ENVIRONMENT_VALUE" \
https://circleci.com/api/v1.1/project/github/{user_name}/{repo_name}/tree/{branch_name}

In test.yml , a step of echo $environment_var_name outputs an empty string. It should have printed ENVIRONMENT_VALUE

Any help is greatly appreciated.

Thank you.

If you are able to receive “test.yml” as a
Can you also post your test.yml or at least a shortened version that shows the issue?

In terms of the original post by @fernfernfern you are working from, was it

Being so old it is not possible to tell how the API was documented back then, but currently the API docs detail this endpoint rather differently.

Yes, it is indeed the post.

I won’t be able to post the original test.yml, however, here is the shortened version of it.

version: 2
jobs:
  build:
    working_directory: ~/code
    docker:
            - image: cimg/python:2.7.16
    resource_class: small
    steps:
      - run:
         name: Running step
         command:  |
          echo $environment_var_name
          echo "Echo is working"

This one is triggered properly. However, environment_var_name is empty.

[Update]

CircleCI has pushed a fix for v1.1 API endpoint, and this feature has started working again.

However, a similar feature still is pending from v2.

Hi @RounakDas02 .
We have actually just released a new feature in Closed Preview that might achieve in a very different way what you are trying to do here.
You can trigger pipelines from VS Code based on your local config.yml, and even select which specific jobs you want to run.
Have a look here and see if it sounds like it’d solve your problem

1 Like