How can I make a .yml job script as a single task that's part of a pipeline with other steps?

5/23/2019

I am new to Azure DevOps and Go.

I am trying to plug in the following .yml Go test execution as a stand-alone .yml step. This yaml works fine as a standalone Pipeline, but I need to make it a YAML step of the pipeline. (I only want to have one pipeline, and my existing pipeline is not just a azure-pipelines.yml file, but is composed of Azure DevOps templates for Docker and ACRs). (Each of those steps has it's own YAML which you can only view and not edit. I.E. auto-generated)

The YAML for running Go tests only

trigger:
  branches:
    include:
      - master
  paths:
    include:
      - /cmd/*
pool:
  vmImage: 'Ubuntu-16.04'

variables:
  GOBIN:  '$(GOPATH)/bin' # Go binaries path
  GOROOT: '/usr/local/go1.12.1' # Go installation path
  GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
  modulePath: '$(GOPATH)/src/azure.com/myproject' # Path to the module's code

steps:
- script: |
    mkdir -p '$(GOBIN)'
    mkdir -p '$(GOPATH)/pkg'
    mkdir -p '$(modulePath)'
    shopt -s extglob
    mv !(gopath) '$(modulePath)'
    cd gopath/src/azure.com/myproject/
  displayName: 'Set up the Go workspace'

- script: |
    go get -v -t -d ./...
  workingDirectory: '$(modulePath)'
  displayName: 'go get dependencies'

- script: go test -v ./...
  workingDirectory: '$(modulePath)'
  displayName: 'Run tests'

So this works when I make it as a seperate pipeline, but I couldn't find how I can plug in this step as a seperate yml step of an existing pipeline.

I have built a Go pipeline in Azure Devops, that has individual steps, that each uses an appropriate azure devops template:

enter image description here

  • My current pipeline:

  • Clones the source repo (from Azure.com)

  • Builds a docker image

  • Pushes the docker image to our ACR

So I want to add a "Run Tests" script with the YML script I included above (minus the Triggers obviously), as a preliminary step, before the docker container is built.

I went over all Azure DevOps Pipeline templates, and evaluated Task Groups, Bash scripts or Azure CLI steps, but none of them can be defined in YAML.

One option, I believe is to convert the above YAML to a bash script.
But I want to know if I can just run YAML steps as part of a pipeline, as a seperate dedicated step?

-- FranticRock
azure
azure-devops
azure-kubernetes
azure-pipelines
go

0 Answers