doutan8506 2019-05-23 13:46
浏览 97

如何将.yml作业脚本制作为单个任务,而该任务是其他步骤的一部分?

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?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?