无法触发自定义(手动)Bitbucket 管道

Unable to trigger custom (manual) Bitbucket Pipeline

提问人:Alooza 提问时间:10/23/2023 更新时间:10/24/2023 访问量:60

问:

我正在尝试让自定义 bitbucket 管道工作。这是我的bitbucket-pipelines.yml

我为自动管道所做的相同步骤工作正常。我只是想让手动管道工作。

我还检查了文档,似乎没有提到任何内容import

image: atlassian/default-image:3

pipelines:
  custom:
    staging-deploy:
      deploy:
        - step:
          name: Deploy to DockerHub
          services:
            - docker
          script:
            - export IMAGE_NAME=$DOCKER_HUB_USERNAME/$PROJECT_NAME:$BITBUCKET_COMMIT
            - docker build -t $IMAGE_NAME .
            - docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD
            - docker push $IMAGE_NAME
        
        - step:
          name: Deploy to Droplet
          script:
            - export IMAGE_NAME=$DOCKER_HUB_USERNAME/$PROJECT_NAME:$BITBUCKET_COMMIT
            - pipe: atlassian/ssh-run:0.6.1
              variables:
                SSH_USER: $SSH_USER
                SERVER: $SSH_SERVER
                COMMAND: 'docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD; docker pull $IMAGE_NAME; docker stop $PROJECT_NAME; docker rm $PROJECT_NAME; docker run -d --restart always --name $PROJECT_NAME -p $SERVER_PORT:$SERVER_PORT $IMAGE_NAME; docker image prune -a -f'

上下文

  1. 构建镜像并将镜像推送到 DockerHub
  2. SSH 到 DO Droplet 并从 DockerHub 拉取映像并运行映像

但是当我尝试在管道 UI 中触发它时,我收到此错误

There is an error in your bitbucket-pipelines.yml at [pipelines > custom > staging-deploy]. Required attributes are not set: import 
Find out more

Bitbucket Pipeline error

bitbucket-pipelines

评论


答:

0赞 Alooza 10/24/2023 #1

我需要解决的 2 件事

pipelines:
  custom:
    staging-deploy:
      deploy:    # This need to be remove
        - step:
          name: Deploy to DockerHub # This need 2 indent
          services:
            - docker

以下是固定的 YAML

pipelines:
  custom:
    staging-deploy:
      - step:
          name: Deploy to DockerHub # This have 2 indent (very important)
          deplyment: staging
          services:
            - docker