有没有办法在 Powershell 脚本中访问 TeamCity 系统属性? [英] Is there a way to access TeamCity system properties in a Powershell script?

查看:42
本文介绍了有没有办法在 Powershell 脚本中访问 TeamCity 系统属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Powershell 运行程序在 TeamCity 中设置新的构建配置.但是,我似乎找不到在构建脚本中访问 TeamCity 系统属性的方法.我已经看到有可能的提示,但找不到有关如何操作的文档.

I'm trying to set up a new build configuration in TeamCity using the Powershell runner. However, I can't seem to find a way to access the TeamCity System Properties in the build script. I've seen hints that it is possible, but cannot find documentation on how to do it.

我尝试使用 Powershell 变量语法 $variable 访问系统属性.我还打印了内存中的所有变量,但没有看到要使用的 teamcity 变量.

I have tried accessing the system properties using Powershell variable syntax, $variable. I have also printed out all variables in memory and see no teamcity variables to use.

Powershell runner 是否可以做到这一点,如果可以,让它工作所需的语法是什么?

Is this possible with the Powershell runner, and if so what is the syntax necessary to get it working?

推荐答案

TeamCity 将设置环境变量,例如 build.number(您可以在 TeamCity 中看到这些变量的列表).

TeamCity will set up environment variables, such as build.number (you can see a list of these within TeamCity).

在 Powershell 中,您可以使用 env "provider" 访问环境变量,例如

In Powershell you can access environment variables using the env "provider", e.g.

$env:PATH

TeamCity 变量可通过替换 .用 _,所以 build.number 变量可以访问为

TeamCity variables are accessible by replacing the . with a _, so the build.number variable can be accessed as

$env:build_number

这篇关于有没有办法在 Powershell 脚本中访问 TeamCity 系统属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆