circleCI 2.0 没有添加环境变量
circleCI 2.0 does not add the environment variable
我最近从 TravisCI 切换到 circleCI 2.0,当我尝试执行以下操作时遇到问题: export PATH="$MINICONDA/bin:$PATH"
,
它不添加路径变量。
我尝试使用 SSH 连接调试它。我首先检查了路径变量是否已设置(未设置),后来我尝试手动设置它并且成功了。但是,当自动执行构建时它不起作用。
这是错误消息:
Complete output from command python setup.py egg_info: Traceback (most
recent call last): File "<string>", line 1, in <module> File
"/tmp/pip-build-m_klG2/snakemake/setup.py", line 13
print("At least Python 3.5 is required.\n", file=sys.stderr)
它基本上看不到通过 conda 安装的 python (3.6),并尝试使用默认的 python (2.7) 运行 pip install -r python-requirements.txt
命令。
我一定是遗漏了什么,但我想不通。
我在下面提供了完整的 config.yml
文件。如果您能解释这个问题,我将不胜感激。
version: 2
jobs:
build:
branches:
only:
-dev
machine: true
working_directory: ~/repo
steps:
- checkout
- run:
name: install miniconda
command: |
cd /home/circleci
export MINICONDA=$HOME/miniconda
export PATH="$MINICONDA/bin:$PATH"
hash -r
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
bash miniconda.sh -b -f -p $MINICONDA
conda config --set always_yes yes
conda update conda
conda info -a
conda create -n testenv python=3.6.0
source activate testenv
- run:
name: install requirements
command: |
cd /home/circleci/repo
pip install -r python-requirements.txt
pip install pytest-ordering
- run:
name: download sample dataset
command: |
cd /home/circleci/repo/unit_tests/test_data
wget http://cf.10xgenomics.com/samples/cell-exp/2.1.0/t_3k/t_3k_filtered_gene_bc_matrices.tar.gz
tar -xvfz t_3k_filtered_gene_bc_matrices.tar.gz
- run:
name: run tests
command: |
cd /home/circleci/repo
pytest ./unit_tests
- store_artifacts:
path: test-reports
destination: test-reports
这似乎是 environment
flag 的一个很好的用例。
- run:
name: install miniconda
environment:
MINICONDA: $HOME/miniconda
PATH: $MINICONDA/bin:$PATH
command: |
cd /home/circleci
hash -r
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
bash miniconda.sh -b -f -p $MINICONDA
conda config --set always_yes yes
conda update conda
conda info -a
conda create -n testenv python=3.6.0
source activate testenv
最后,我使用the docs 2.0中的插值环境变量解决了它。
步骤:
将环境变量附加到 ~/.bashrc
echo 'export MINICONDA=$HOME/miniconda' >> ~/.bashrc
source 规则中的 ~/.bashrc 你想要访问那些变量
source ~/.bashrc
配置文件:
version: 2
jobs:
build:
branches:
only:
-dev
machine: true
working_directory: ~/repo
steps:
- checkout
- run:
name: install miniconda
command: |
cd /home/circleci
echo 'export MINICONDA=$HOME/miniconda' >> ~/.bashrc
echo 'export PATH="$MINICONDA/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
hash -r
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
bash miniconda.sh -b -f -p $MINICONDA
conda config --set always_yes yes
conda update conda
conda info -a
conda create -n testenv python=3.6.0
echo 'source activate testenv' >> ~/.bashrc
source ~/.bashrc
- run:
name: install requirements
command: |
source ~/.bashrc
cd /home/circleci/repo
# a requirement has install-time dependency on numpy
pip install numpy
pip install -r python-requirements.txt
pip install pytest-ordering
- run:
name: download sample dataset
command: |
cd /home/circleci/repo/unit_tests/test_data
wget http://cf.10xgenomics.com/samples/cell-exp/2.1.0/t_3k/t_3k_filtered_gene_bc_matrices.tar.gz
tar -zxvf t_3k_filtered_gene_bc_matrices.tar.gz
- run:
name: run tests
command: |
source ~/.bashrc
cd /home/circleci/repo
pytest ./unit_tests
- store_artifacts:
path: test-reports
destination: test-reports
[1]: https://circleci.com/docs/2.0/env-vars/#interpolating-environment-variables
我最近从 TravisCI 切换到 circleCI 2.0,当我尝试执行以下操作时遇到问题: export PATH="$MINICONDA/bin:$PATH"
,
它不添加路径变量。
我尝试使用 SSH 连接调试它。我首先检查了路径变量是否已设置(未设置),后来我尝试手动设置它并且成功了。但是,当自动执行构建时它不起作用。
这是错误消息:
Complete output from command python setup.py egg_info: Traceback (most
recent call last): File "<string>", line 1, in <module> File
"/tmp/pip-build-m_klG2/snakemake/setup.py", line 13
print("At least Python 3.5 is required.\n", file=sys.stderr)
它基本上看不到通过 conda 安装的 python (3.6),并尝试使用默认的 python (2.7) 运行 pip install -r python-requirements.txt
命令。
我一定是遗漏了什么,但我想不通。
我在下面提供了完整的 config.yml
文件。如果您能解释这个问题,我将不胜感激。
version: 2
jobs:
build:
branches:
only:
-dev
machine: true
working_directory: ~/repo
steps:
- checkout
- run:
name: install miniconda
command: |
cd /home/circleci
export MINICONDA=$HOME/miniconda
export PATH="$MINICONDA/bin:$PATH"
hash -r
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
bash miniconda.sh -b -f -p $MINICONDA
conda config --set always_yes yes
conda update conda
conda info -a
conda create -n testenv python=3.6.0
source activate testenv
- run:
name: install requirements
command: |
cd /home/circleci/repo
pip install -r python-requirements.txt
pip install pytest-ordering
- run:
name: download sample dataset
command: |
cd /home/circleci/repo/unit_tests/test_data
wget http://cf.10xgenomics.com/samples/cell-exp/2.1.0/t_3k/t_3k_filtered_gene_bc_matrices.tar.gz
tar -xvfz t_3k_filtered_gene_bc_matrices.tar.gz
- run:
name: run tests
command: |
cd /home/circleci/repo
pytest ./unit_tests
- store_artifacts:
path: test-reports
destination: test-reports
这似乎是 environment
flag 的一个很好的用例。
- run:
name: install miniconda
environment:
MINICONDA: $HOME/miniconda
PATH: $MINICONDA/bin:$PATH
command: |
cd /home/circleci
hash -r
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
bash miniconda.sh -b -f -p $MINICONDA
conda config --set always_yes yes
conda update conda
conda info -a
conda create -n testenv python=3.6.0
source activate testenv
最后,我使用the docs 2.0中的插值环境变量解决了它。
步骤:
将环境变量附加到 ~/.bashrc
echo 'export MINICONDA=$HOME/miniconda' >> ~/.bashrc
source 规则中的 ~/.bashrc 你想要访问那些变量
source ~/.bashrc
配置文件:
version: 2
jobs:
build:
branches:
only:
-dev
machine: true
working_directory: ~/repo
steps:
- checkout
- run:
name: install miniconda
command: |
cd /home/circleci
echo 'export MINICONDA=$HOME/miniconda' >> ~/.bashrc
echo 'export PATH="$MINICONDA/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
hash -r
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
bash miniconda.sh -b -f -p $MINICONDA
conda config --set always_yes yes
conda update conda
conda info -a
conda create -n testenv python=3.6.0
echo 'source activate testenv' >> ~/.bashrc
source ~/.bashrc
- run:
name: install requirements
command: |
source ~/.bashrc
cd /home/circleci/repo
# a requirement has install-time dependency on numpy
pip install numpy
pip install -r python-requirements.txt
pip install pytest-ordering
- run:
name: download sample dataset
command: |
cd /home/circleci/repo/unit_tests/test_data
wget http://cf.10xgenomics.com/samples/cell-exp/2.1.0/t_3k/t_3k_filtered_gene_bc_matrices.tar.gz
tar -zxvf t_3k_filtered_gene_bc_matrices.tar.gz
- run:
name: run tests
command: |
source ~/.bashrc
cd /home/circleci/repo
pytest ./unit_tests
- store_artifacts:
path: test-reports
destination: test-reports
[1]: https://circleci.com/docs/2.0/env-vars/#interpolating-environment-variables