【问题标题】:Is it possible to use multiple docker images in bitbucket pipeline?是否可以在 bitbucket 管道中使用多个 docker 图像?
【发布时间】:2017-03-03 04:02:27
【问题描述】:

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

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

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

【问题讨论】:

    标签: bitbucket-pipelines


    【解决方案1】:

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

    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
    

    【讨论】:

    • 我可以在一个步骤中有多个图像吗?
    • @SuganthanMadhavanPillai afaik 这是不可能的,每一步都在一个图像上运行
    • @DmitryZaytsev 这种情况下如何定义部署?
    • 在一个步骤中利用多个图像的一种方法可能是使用服务? support.atlassian.com/bitbucket-cloud/docs/…
    【解决方案2】:

    终于找到了:

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

    step(必需)定义构建执行单元。步骤在 它们在管道中出现的顺序。目前,每 管道只能有一个步骤(一个用于默认管道,一个用于 每个分支)。您可以通过指定覆盖主 Docker 映像 一步中的图像。

    【讨论】:

    • "您可以通过在一个步骤中指定一个镜像来覆盖主 Docker 镜像。" - 指定代码在哪里? :D
    • 使用多张图片的唯一问题是,每张图片仍然需要拉下并旋转起来,这可能会占用您分配的分钟数。
    【解决方案3】:

    我还没有找到任何信息说是或否,所以我假设由于这个图像可以配置你需要的所有语言和技术,我建议这种方法:

    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 
    

    【讨论】:

      猜你喜欢
      • 2020-07-20
      • 1970-01-01
      • 2021-05-25
      • 2020-03-25
      • 1970-01-01
      • 2021-06-16
      • 1970-01-01
      • 2021-08-15
      • 2017-11-06
      相关资源
      最近更新 更多