Jenkinsfile中的Anaconda [英] Anaconda in Jenkinsfile
问题描述
由于我们正在运行的测试越来越长,我认为从Travis CI切换到Jenkins(在我的本地计算机上)将是一个好主意.设置Jenkins相对简单,但是让我的Jenkinsfile可以工作"的不是很多.我正在尝试下载miniconda->安装miniconda->安装环境->激活环境->从该环境运行命令.这是我到目前为止所得到的:
Since the tests we are running are getting longer and longer, I thought it would be a good idea to switch from Travis CI to Jenkins (on my local computer). Setting up Jenkins was relatively straightforward, however getting my Jenkinsfile to 'work' not so much. I am trying to download miniconda -> install miniconda -> install an environment -> activate the environment -> run commands from that environment. This is what I got so far:
environment {
PATH = "$WORKSPACE/miniconda/bin:$PATH"
}
stages {
stage('setup miniconda') {
steps {
sh '''#!/usr/bin/env bash
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
bash miniconda.sh -b -p $WORKSPACE/miniconda
hash -r
conda config --set always_yes yes --set changeps1 no
conda update -q conda
# Useful for debugging any issues with conda
conda info -a
conda config --add channels defaults
conda config --add channels conda-forge
conda config --add channels bioconda
# create snakemake-workflows env
conda init bash
conda env create -f envs/snakemake-workflows.yaml
'''
}
}
stage('Test downloading') {
steps {
sh '''#!/usr/bin/env bash
conda init bash
conda activate miniconda/envs/snakemake-workflows/
snakemake -s workflows/download_fastq/Snakefile --directory workflows/download_fastq -n -j 48 --quiet
'''
}
}
似乎安装了miniconda,但是阶段测试下载的下一步导致错误:
The installation of miniconda seems to work, however the next step in stage test downloading results in the error:
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
Currently supported shells are:
- bash
- fish
- tcsh
- xonsh
- zsh
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
我该如何进行呢?我需要初始化我的conda,但是它似乎没有作用(在创建环境以及尝试激活它时,我会这样做).
How do I proceed from this? I need to init my conda, however it seems to have no effect (I do it when creating the environment, and when trying to activate it).
推荐答案
如果conda是以静默方式安装的(-b标志),则它将不会编辑您的bashrc(请参阅
If conda is installed in silent mode (-b flag), then it will not edit your bashrc (see https://docs.anaconda.com/anaconda/install/silent-mode/). So in the Test downloading
stage you will have to manually init it again.
这应该有效:
stage('Test downloading') {
steps {
sh '''#!/usr/bin/env bash
source $WORKSPACE/miniconda/etc/profile.d/conda.sh
conda activate miniconda/envs/snakemake-workflows/
snakemake -s workflows/download_fastq/Snakefile --directory workflows/download_fastq -n -j 48 --quiet
'''
}
}
这篇关于Jenkinsfile中的Anaconda的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!