如何在詹金斯构建中激活conda环境 [英] How to activate conda environment in jenkins build

查看:406
本文介绍了如何在詹金斯构建中激活conda环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我们的jenkins服务器(在Windows上运行)上使用特定的conda环境运行jenkins构建.我认为这和运行一样容易:

I need to run jenkins build using a specific conda environment on our jenkins server (running on Windows). I thought it would be as easy as running:

activate myenv
python test_env.py

,但这似乎导致构建甚至在脚本启动之前退出.这是jenkins控制台日志:

but this seems to cause the build to exit instead, before the script even starts. Here is the jenkins console log:

activate myenv
Activating environment "myenv"...
Finished: SUCCESS

如果我删除了激活行,则python脚本可以正常执行.

If I remove the activate line, the python script executes fine.

仅供参考,我正在运行的脚本:

FYI, the script I am running:

import os

f = open('env.txt','w')

for k, v in os.environ.iteritems():
    print k, v
    f.write('%s\t%s\n' % (k,v))
f.close()

有人知道发生了什么吗?我应该直接调用相关的python可执行文件吗?

Does anybody know what is going on? Should I directly call the relevant python executable instead?

推荐答案

使用call activate myenv防止激活完成后结束当前shell.请参阅 https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/call.mspx?mfr=true .

Use call activate myenv to prevent activate from ending the current shell when it is finished. See https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/call.mspx?mfr=true.

这篇关于如何在詹金斯构建中激活conda环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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