2016-08-21 128 views
1

通過終端,它是爲source activate MyCondaEnv一樣簡單,但如果我嘗試在Jenkinsfile:如何通過Jenkinsfile激活conda環境?

sh '. /home/rwardrup/anaconda3/bin/activate MyCondaEnv', 

詹金斯控制檯回報:

Running shell script 
+ . /home/rwardrup/anaconda3/bin/activate MyCondaEnv 
+ [[ -n ]] 
/var/lib/jenkins/workspace/testing/[email protected]/durable-bb4a4c30/script.sh: 4: /home/rwardrup/anaconda3/bin/activate: [[: not found 
+ [[ -n ]] 
/var/lib/jenkins/workspace/testing/[email protected]/durable-bb4a4c30/script.sh: 7: /home/rwardrup/anaconda3/bin/activate: [[: not found 
+ echo Only bash and zsh are supported 
Only bash and zsh are supported 
+ return 1 

我試着在上面吐了一點家當: sh '$!/bin/bash. /home/rwardrup/anaconda3/bin/activate MyCondaEnv',以爲這樣就可以有,這樣做,我也得到:

Running shell script 
+ /bin/bash. /home/rwardrup/anaconda3/bin/activate MyCondaEnv 
/var/lib/jenkins/workspace/testing/[email protected]/durable-2a550d19/script.sh: 2: /var/lib/jenkins/workspace/testing/[email protected]/durable-2a550d19/script.sh: /bin/bash.: not found 

有什麼辦法來激活和使用Conda環境通過Jenkinsfile?我發現了一些關於使用Django venv in a Jenkinsfile的信息,但這在我的情況下並不起作用。

回答

3

它看起來像一個不正確的語法爲shebang和一個missng換行後。

試試這個:

sh '''#!/bin/bash 
    . /home/rwardrup/anaconda3/bin/activate MyCondaEnv 
''' 
+0

這是它!非常感謝你。 –