Our jenkins jobs using SFDX are dockerized, and we would like to be able to reuse scratch orgs from one job to another.
As a scratch org is linked to one SFDX CLI installation sfdx force:org:list doesn't return the scratch org created inside the previous container, as SFDX installs are considered different.
To solve this issue, I tried using docker volumes to share sfdx cache between containers, but until now it is unsuccessful.
Summary:
- Jenkins Build 1: force:org:create MYSCRATCH1
- Jenkins Build 2: I need to find MYSCRATCH1 and interact with it using force:org:list
Jenkinsfile part:
agent {
dockerfile {
args '-u 0:0 -v dxco4sfvol_pmdcache:/tmp/pmdcache -v dxco4sfvol_cache_sfdx:/root/.cache/sfdx' //Forces Container tu run as User Root , store cache dirs on locale volume
reuseNode true
}
}
Dockerfile part:
# Install sfdx-cli , sfdx-essentials plugin, sass , eslint
RUN npm install -g sfdx-cli && \
echo 'y' | sfdx plugins:install sfdx-essentials && \
npm install -g sass && \
npm install -g eslint
How could I manage to have the "same" SFDX install for all docker containers ?
Additional info :
- I don't have access to the file system of the EC2 / Linux AMI server hosting Jenkins
- Different jobs can run in parallel (so parallel docker containers using SFDX running at the same time)