我有这个管道文件来对我的项目进行单元测试:
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
我似乎找不到任何说明“是”或“否”的文档。
您可以为每个步骤指定一个图像。像这样:
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
终于找到了:
step(必需)定义构建执行单元。步骤执行于 它们在管道中出现的顺序。目前,每个 管道只能有一个步骤(一个用于默认管道,一个用于 对于每个分支)。您可以通过指定来覆盖主 Docker 映像 一步一步生成图像。
我还没有找到任何表明是或否的信息,所以我假设的是,由于该图像可以使用您需要的所有语言和技术进行配置,所以我建议使用这种方法:
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
从 2024 年开始,您可以“从构建管道运行多个 Docker 容器” https://support.atlassian.com/bitbucket-cloud/docs/databases-and-service-containers/
服务在 bitbucket-pipelines.yml 文件的定义部分中定义。
default:
# "Build step is allocated 4096 MB of memory"
- step:
services:
- redis
- mysql
- docker
script:
- echo "Build container is allocated 2048 MB of memory"
- echo "Services are allocated the memory configured. docker 512 MB, redis 512 MB, mysql 1024 MB"
definitions:
services:
redis:
image: redis:3.2
memory: 512
docker:
memory: 512 # reduce memory for docker-in-docker from 1GB to 512MB
mysql:
image: mysql:5.7
# memory: 1024 # default value
variables:
MYSQL_DATABASE: my-db
MYSQL_ROOT_PASSWORD: $password