bamboobamboo-specs

Use docker in bamboo specs


I'm trying to use docker to build NPM projects with Bamboo. How do I do it?

---
version: 2
plan:
  project-key: WEBSITE
  name: Build
  key: BD

stages:
  - Lint and Test:
      - Lint
  - Build Artifact:
      - Build Artifact
  - Publish Image:
      - Publish Image


Lint:
  tasks:
    - script:
        - npm install
        - npm lint
      dockerImage: node:alpine


Build Artifact:
  tasks:
    - script:
        - ${bamboo_capability_system_builder_npm} install
        - ${bamboo_capability_system_builder_npm} run build
    - script:
        - cp -r content build/
        - cp release/* build/
  requirements:
    - node
  artifacts:
    - name: release
      pattern: build/**

Publish Image:
  tasks:
    - artifact-download:
        source-plan: WEBSITE-BD
        artifacts:
          - name: release

Bamboo throws error:

Bamboo YAML import failed: Document structure is incorrect: Lint / tasks / [0]: Task must have its type defined as the only YAML property

Solution

  • The spec should read:

    Lint:
      tasks:
        - script:
            - npm install
            - npm run lint
      docker:
        image: node:alpine