激活时立即运行脚本的原型

问题描述 投票:0回答:1

我正在teamcity配置中使用Windows cmd脚本作业。作业基本上是通过直接python调用来运行测试的]

set PYTHONPATH=c:\work;%PYTHONPATH;
cd c:\work\test
pytest -v

现在我们决定在anaconda环境中进行测试,并寻找类似的东西

conda activate test_env -execute "wrapper.bat"

有什么想法吗?

teamcity pytest anaconda3
1个回答
0
投票

这是我在Teamcity中使用conda环境所做的工作

  1. 使用powershell构建步骤
  2. 创建conda环境并设置路径
conda create -y --name %conda_env_name% python=%python_version%

activate %conda_env_name%

# Created Conda paths to be added to path  
$conda_path = "C:\Program Files\Conda43\envs\" + "%conda_env_name%"
$conda_script = "$conda_path" + "\Scripts"
$conda_lib = "$conda_path" + "\Library\bin"

# Add the newly conda to your path for the session only
$env:Path = "$conda_path;$conda_script;$conda_lib;$env:Path"

#test that it is now using python from the new conda env together with pip
python -V
pip -V
  1. 就是这样,运行并测试它
© www.soinside.com 2019 - 2024. All rights reserved.