Search code examples
continuous-integrationcontinuous-deploymentcirclecicontinuous-deliverycircleci-orb

CircleCI: Cannot find a definition for executor named ubuntu?


I am trying to extend the orb that is already in use. We have used Docker before but now want to use a machine executor and maybe a windows executor in the future. I go through the documentation, but it is not clear if it is possible to have executors of different types and call them on the same jobs.

Is it possible to have executors of different types in the same orb in CircleCI?

I tried creating the executor ubuntu.yml:

description: >
  The executor to run testcontainers without extra setup in Circle CI builds.

parameters:
  # https://circleci.com/docs/2.0/configuration-reference/#resource_class
  resource-class:
    type: enum
    default: medium
    enum: [medium, large, xlarge, 2xlarge]

  tag:
    type: string
    default: ubuntu-2004:202010-01

resource_class: <<parameters.resource-class>>

machine:
  image: <<parameters.tag>>

Another executor, openjdk.yml:

description: >
  The default executor for our OpenJDK + Maven-based builds.

parameters:
  # https://circleci.com/docs/2.0/configuration-reference/#resource_class
  resource-class:
    type: enum
    default: medium
    enum: [small, medium, medium+, large, xlarge]

  tag:
    type: string
    default: 11.0-jdk-stretch

resource_class: <<parameters.resource-class>>

docker:
  - image: circleci/openjdk:<<parameters.tag>>

The beginning of my job is:

parameters:
  executor:
    type: executor
    default: openjdk
  resource-class:
    type: enum
    default: medium
    enum: [small, medium, medium+, large, xlarge]

executor: << parameters.executor >>
resource_class: << parameters.resource-class >>

environment:
  # Customize the JVM maximum heap limit
  MAVEN_OPTS: -Xmx3200m

How can I reference my ubuntu executor so that it can be visible by other orbs?


Solution

  • There 3 types of executors invocation in Circle CI:

    • Call CircleCI predefined images such as ruby, openjdk.
    • Invoke executors from the same config file/orb such as my-openjdk, my-executor.

    For example,

    executors:
      my-executor:
        machine: true
      my-openjdk:
        docker:
          - image: openjdk:11
    
    • Invoke executors from the existing orbs such as <orb-name>/<executor-name>.

    In my case, it was the 3rd option, my-orb/ubuntu.