I have jenkins pipeline with SFDX CLI integration. I have few stages in pipeline like login, validate.

In validate I have SFDX command

rc = command "${toolbelt}/sfdx force:mdapi:deploy -f unpackaged.zip -u ${USERNAME} -w 180 -l ${TestLevel} -c"

where -c is used to only validate the deployment.

Now, I have a requirement where if validate is completed / successful then I need to deploy that change set into target Salesforce org. So, according to sfdx:force:mdapi:deploy documentation there is option to quick deploy with flag -q. But for that I will need the Job ID of the validated change set. So I am confused how to retrieve Job ID from validate step and use it in quick deploy step so as to it will first validate and deploy the change set.

Note: I am new to Salesforce deployment so let me know if I am not following standard process for change set deployment.


1 Answer 1


Specify the --json so that you can obtain the deployment Id as needed by the other command.

Something like below

rc = command "${toolbelt}/sfdx force:mdapi:deploy -f unpackaged.zip -u ${USERNAME} -w 180 -l ${TestLevel} -c --json"

The deployment result will be JSON now as below

 "status": 0,
 "result": {
   "id": "0Af80000003ynf6CAA",
   "status": "Succeeded",
   "success": true
  • Ok, so I will need to store this JSON output to a file to access in next SFDX CLI commands ? Like, how it will be available to use by other command in next stages of Jenkins pipeline ? Jun 9, 2022 at 10:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .