2
  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 的作业的定义

警告:此配置是自动生成的,用于向您显示上述消息。不要重新运行此作业。重新运行将没有效果。错误的

4

2 回答 2

2

看来您的缩进已关闭。publish-latest 应该像其他定义的工作一样缩进。

于 2019-06-05T07:48:20.647 回答
1

正如marxmacher 所提到的,它看起来像一个缩进错误。如果你有CircleCi CLI,你可以运行circleci config validate命令,它会在你的配置文件中显示任何问题。

于 2019-06-13T19:46:20.310 回答