如何在构建管道执行的中间设置环境变量? [英] How to set an environment variable in the middle of a build pipeline execution?

查看:81
本文介绍了如何在构建管道执行的中间设置环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用create-react-app创建我的React应用程序的项目,并且我正在使用Azure DevOps构建该项目并运行测试,但是存在问题.

I have a project that uses create-react-app for creating my react app, and I'm using Azure DevOps to build the project and run tests, but there is a problem.

为了在CI环境中运行测试,您必须创建一个环境变量CI=true,但是这样的结果是,如果发现警告(并且我的项目有警告),则构建脚本将失败.

In order to run tests in a CI environment, you have to create an environment variable CI=true, but this has the effect that the build script fails if warnings are found (and my project have warnings).

所以我的想法是先运行构建脚本,然后设置变量,然后运行测试,但是我还没有找到如何设置变量的方法.

So my idea is running the build script first, then set the variable, then run the tests, but I haven't found how to set the variable.

推荐答案

在构建中间添加一个Powershell任务,并在其中设置变量:

Add a Powershell task in the middle of the build and set the variable there:

这篇关于如何在构建管道执行的中间设置环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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