Issues importing circleci orbs in my orb

Hello,

I’m working on creating a cicd orb for our organization to abstract away some of the complexity of setting up circleci pipelines in our organization. I would like to create an orb that combines jobs pulled from the circleci/gradle and circleci/docker orbs.

From looking here it appears we can import a job from another orb for use inside my orb:

orbs-within-orbs

When I try to do this inside my orb with the gradle orb I run into some issues.

  • When importing the gradle orb into my orb I’m able to specify I want to include the run and test jobs as described in the documentation. My orb validates as expected.

    orbs:
      gradle: circleci/gradle@2.1.0
    jobs:
      gradle-build: gradle/run
      gradle-test: gradle/test
    

    ╰─ circleci orb validate src/orb.yml
    Orb at src/orb.yml is valid.

  • If I specify ONLY my orb in a circleci config.yml and use the cicd-orb/gradle-test job alias I created when importing the job in my orb and try a “circleci config validate”, I get an error saying the gradle/run or gradle/test jobs are not defined. Even though they are clearly defined inside my orb.

    orbs:
      cicd-orb: drewtittle/cicd-orb@dev:alpha
    workflows:
      build:
        jobs:
          - cicd-orb/gradle-test
          - cicd-orb/gradle-build
    

    ╰─ circleci config validate
    Error: Error calling workflow: ‘build’
    Cannot find orb ‘gradle’ looking for job named ‘gradle/run’

  • If I add a line for the circleci/gradle orb to the orbs stanza of my config.yml it works normally.

    orbs:
      cicd-orb: drewtittle/cicd-orb@dev:alpha
      gradle: circleci/gradle@2.1.0
    workflows:
      build:
        jobs:
          - cicd-orb/gradle-test
          - cicd-orb/gradle-build
    

    ╰─ circleci config validate
    Config file at .circleci/config.yml is valid.

This defeats the purpose of creating an orb to abstract away complexity if you have to import the orbs inside your orb in any config.yml files that use it. I must be missing something.

When I do this inside my orb with the docker orb, I run into some other issues.

  • I am unable to import the docker/publish job inside my orb at all in the way described in the orbs-within-orbs link.

    orbs:
      docker: circleci/docker@1.0.1
    jobs:
      docker-publish: docker/publish
    
  • docker/publish has a required parameter “image”. When I have this job added to my orb, my orb will not validate with a “circleci orb validate src/orb.yml”. I get an error saying a required parameter ‘image’ is not specified.

    ╰─ circleci orb validate src/orb.yml
    Error: Error calling job: ‘docker/publish’
    Missing required argument(s): image

  • I tried several different ways to specify the image parameter where I am importing the job in my orb.

    docker-publish: docker/publish
      parameters:
        image:
          type: string
    
  • Everything I can think to try produces this error:

    ╰─ circleci orb validate src/orb.yml
    Error: Unable to parse YAML
    mapping values are not allowed here
    in ‘string’, line 23, column 15:
    parameters:
    ^

  • Even breaking out the job into it’s component commands and trying to add the job source code in my orb reveals the docker/push and docker/build commands also have a required parameter and specifying a parameter where these commands are imported also generates a similar error for the missing image argument. Adding a parameters field to the command import produces a similar error to the one above.

    ╰─ circleci orb validate src/orb.yml
    Error: Error calling command: ‘docker/push’
    Missing required argument(s): image
    Error calling command: ‘docker/build’
    Missing required argument(s): image

I’m not sure if there’s a way to accomplish what I’m trying to do but based on the documentation I linked above both these use cases should be supported. Particularly the first one.

1 Like