I have a pipeline in Gitlab that the last step is only to push in production. But there's no need to execute all the tests again once the previous step/stage already did it. The previous command does it when I add '-c ' parameter to check if everything is okay.

enter image description here

So, instead of running all again (without -c parameter) I would like to set up a command to simulate the same behavior that we have in the Salesforce interface Deployment Status page.

It would be so fast and there would not need to wait all the process or login in SF admin interface to proceed that.

The Validate stage creates this item, so that is faster to go to Salesforce instead of clicking on the butoon "Deploy-prod" in Gitlab.

Which command would be it? is there any?

enter image description here

2 Answers 2


The documentation for force:source:deploy includes a list of flags that it can accept.

One of them is -q <validated deploy request id>, which documentation says

Specifies the ID of a package with recently validated components to run a Quick Deploy.

Myself, I haven't used that flag before, so I'm not 100% sure what the command would be. That said, I imagine it's likely
sfdx force:source:deploy -u <username or alias> -q <validated deploy request id>


The documentation does give an example, sfdx force:source:deploy -q 0Af9A00000FTM6pSAH, so it looks like I was on the money. I'd also use the -u flag because I imagine the command would fail if you try to quick deploy something that wasn't in your default org.

  • nice! but how do you get the deploy id dynamically? It comes from the previous stage so that I would need to get the last one. Nov 24, 2021 at 13:31
  • @OlavoAlexandrino I'll have to play around with a few things a bit later (I don't have the sf cli on the computer I'm using to write this), but I imagine that force:source:deploy writes the deployment Id to the terminal at some point in time. A shell script (e.g. BASH) should be able to isolate it and write the result to something (a file, a pipeline variable) that could be used in another pipeline/job.
    – Derek F
    Nov 24, 2021 at 14:19
  • Yes, force:source:deploy does it. I'm checking out to about how to get it dynamically. Let's share each other. thanks! Nov 24, 2021 at 18:59

In your validate job, re-direct the output of the validation deployment command to a text file using "tee" for example (sfdx force:source:deploy -c | tee deploy_log.txt). Store the text file as a pipeline artifact.

By default, other subsequent jobs in your pipeline will have access to this artifact. Then, you can just extract the Deploy ID from the log and pass that to your quick deploy function.

I wrote up a shell script that pulls the ID from the log, then runs the quick deploy like this:

# Pull deployment ID from the deploy log
deploy_id=$(grep -rnw 'deploy_log.txt' -e 'Deploy ID:' | sed 's/..*Deploy ID: //g')
sfdx force:source:deploy -q $deploy_id

You must log in to answer this question.

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