Start tracking your progress
Trailhead Home
Trailhead Home

Deploy to Production with CI/CD

You’ve completed the first two stages of your CI/CD pipeline. The pipeline stops at integration testing intentionally to simulate an approval process before actually deploying to production. At the moment, the DreamHouse app is deployed in an ephemeral scratch org where your team can log into it for functional testing and review.

After you review the app in the scratch org, you switch back to GitLab where you click a button to continue the pipeline to install the package into your Trailhead Playground. Just like the other scratch orgs, when you approve the deploy stage, the integration testing scratch org is deleted as it is no longer needed. 

Review the App

Let’s review the current commit. 

  1. Log in to if you’re not already there.
  2. Click the Projects dropdown and search for dreamhouse to find your cloned repository, and select DreamHouse-sfdx.
    DreamHouse-sfdx selected from the Projects dropdown, with DreamHouse appearing in the search box.
  3. Click CI / CD then Pipelines.
  4. If your pipeline is still running, wait for it to complete. If successful, you should see a green checkmark with the status passed. If unsuccessful, you should see a red x with the status failed. Click the status of the latest pipeline to see more details.All GitLab Pipeline results
  5. Click integration-testing to see that job's log.
    Details of a single GitLab Pipeline result
  6. Scroll to the bottom of the job log to find the output of the sfdx force:user:display command. Note the Instance Url, Username, and Password displayed in the log output. You use these credentials to log in to the scratch org to review the DreamHouse app at this stage of the pipeline.
    Job log output for integration-test stage
  7. Open an incognito window in your favorite web browser and navigate to the website indicated by the Instance Url listed in the job log. Enter the Username and Password credentials for the scratch org listed in the job log, then click Log In to Sandbox.
    Log in to scratch org
  8. Click App Launcher to open the App Launcher, then click DreamHouse.
    Choose DreamHouse app in the App Launcher options
  9. Click Property Finder. Notice there is sample data already imported. This is because the integration-testing job ran the force:user:permset:assign and force:data:tree:import commands to configure the scratch org for testing. How convenient!
    The Property Finder custom object showing filters, houses and condos, Property Summary, and more.
  10. Explore the DreamHouse app.
  11. After you’re satisfied that the DreamHouse app is functioning as desired, close your incognito browser session and return to your GitLab project's pipeline page.

Approve Deployment and Push to Production

  1. From the latest pipeline, click the Play button on the app-deploy job. This starts the deployment stage.
    Manually start the app-deploy job.
  2. Click app-deploy to see that job's log. It can take a few minutes for the package install request to complete.
    Watching job log while app deploys

When completed, you get a glorious message, “Job succeeded”.

Review Your Deployment

It's time to see the deployed changes.

  1. At the bottom of this step, click Launch to open your Trailhead Playground in a new browser tab.
  2. Click App Launcher to open the App Launcher, then click DreamHouse. This step confirms you have successfully deployed the change to production in your Trailhead Playground. Once, there was no DreamHouse in your Trailhead Playground. Now, it’s there. Not by magic, but by CI/CD!
  3. Click Property Finder. Notice there is no sample data. This is because for production deployments you often don't want test data to automatically be inserted in the org each time a deployment occurs or a new package version is installed.

The Road to Fully Automated CI/CD

Now that DreamHouse is deployed, the next step is to repeat the development workflow: commit new changes to your Git repository and push them to GitLab to automatically re-trigger the pipeline. You have the opportunity to review the updated app and then approve deployment of those changes like you did during the first go-around. 

After successfully deploying the application a second time, you will have completed setting up an automated CI/CD pipeline for application development using Salesforce DX within a Trailhead Playground. We’re almost there. Let’s do this.