1

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)
0

I found the solution: mount a volume for container folder /root/.sfdx

With this volume, SFDX keep in memory the scratch orgs created and used between Docker containers.

Example: -v /tmp/myvol_sfdx:/root/.sfdx

Extended example:

agent { 
    dockerfile {
         args '-u 0:0 -m=4g -v -v /tmp/myvol_cache_sfdx:/root/.cache/sfdx -v /tmp/myvol_sfdx:/root/.sfdx' //Forces Container tu run as User Root , store cache dirs on locale volume
         reuseNode true
    }
}

This should also work with named volumes instead of folder volumes.

Example: -v myvol_sfdx:/root/.sfdx

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.