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

问题描述 投票:0回答:1

我正在尝试让自定义 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 拉取映像并运行该映像

但是当我尝试在 Pipeline 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 bitbucket-pipelines
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

更新(2024 年 5 月)

这不会创建新的管道,只会手动触发

stages:
- build

staging:
  stage: build
  rules: 
    - if: $CI_PIPELINE_SOURCE == 'web'
    when: always
  script:
    - echo "Running project job..."
© www.soinside.com 2019 - 2024. All rights reserved.