circleCI 2.0 не добавляет переменную окружения - PullRequest
0 голосов
/ 16 мая 2018


Я недавно переключился на circleCI 2.0 из TravisCI, и у меня возникает проблема, когда я пытаюсь: 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)

По сути, он не видит python (3.6), установленный через conda, и пытается запустить команду pip install -r python-requirements.txt с python по умолчанию (2.7).
Должно быть, я что-то упустил, но я не мог этого понять.Я предоставляю полный 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

Ответы [ 2 ]

0 голосов
/ 17 мая 2018

В конце концов, я решил это с помощью интерполяционных переменных среды в документах 2.0 .

Шаги:

  1. Добавить переменную окружения к ~ / .bashrc
    echo 'export MINICONDA=$HOME/miniconda' >> ~/.bashrc

  2. источник ~ / .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
0 голосов
/ 17 мая 2018

Это хороший пример использования флага environment .

- 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
...