Skip to content

Pipeline YAML Format

Jasmeet Singh edited this page Jan 30, 2018 · 22 revisions

Introduction

This page describes the pipeline YAML support implemented to support DevOps open toolchains. It is used in the Deploy to IBM Cloud Button (D2IC) flow to enable creation of samples that contain pipelines using Docker container extensions. The feature is currently only available for hosted git (Git Repos and Issue Tracking) and GitHub projects targeting IBM Cloud.

Basics

If a pipeline yaml file is present in the toolchain template repository or in a D2IC  sample, a pipeline based on that description will be created (and the first stage executed) as part of the D2IC flow. The name of the yaml file is pipeline.yml and it must be located in a folder called .bluemix: .bluemix pipeline.yml

YAML Format

The yaml format is a single yaml document containing a pipeline specification. Here is the pipeline.yml to build and deploy nodejs application to IBM Cloud

---
stages:
- name: Build Stage
  inputs:
  - type: git
    branch: ${BRANCH}
    service: ${REPO}
  jobs:
  - name: Build
    type: builder
    artifact_dir: ''
- name: Deploy Stage
  inputs:
  - type: job
    stage: Build Stage
    job: Build
  triggers:
  - type: stage
  jobs:
  - name: Deploy
    type: deployer
    target:
      region_id: ${CF_REGION_ID}
      organization: ${CF_ORGANIZATION}
      space: ${CF_SPACE}
      application: ${CF_APP}
    script: |-
      #!/bin/bash
      cf push "${CF_APP}"
      # View logs
      # cf logs "${CF_APP}" --recent

The above yaml contains the references to environment variables (enclosed with ${}) which are defined in the Pipeline service definition of toolchain yml . The pipeline service definition also contains the other parameters required to add pipeline to the toolchain.

services:
  repo:
    service_id: hostedgit
    parameters:
      repo_name: '{{toolchain.name}}'
      repo_url: '{{repository}}'
      type: clone
      has_issues: true
      enable_traceability: true
  build:
    service_id: pipeline
    parameters:
      services:
        - repo
      name: '{{toolchain.name}}'
      ui-pipeline: true
      configuration:
        content:
          $text: pipeline.yml
        env:
          REPO: repo
          BRANCH: '{{branch}}'
          CF_APP: '{{form.pipeline.parameters.app-name}}'
          CF_SPACE: '{{space}}'
          CF_ORGANIZATION: '{{organization}}'
          CF_REGION_ID: '{{region}}'
        execute: true

The "REPO" environment variable references the repository service, which defines whether we want to include Github or GRIT integration.

Syntax

Pipeline

 

---
stages:

<sequence of stages>

Stage

name: <name>

[inputs:
  <sequence of inputs>]

[triggers:
  <sequence of triggers>]

[properties:
  <sequence of properties>]
[jobs:
  <sequence of jobs>]

Input

type: 'git' | 'job'

[branch: <branch name>]   ; only for git inputs

[service: <github/GRIT service definition>] ;can be referenced through environment variable
stage: <stage name>   ; only for job inputs

job: <job name>       ; only for job inputs