Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
Labs

Triggering a Cloud Function with Cloud Build

Many organizations have adopted a CI/CD (continuous integration/continuous delivery) pipeline to maintain coding efficiency. Cloud Functions work well in a CI/CD environment and can be implemented as such through a Google Cloud service, Cloud Build. In this hands-on lab, you’ll gain the practical experience of setting up the Cloud Source Repository, Cloud Functions, and Cloud Build services to implement a CI/CD pipeline.

Lab platform
Lab Info
Level
Beginner
Last updated
Apr 06, 2025
Duration
45m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Enable APIs
    1. From the Google Cloud console's main navigation, visit APIs & Services > Library to enable the following services:
      • Cloud Functions
      • Source Repositories
      • Cloud Build
      • Cloud Resource Manager API
  2. Challenge

    Create a Google Cloud Source Repository
    1. Activate a Cloud Shell.

    2. Create a Source Repository:

      gcloud source repos create gcpro_repo
      
    3. Clone the repository to the shell:

      gcloud source repos clone gcpro_repo
      
    4. Clone repository from GitHub:

      git clone https://github.com/linuxacademy/content-gcpro-developer
      
    5. Copy files to shell repo:

      cp content-gcpro-developer/cicd-lab/* gcpro_repo
      
      cd gcpro_repo
      
  3. Challenge

    Move Files to Source Repository
    1. Use the following commands to commit the files in the shell repo to the newly created Source Repository:

      git remote add google https://source.developers.google.com/p/[PROJECT_ID]/r/gcpro_repo
      git add .
      git config --global user.email "[EMAIL_ADDRESS]"
      git config --global user.name "[NAME]"
      git commit -m "Initial Commit"
      git push --all google
      
    2. Visit the Source Repositories dashboard and click gcpro_repo to confirm the files.

  4. Challenge

    Create Cloud Function
    1. From the main navigation, go to Cloud Functions.
    2. Choose Create function.
    3. Configure your function with the following values:
      • Environment: 1st gen
      • Name: repo-function-1
      • Trigger: HTTP
      • Authentication: Allow unauthenticated invocations
      • Click Save
      • Under Runtime, build, connections and security settings:
        • Maximum number of instances: 1
      • Click Next
      • Source Code: Cloud Source repository
      • Runtime: Python 3.7
      • Repository: gcpro_repo
      • Entry point: greetings_http
    4. Leave all other fields with their default values and click Deploy.
    5. Once the function spins up, click to open it.
    6. Select the Trigger tab, and click the listed URL. It will open a new window with the default greeting.
    7. Back in the GCP console, click the Testing tab.
    8. In the Triggering window, enter
    {"name":"<YOUR_NAME>"}
    
    1. Click Test the function.
    2. In the Output box, note the results.
  5. Challenge

    Set IAM Permissions
    1. From the navigation, go to Cloud Build > Settings.
    2. In the Service Account Permissins section, change the status of the Cloud Functions Developer role to Enabled.
    3. In the Additional steps may be required dialog, choose Grant Access to All Service Accounts.
    4. Note that the status of the Service Account User role has changed to Enabled.
  6. Challenge

    Define a Cloud Build Trigger
    1. From the side navigation of the Cloud Build console, go to Triggers.
    2. Click Create trigger.
    3. Set the following values:
      • Repository: gcpro_repo.
      • Name: trigger-1
      • Build configuration: Cloud Build configuration file (yaml or json)
        • Make sure Cloud Build configuration file location autopopulates with / cloudbuild.yaml.
    4. Leave all other fields with their default values, and click Create.
  7. Challenge

    Verify Trigger
    1. From the Cloud Build Triggers page, click the Run Trigger option associated with the newly defined trigger.
    2. Test the trigger by using the Cloud Shell editor to alter the main.py file and pushing to the Source Repository.
    3. Visit Cloud Build > History and, if necessary, refresh the page to confirm the new build.
About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight