Azure Devops中的variable group建议或者只能(?)添加string类型的value。基于此我们想在variable group实现array或者hashtable的传递的核心思路就是先定义出合适易转换的字符串,

然后将字符串转为我们想要的array和hashtable。为了测试,我在的variable group中预先添加了arraystring 和 hashstring,一定要注意我设置的方法,value值格式会影响整个过程。

利用rest api 去get一下值,我们可以得到如下:

PS C:\Users\wenbo> $group.variables

arraystring                 hashstring
----------- ----------
@{value=wbubuntu,wbubuntu2} @{value=@{"key"="value";"key2"="value2"}}

我们看下类型:

PS C:\Users\wenbo> $group.variables.arraystring.value.GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ---- --------
True True String System.Object PS C:\Users\wenbo> $group.variables.hashstring.value.GetType() IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object

两个都是string,在做参数传递的时候,我们希望值是array和hashtable

1.转array string,此处的转换方法和你写的value值有关系,自己对应即可

PS C:\Users\wenbo> $array = $group.variables.arraystring.value.Split(",")

PS C:\Users\wenbo> $array
wbubuntu
wbubuntu2 PS C:\Users\wenbo> $array.GetType() IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String[] System.Array

2.转hashtable

PS C:\Users\wenbo> $hash = Invoke-Expression $group.variables.hashstring.value

PS C:\Users\wenbo> $hash

Name                           Value
---- -----
key value
key2 value2 PS C:\Users\wenbo> $hash.GetType() IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Hashtable System.Object

Azure DevOps的variable group实现array和hashtable参数的传递的更多相关文章

  1. Azure DevOps 利用rest api设置variable group

    我们在Azure DevOps中设置参数的时候,可以使用build,release各自的variables,但是各自的变量不能共用.此时我们需要使用variable group,它允许跨Build和R ...

  2. Azure Terraform(七)利用Azure DevOps 实现自动化部署基础资源(补充)

    一,引言 之前一篇文章有讲解到利用 利用Azure DevOps 实现自动化部署基础资源,当时 TF 代码没有针对 Azure 各个资源的封装,所有的资源代码全部写在一个 main.tf 文件中.然后 ...

  3. Azure DevOps(二)利用Azure DevOps Pipeline 构建基础设施资源

    一,引言 上一篇文章记录了利用 Azure DevOps 跨云进行构建 Docker images,并且将构建好的 Docker Images 推送到 AWS 的 ECR 中.今天我们继续讲解 Azu ...

  4. [Azure DevOps] 编译时自动修改版本号

    1. 需求 在使用 Pipeline 自动化 CI/CD 流程的过程中,我还还需要自动修改程序集的版本号.这个功能 EdiWang 和LeoLaw 都写文章讲解过做法.不过我的项目基本都是 .Net ...

  5. Azure Terraform(九)利用 Azure DevOps Pipeline 的审批来控制流程发布

    一,引言 Azure Pipeline 管道是一个自动化过程:但是往往我们由于某种原因,需要在多个阶段之前获得批准之后再继续下一步流程,所以我们可以向Azure Pipeline 管道添加审批!批准流 ...

  6. Azure Terraform(十)利用 Azure DevOps 的条件语句选择发布环境

    一,引言 之前我讲过的所有的案例中,都是将整个Azure Resource 部署到同一个订阅下,没有做到灵活的在 Azure Pipeline 在运行前选择需要部署的环境.在实际的项目开发中,我们也会 ...

  7. Azure Terraform(十一)Azure DevOps Pipeline 内的动态临时变量的使用

    思路浅析 在我们分析的 Azure Terraform 系列文中有介绍到关于 Terraform 的状态文件远程存储的问题,我们在  Azure DevOps Pipeline 的 Task Job ...

  8. Azure Devops/Tfs 编译的时候自动修改版本号

    看到阿迪王那边出品了一个基于Azure Devops自增版本号  链接 http://edi.wang/post/2019/3/1/incremental-build-number-for-net-c ...

  9. 使用ML.NET + Azure DevOps + Azure Container Instances打造机器学习生产化

    介绍 Azure DevOps,以前称为Visual Studio Team Services(VSTS),可帮助个人和组织更快地规划,协作和发布产品.其中一项值得注意的服务是Azure Pipeli ...

随机推荐

  1. docker学习(四)

    一.Docker数据管理 在容器中管理数据主要有两种方式:1.数据卷(Data volumes)2.数据卷容器(Data volume containers) 1.数据卷数据卷是一个可供一个或多个容器 ...

  2. [Dart] Understand Classes and Inheritance in Dart

    We will look at how we can create classes and explore some various features. Dart adopts a single-in ...

  3. struts2--CRUD

    struts的CRUD 1.导入相关的pom依赖(struts.自定义标签库的依赖) <dependency> <groupId>jstl</groupId> &l ...

  4. sql server if exists和 if not exists 的关键字用法

    if exists和if not exists关键字用法   1.介绍  if not exists 即如果不存在,if exists 即如果存在 2.使用  a.判断数据库不存在时  if not ...

  5. 洛谷 P2347 砝码称重 题解

    每日一题 day12 打卡 Analysis 完全背包 #include<iostream> #include<cstdio> #include<cstring> ...

  6. Oracle 与 postgreSQL 事务处理区别(多版本与undo区别)

    2015年左右,因为工作需要用MongoDB.CouchBase这两种文档型数据库,时不时到这两个数据库官网上查资料.报BUG.时常可以在MongoDB官网上看到这样一些新闻,“某某企业成功将MySQ ...

  7. b/s利用webuploader实现超大文件分片上传、断点续传

    本人在2010年时使用swfupload为核心进行文件的批量上传的解决方案.见文章:WEB版一次选择多个文件进行批量上传(swfupload)的解决方案. 本人在2013年时使用plupload为核心 ...

  8. 差分约束 4416 FFF 团卧底的后宫

    /* 4416 FFF 团卧底的后宫  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold 题解       题目描述 Description 你在某日收到了 FFF ...

  9. 【02NOIP提高组】均分纸牌

    #include<bits/stdc++.h> using namespace std; ; int n,sum,a[maxn]; int main() { ; cin>>n; ...

  10. expect 实例

    [root@runstone ssh_lianxi]# cat expect.sh #!/usr/bin/env expect } { #判断命令行参数的个数 send_user "usag ...