Search code examples
circleciorb

CircleCI validation using orb: Cannot find a definition for job


I have created a circleci orb dev and published it:

>circleci orb publish myorb.yml mynamespace/myorb@dev:alpha2
Orb `mynamespace/myorb@dev:alpha2` was published.
Please note that this is an open orb and is world-readable.
Note that your dev label `dev:alpha2` can be overwritten by anyone in your organization.
Your dev orb will expire in 90 days unless a new version is published on the label `dev:alpha2`.

As I found it is not possible to see the dev orbs under registery, I have tried to use cli for listing it, here is what I get:

 >circleci orb list vydev --uncertified
 Orbs found: 1. Includes all certified and uncertified orbs.

 mynamespace/myorb (Not published)

When I try to check the validation of my config.yml file I get this error:

 >circleci config validate
 Error: Error calling workflow: 'myworkflow'
 Cannot find a definition for job named myorb/job1

Here is myorb.yml file:

version: 2.1
description: My orb

commands:
  job1:
    description: "job1"
    steps:
      - checkout:
          path: ~/repo
      - run:
          name: Validate code
          command: |
            printf "Validating code\n"
        
  job2:
    steps:
      - checkout:
          path: ~/repo
      - run:
          name: Zip source code
          command: |
            s3_prefix="$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/branches/$CIRCLE_BRANCH"
            sha1="$(echo $CIRCLE_SHA1 | cut -c -7)"
            ls -al
            more commands
      - persist_to_workspace:
          root: ./
          paths:
            - "*"
  job3:
    steps:
      - attach_workspace:
          at: /tmp/workspace
      - run:
          name: Upload source to S3
          command: |
            s3_bucket="mybucket"
            ls -al
            more commands

executors:
  exe1:
    description: using defined version 
    parameters:
      version:
        type: string
        default: ${version} 
        description: Version of code
    docker:
      - image: << parameters.version >>
    working_directory: /tmp/workspace
  exe2:
    description: buildpackages
    docker:
      - image: myimage:latest 
    working_directory: /tmp/workspace   
  exe3:
    description: using ECR CLI
    docker:
      - image: myimage:v1
    working_directory: /tmp/workspace

and config.yml is as shown below:

version: 2.1
orbs:
  myorb: mynamespace/myorb@dev:alpha2
workflows:
  myworkflow:
    jobs:
      - myorb/job1:
          executor: 
            name: myorb/exe1
            version: 0.12.24
          filters:
            branches:
              only: master
      - myorbm/job2:
          executor: 
            name: myorb/exe2
          filters:
            branches:
              only: master
      - myorb/job3:
          executor: 
            name: myorb/exe3
          filters:
            branches:
              only: master
          requires:
            - myorb/job1
            - myorb/job2

Does anyone know what it is missing here?

Any help would be appreciated.


Solution

  • In the example you have provided, you are defining commands and naming them as if they were jobs.

    The error is stating there is no jobs under that name, as there is not. There is however commands.

    Commands must be used within jobs.

    https://circleci.com/docs/2.0/orbs-faq/#difference-between-commands-and-jobs

    How to author a job: https://circleci.com/docs/2.0/reusing-config/#authoring-parameterized-jobs

    Live Examples:

    Node "test" Job: https://github.com/CircleCI-Public/node-orb/blob/master/src/jobs/test.yml

    Node "install-packages" Command: https://github.com/CircleCI-Public/node-orb/blob/master/src/commands/install-packages.yml