43

I have this pipeline file to unittest my project:

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

but is it possible to switch to another docker image to deploy?

image: jameslin/python-deploy

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

I cannot seem to find any documentation saying either Yes or No.

James Lin
  • 25,028
  • 36
  • 133
  • 233

3 Answers3

103

You can specify an image for each step. Like that:

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
Dmitry Zaytsev
  • 23,650
  • 14
  • 92
  • 146
12

Finally found it:

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.

James Lin
  • 25,028
  • 36
  • 133
  • 233
  • "You can override the main Docker image by specifying an image in a step." - wheres the code for specifying? :D – Machado May 19 '17 at 12:19
  • Only issue with using multiple images is that each one still needs to be pulled down and spun up which can eat away at your allotted minutes. – isaac weathers Jan 17 '18 at 20:39
2

I have not found any information saying yes or no either so what I have assumed is that since this image can be configured with all the languages and technology you need I would suggest this method:

  1. Create your docker image with all utilities you need for both default and deployment.
  2. Use the branching method they show in their examples https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html#Configurebitbucket-pipelines.yml-ci_branchesbranches(optional)
  3. Use shell scripts or other scripts to run specific tasks you need and

enter image description here

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 
isaac weathers
  • 1,436
  • 4
  • 27
  • 52