Why?

This example shows how to have multiple versions of a language, environment, or dependency fetched and integrated in to a Pipeline.

For these Docker images, defining them as Resources has two advantages for this use case. First, this enables the pipeline to be triggered when there are new versions of those images available. Second, referencing them in the task's image param is helpful as it will ensure consistency between the image versions fetched by the Resource and the image version running in the job.

2.9 Golang library testing example

You can run the tests for a Golang library across any specified versions.

Pipeline Configuration

---
resources:
  - name: golang-mock-git
    type: git
    icon: github-circle
    source:
      uri: https://github.com/golang/mock.git

  - name: golang-1.11.x-image
    type: registry-image
    icon: docker
    source:
      repository: golang
      tag: 1.11-stretch

  - name: golang-1.10.x-image
    type: registry-image
    icon: docker
    source:
      repository: golang
      tag: 1.10-stretch

  - name: golang-1.9.x-image
    type: registry-image
    icon: docker
    source:
      repository: golang
      tag: 1.9-stretch

task-config: &task-config
  platform: linux
  inputs:
    - name: golang-mock-git
      path: /go/src/github.com/golang/mock
  run:
    path: /bin/sh
    args:
      - -c
      - |
        SRCPATH=$PWD/go/src/github.com/golang/mock
        GOPATH=$PWD/go
        cd $SRCPATH
        go get -t -v ./...
        go test -v ./...

jobs:
  - name: golang-1.11
    public: true
    plan:
      - get: golang-mock-git
        trigger: true
      - get: golang-1.11.x-image
        trigger: true
      - task: run-tests
        image: golang-1.11.x-image
        config:
          << : *task-config
  - name: golang-1.10
    public: true
    plan:
      - get: golang-mock-git
        trigger: true
      - get: golang-1.10.x-image
        trigger: true
      - task: run-tests
        image: golang-1.10.x-image
        config:
          << : *task-config
  - name: golang-1.9
    public: true
    plan:
      - get: golang-mock-git
        trigger: true
      - get: golang-1.9.x-image
        trigger: true
      - task: run-tests
        image: golang-1.9.x-image
        config:
          << : *task-config

References