I'm trying to setup a Jenkins Pipeline for our SFDX CI process on a Jenkins instance.

I've successfully added the custom tool

Jenkins Global Settings - custom tool

I can successfully create a new scratch org via ${toolbelt} folder as below:

  // need to pull out assigned username
        rmsg = sh returnStdout: true, script: "${toolbelt}/sfdx force:org:create --definitionfile config/project-scratch-def.json --json --setdefaultusername"
        printf rmsg
        def jsonSlurper = new JsonSlurperClassic()
        def robj = jsonSlurper.parseText(rmsg)
      echo ('## parsed the msg')

My next step in the pipeline is to push the source code into the scratch org as below:

// push the source code into newly created scratch org

  rc = sh returnStatus: true, script: "${toolbelt}/sfdx force:source:push --targetusername ${SFDC_USERNAME}"
            if (rc != 0) {
                error 'push failed'

However, I'm getting folder does not contain SFDX project since the execution is running from the sfdx bin folder?


ERROR: This directory does not contain a valid Salesforce DX project

Any suggestions on how to get around this?

  • looks interesting. but how do you relate ${SFDC_USERNAME} to the user in scratch org created in step 1? it seems to be a env value. Dont you need to set it somewhwre? – San Tosh Nov 5 '18 at 12:07

You need to cd into the source code folder (checkout from VCS) and then run this command.

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.