首页 > 其他分享 >ADS 流水线模板

ADS 流水线模板

时间:2022-12-16 15:58:39浏览次数:64  
标签:displayName ADS parameters script 模版 yaml buildConfiguration 流水线 模板

经典模式

Azure Devops Server 2019 , Team Foundation Server 2018
另存为模版即可
可以在模版上管理权限,比如不能修改模版
但是继承模版后依然可以随意调整

Yaml文件模式

使用引用其他git库的yaml文件,可以编写通用的模版,并可以实现yaml模版被引用后,模版中的步骤不能跳过 也不能被篡改。

Azure Devops Server 2019

新建模版库,创建yaml文件

# core-template.yml
# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

parameters:
- name: buildConfiguration
  type: string
  default: Release
  values: 
  - Release
  - Debug

- name: buildSteps # the name of the parameter is buildSteps
  type: stepList # data type is StepList
  default: [] # default value of buildSteps

#steps:
#- script: dotnet build --configuration ${{ parameters.buildConfiguration }}
#  displayName: 'dotnet build ${{ parameters.buildConfiguration }}'

stages:
- stage: secure_buildstage
  pool: Default
  jobs:
  - job: secure_buildjob
    steps:
    - script: echo This happens before code 
      displayName: 'Pre-build'

    - script: dotnet build --configuration ${{ parameters.buildConfiguration }}
      displayName: 'dotnet build ${{ parameters.buildConfiguration }}'

    - ${{ each step in parameters.buildSteps }}:
      - ${{ each pair in step }}:
          ${{ pair.key }}: ${{ pair.value }}       
       
    - script: echo This happens after code
      displayName: 'Complete'

引用模版的yaml
新建管道

选择yaml类型

# Repo: PipelineTemplateTest/PipelineTemplateTest
# File: azure-pipelines.yml

# 从其他的azure devops repos库中引用
resources:
  repositories:
    - repository: templates
      type: git
      name: YamlTemplate/YamlTemplate  # 项目名称 / 存储库名称

trigger: 
- master

pool: 
  name: 'Default' 

# 导入模版,并设置变量的值
extends:
  template: core-template.yml@templates # yaml文件的名称 @ 上面申明的模版库名称
  parameters:
      buildConfiguration: 'Debug'
      buildSteps:  
        - script: echo Test 
          displayName: test succeed
        - task: CmdLine@2
          displayName: Test 3 - Will Fail
          inputs:
            script: echo "Script Test"

流水线运行结果

Team Foundation Server 2018

不具备创建yaml类型管道的功能

参考资料
https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops#use-other-repositories

标签:displayName,ADS,parameters,script,模版,yaml,buildConfiguration,流水线,模板
From: https://www.cnblogs.com/smallidea/p/16987556.html

相关文章

  • 零基础学 Vue + Element UI 第01步 —— 搭建开发环境、创建项目、修改默认模板、启动
    通过对《零基础学前端系列教程|和前端谈恋爱的第001–006天》的学习,我们已经基本掌握了HTML的核心标签,CSS的常见样式,对Javascript也略有接触。零基础学前端系列教程|......
  • 美化模板测试
    标题一dsadasdfsadasasd打防守打法第三方s发生大幅度标题二正式服是这是大V早上的招待费GV个大概富商大贾个反的个个公司搞法高富帅搞法苟富贵发搞法苟富贵发个施工......
  • 子矩阵的和【模板题】
    子矩阵的和输入一个n行m列的整数矩阵,再输入q个询问,每个询问包含四个整数\(x1,y1,x2,y2\),表示一个子矩阵的左上角坐标和右下角坐标。对于每个询问输出子矩阵中所有......
  • 前缀和【模板题】
    前缀和输入一个长度为n的整数序列。接下来再输入m个询问,每个询问输入一对l,r。对于每个询问,输出原序列中从第l个数到第r个数的和。输入格式第一行包含两个整......
  • 刷题笔记 | 算法模板题-回文判定
    题目描述给定一个长度为n的字符串S。请你判断字符串S是否回文。输入描述输入仅1行包含一个字符串S。\(1\leq|S|\leq10^6\),保证S只包含大小写、字母。输......
  • 【《硬件架构的艺术》读书笔记】06 流水线的艺术(1)
    6.1介绍流水线通过在较长的组合逻辑路径中插入寄存器降低了组合逻辑延迟,增加了时钟频率并提高了性能。 图中分别为插入流水线前后的逻辑。长路径插入寄存器后最大时钟......
  • PhpSpreadsheet 使用总结
    读取文件1$spreadsheet=IOFactory::createReader('Csv')//传文件类型首字母大写->setReadDataOnly(true)//设置为只读取数据->setReadEmptyCells(false)//不......
  • Django之模板层
    Django之模板层目录Django之模板层模板语法传值模板层之标签自定义过滤器、标签及inclusion_tag模板的继承与导入模型层之前期准备ORM常用关键字模板语法传值方法一、#......
  • django框架模板层——标签、自定义过滤器、标签、inclusion_tag、继承与导入、外键字
    django框架模板层——标签、自定义过滤器、标签、inclusion_tag、继承与导入、外键字段、外键字段数据增删改查一、模板层之标签{%if条件1(可以是自己写的条件,也可以是......
  • Excel数据导入(有模板)
    项目经常有这个需求:提前设置好excel模板,然后把模板中的数据解析出来并存到数据库本次示例中的excel模板中有4页(sheet1、sheet2、sheet3、sheet4),要把每一页的数据都解析出......