Can I use environment variables in store_artifacts


#1

I’d like to use environment variables in the store artifacts section, like so:

      - store_artifacts:
      path: target/scala-$SCALA_BINARY_VERSION/coverage-report
      destination: coverage-report/

Is this possible, or am I missing something?


#2

2.0 does not yet support evaluating ENVARS in circle.yml, this is coming soon though.


Using Environment Variables in config.yml not working
#3

@levlaz Any updates on this?


#4

Please see my answer here: Using Environment Variables in config.yml not working


#5

We have the following config:

version: 2
jobs:
  build:
    machine:
      enabled: true
      image: circleci/classic:201708-01

    steps:
      - run:
          name: Set environment variables
          shell: /bin/bash
          command: |
            LOG_DIR=/tmp/artifacts; echo "export LOG_DIR=${LOG_DIR}" >> "${BASH_ENV}"

      - checkout

      - run:
          name: Create arctifacts directory
          command: |
            mkdir "${LOG_DIR}"

      - run: make -e build

      - run: make -e deploy

      - store_artifacts:
          path: "${LOG_DIR}"

Which fails with:

Uploading /home/circleci/project/${LOG_DIR} to home/circleci/project/${LOG_DIR}
  No artifact files found at /home/circleci/project/${LOG_DIR}

I also tried with

LOG_DIR=artifacts

And then it fails with:

Uploading /home/circleci/project/${LOG_DIR} to home/circleci/project/${LOG_DIR}
  No artifact files found at /home/circleci/project/${LOG_DIR}

@leviaz, is there an ETA for evaluating ENVARS in the store_artifacts step?


#6

Not at this time.


#7

:cry: This is a badly needed feature. For example to embed a build version number in an artifact file name. Hoping that CircleCI can address this need soon!


#8

You can still name a file with the version and keep the parent directory name static.


#9

Maven also joins project version in artifact file name. Sure I can change build final name, but it is unsuitable. Moreover, target output dir is very dirty. For while, I have configured maven-war-plugin to change output directory based on environment variable.


#10

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.