I am setting up a CI/CD with bitbucket/jenkins using SFDX. I want each developer to have their own scratch org if they push to their feature branch.

I have to maintain if the scratch org is expired a new scratch org should be provisioned for the developer without showing the error message

    stage('Create Test Scratch Org') {
        rc = command "${toolbelt}/sfdx force:org:create --targetdevhubusername HubOrg --setdefaultusername --definitionfile config/project-scratch-def.json --setalias ciorg --wait 10 --durationdays 1"
        if (rc != 0) {
            error 'Salesforce test scratch org creation failed.'

Thanks in advance.

  • 1
    What is your question? Why are you not using a new scratch org on each commit?
    – David Reed
    Sep 23, 2019 at 13:46
  • Welcome to SF SE. May I suggest you review the section on how to ask questions in the Help Center. From your post it doesn't become clear what you're asking for. Sep 23, 2019 at 14:04
  • I agree with @DavidReed that you should ensure that every commit processed by your CI service has its own scratch org created for it. That way you know it is entirely clean and represents the state of your target branch with the commit merged to it.
    – Phil W
    Sep 23, 2019 at 15:24


Your Answer

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

Browse other questions tagged or ask your own question.