How to trigger job (circle v2.0) from command line

I wanna start circle job(v 2.0) from other circle job(v 2.0).

I try to use curl -X POST --header “Content-Type:application/json” https://circleci.com/api/v1.1/project/github/BLA_BLA_BLA/tree/master?circle-token=OPS

But on circleci job I have error:

Build-agent version 0.0.7288-1e94a694 (2018-07-06T16:07:08+0000)
Configuration errors: 1 error occurred:

  • Cannot find a job named build to run in the jobs: section of your configuration file.
    If you expected a workflow to run, check your config contains a top-level key called ‘workflows:’

Using ‘api/v2’ and ‘api/v2.0’ can’t help.

regarding this I have question: Is it possible to run on circle job (v 2) form other job (v 2) or its solution only for v1.1???

My config like this:

version: 2
jobs:
  all-tests:
    macos:
      xcode: "9.4.0"
...
workflows:
  version: 2
  build-test-adhoc:
    jobs:
        - all-tests

My guess is that since you are triggering a job and not a workflow via the API, the job has to be called “build”, otherwise it would not know which job to call.

1 Like

Yes!!! it’s working after specify job name for run (CIRCLE_JOB)

 curl -X POST --header "Content-Type:application/json" --data '{"build_parameters": {"CIRCLE_JOB": "all-tests"}}' https://circleci.com/api/v1.1/project/BLA_BLA_BLA 
1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.