Orbs - "Cannot find a definition for command named ..."

I’m able to use my orb with this config.yml:

orbs:
  ssh-deployment: arturgontijo/ssh-deployment@dev:0.0.1

workflows:
    service-1:
        jobs:
        - ssh-deployment/deploy:
            ssh-host: ${SSH_HOST}
            ssh-user: ${SSH_USER}
    service-2:
        jobs:
        - ssh-deployment/deploy:
            ssh-host: ${SSH_HOST}
            ssh-user: ${SSH_USER}

version: 2.1

But not with this one:

version: 2.1
orbs:
  ssh-deployment: arturgontijo/ssh-deployment@dev:0.0.1
jobs:
  service-1:
    docker:
      - image: 'circleci/python:3.7.1'
    steps:
      - ssh-deployment/deploy:
          ssh-host: ${SSH_HOST}
          ssh-user: ${SSH_USER}
  service-2:
    docker:
      - image: 'circleci/python:3.7.1'
    steps:
      - ssh-deployment/deploy:
          ssh-host: ${SSH_HOST_2}
          ssh-user: ${SSH_USER_2}
workflows:
  test-services:
    jobs:
      - service-1
      - service-2

I’m getting the Cannot find a definition for command named ssh-deployment/deploy error.

Does the second approach only work with “official” orbs?

I’ve figured it out!

In order to use the orb in both ways you need to set up #1 and #2 with same name, like:

commands:
  deploy: # ----> #1
    description: |
      Deploying...
    parameters:
      ssh-user:
        type: string
      ssh-host:
        type: string
    steps:
      - run:
          name: Setting Up
          command: |
            ...
      - run:
          name: Removing old Docker Container (Previous Builds)
          command: |
            ...

jobs:
  deploy: # ----> #2
    description: Deploy a Docker image from a Github repository on a remote server using SSH.
    docker:
      - image: circleci/python:3.6.6-node
    parameters:
      ssh-user:
        description: The remote SSH username.
        type: string
      ssh-host:
        description: The remote SSH host.
        type: string
    steps:
    - checkout
    - deploy:
        ssh-user: << parameters.ssh-user >>
        ssh-host: << parameters.ssh-host >>

version: 2.1

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