'CircleCi job: I need to make the working-directory as a variable
I am working in many project in same time so i need to use a different working directory in circle,look what i did:
steps: - checkout
- run:
name: Run test
command: |
mvn test -Dcucumber.options="/home/circleci/project/features/$featurename"
if [ "$interface_impacted" == "Pro web App (ap PC)" ];
then
WDR= "QaPlanityUserAutomation"
else
WDR= "QaPlanityProAutomation"
fi
working_directory: $WDR
But it does not work
Solution 1:[1]
You can use save_workspace and attach_workspace to provide working_directory.
For example:
version: 2.1
jobs:
doing-things-job:
docker:
- image: cimg/base:stable
parallelism: 3
steps:
- checkout
- run:
name: "Say hello"
command: "echo Hello, World!"
- run:
name: "Write random data"
command: openssl rand -hex 4 > rand_${CIRCLE_NODE_INDEX}.txt
- run:
name: "Emulate doing things"
command: |
if [[ "$CIRCLE_NODE_INDEX" != "0" ]]; then
sleep 30
fi
# save the files your deploy step needs
- save_workspace:
root: . # relative path to our working directory
paths: # file globs which will be persisted to the workspace
- rand_*
deploy-job:
docker:
- image: cimg/base:stable
steps:
# attach the files you persisted in the doing-things-job
- attach_workspace:
at: . # relative path to our working directory
- run:
command: |
echo "this is a deploy step"
workflows:
deploy-step-workflow:
jobs:
- doing-things-job
- deploy-job:
requires:
- doing-things-job
You can refer to Configuring CircleCI and Using ENV variable as working directory?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
