Circleci:找不到名为publish-latest的作业的定义

时间:2019-04-02 15:51:26

标签: yaml circleci circleci-2.0 circleci-workflows

  version: 2.1
  executors:
    docker-publisher:
      environment:
        IMAGE_NAME: mocking-service
      docker:
        - image: circleci/buildpack-deps:stretch
  jobs:
    build:
       executor: docker-publisher
       steps:
         - checkout
         - setup_remote_docker
         - run:
            name: Build Docker image
            command: |
              docker build -t $IMAGE_NAME:latest .
         - run:
            name: Archive Docker image
            command: docker save -o mocking.tar $IMAGE_NAME
         - persist_to_workspace:
              root: .
              paths:
                - ./mocking.tar
  publish-latest:
      executor: docker-publisher
      steps:
        - attach_workspace:
            at: /tmp/workspace
        - setup_remote_docker
        - run:
            name: Load archived Docker image
            command: docker load -i /tmp/workspace/mocking.tar
        - run:
            name: Publish Docker Image to Docker Hub
            command: |
                  echo "$DOCKER_HUB_PASSWORD" | docker login -u "$DOCKER_HUB_USERNAME" --password-stdin
                  docker push docker.kfz42.de/v2/java/mocking-service/$IMAGE_NAME:latest .
  workflows:
    version: 2
    build-master:
      jobs:
        - build:
            filters:
             branches:
               only: master
        - publish-latest:
            requires:
              - build
            filters:
              branches:
                only: master

有人可以告诉我我在做什么错吗? 当我尝试通过circleci运行此Yaml文件时出现以下错误

  

!/ bin / sh -eo pipefail调用工作流时出错:“ build-master”无法   查找名为publish-latest

的作业的定义      

警告:此配置已自动生成以向您显示消息   以上。不要重新运行这项工作。重新运行将无效。错误

2 个答案:

答案 0 :(得分:0)

您的缩进似乎已关闭。应该像其他已定义的作业一样缩进publish-latest。

答案 1 :(得分:0)

正如marxmacher提到的那样,它看起来像是缩进错误。如果您拥有CircleCi CLI,则可以运行circleci config validate命令,该命令将向您显示配置文件中的所有问题。