是否可以在 bitbucket 管道中使用多个 docker 图像?

Is it possible to use multiple docker images in bitbucket pipeline?

我有这个管道文件来对我的项目进行单元测试:

image: jameslin/python-test

    pipelines:
      default:
        - step:
            script:
              - service mysql start
              - pip install -r requirements/test.txt
              - export DJANGO_CONFIGURATION=Test
              - python manage.py test

但是是否可以切换到另一个 docker 映像进行部署?

image: jameslin/python-deploy

    pipelines:
      default:
        - step:
            script: 
              - ansible-playbook deploy

我似乎找不到任何说明是或否的文档。

终于找到了:

https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html#Configurebitbucket-pipelines.yml-ci_stepstep(required)

step (required) Defines a build execution unit. Steps are executed in the order in which they appear in the pipeline. Currently, each pipeline can have only one step (one for the default pipeline and one for each branch). You can override the main Docker image by specifying an image in a step.

我没有找到任何信息说是或否,所以我假设是因为可以使用您需要的所有语言和技术配置此图像,所以我建议使用此方法:

  1. 使用默认和部署所需的所有实用程序创建 docker 映像。
  2. 使用他们在示例中显示的分支方法https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html#Configurebitbucket-pipelines.yml-ci_branchesbranches(optional)
  3. 使用 shell 脚本或其他脚本来 运行 您需要的特定任务和

image: yourusername/your-image

pipelines:
 branches:
  master:
  - step:
      script: # Modify the commands below to build your repository.
        - echo "Starting pipelines for master"
        - chmod +x your-task-configs.sh #necessary to get shell script to run in BB Pipelines
        - ./your-task-configs.sh
feature/*:
  - step:
      script: # Modify the commands below to build your repository.
        - echo "Starting pipelines for feature/*"
        - npm install
        - npm install -g grunt-cli
        - npm install grunt --save-dev
        - grunt build 

您可以为每个步骤指定一张图片。像这样:

pipelines:
  default:
    - step:
        name: Build and test
        image: node:8.6
        script:
          - npm install
          - npm test
          - npm run build
        artifacts:
          - dist/**
    - step:
        name: Deploy
        image: python:3.5.1
        trigger: manual
        script:
          - python deploy.py