Published on: February 26, 2026
6 min read
Follow this step-by-step guide to build an AI agent with Google's Agent Development Kit and deploy to Agent Engine using GitLab.

In this tutorial, you'll learn how to deploy an AI agent built with Google's Agent Development Kit (ADK) to Agent Engine using GitLab's native Google Cloud integration and CI/CD pipelines. We'll cover IAM configuration, pipeline setup, and testing your deployed agent.
Agent Engine is Google Cloud's managed runtime specifically designed for AI agents. Think of it as the production home for your agents — where they live, run, and scale without you having to manage the underlying infrastructure. Agent Engine handles infrastructure, scaling, session management, and memory storage so you can focus on building your agent — not managing servers. It also integrates natively with Google Cloud's logging, monitoring, and IAM.
AI agent deployment is typically difficult to configure correctly. Security considerations, CI/CD orchestration, and cloud permissions create friction that slows down development cycles.
GitLab streamlines this entire process while enhancing security:
Before you begin, ensure you have:
Here are the steps to follow.
The foundation of secure deployment is proper IAM configuration between GitLab and Google Cloud using Workload Identity Federation.
In your GitLab project:
GitLab generates a script for you. Copy and run this script in Google Cloud Shell to establish the Workload Identity Federation between platforms.
Important: Add these additional roles to your service principal for Agent Engine deployment:
roles/aiplatform.userroles/storage.objectAdminYou can add these roles using gcloud commands:
GCP_PROJECT_ID="<your-project-id>"
GCP_PROJECT_NUMBER="<your-project-number>"
GCP_WORKLOAD_IDENTITY_POOL="<your-pool-id>"
gcloud projects add-iam-policy-binding ${GCP_PROJECT_ID} \
--member="principalSet://iam.googleapis.com/projects/${GCP_PROJECT_NUMBER}/locations/global/workloadIdentityPools/${GCP_WORKLOAD_IDENTITY_POOL}/attribute.developer_access/true" \
--role='roles/aiplatform.user'
gcloud projects add-iam-policy-binding ${GCP_PROJECT_ID} \
--member="principalSet://iam.googleapis.com/projects/${GCP_PROJECT_NUMBER}/locations/global/workloadIdentityPools/${GCP_WORKLOAD_IDENTITY_POOL}/attribute.developer_access/true" \
--role='roles/storage.objectAdmin'
Now for the core of the deployment — the CI/CD pipeline. Create a .gitlab-ci.yml file in your project root:
stages:
- test
- deploy
cache:
paths:
- .cache/pip
key: ${CI_COMMIT_REF_SLUG}
variables:
GCP_PROJECT_ID: "<your-project-id>"
GCP_REGION: "us-central1"
STORAGE_BUCKET: "<your-staging-bucket>"
AGENT_NAME: "Canada City Advisor"
AGENT_ENTRY: "canada_city_advisor"
image: google/cloud-sdk:slim
# Security scanning templates
include:
- template: Jobs/Dependency-Scanning.gitlab-ci.yml
- template: Jobs/SAST.gitlab-ci.yml
- template: Jobs/Secret-Detection.gitlab-ci.yml
deploy-agent:
stage: deploy
identity: google_cloud
rules:
- if: $CI_COMMIT_BRANCH == "main"
before_script:
- gcloud config set core/disable_usage_reporting true
- gcloud config set component_manager/disable_update_check true
- pip install -q --no-cache-dir --upgrade pip google-genai google-cloud-aiplatform -r requirements.txt --break-system-packages
script:
- gcloud config set project $GCP_PROJECT_ID
- adk deploy agent_engine
--project=$GCP_PROJECT_ID
--region=$GCP_REGION
--staging_bucket=gs://$STORAGE_BUCKET
--display_name="$AGENT_NAME"
$AGENT_ENTRY
The pipeline consists of two stages:
Test stage — GitLab's security scanners run automatically. The included templates provide dependency scanning, static application security testing (SAST), and secret detection without additional configuration.
Deploy stage — Uses the ADK CLI to deploy your agent directly to Agent Engine. The staging bucket temporarily holds your application workload before Agent Engine picks it up for deployment.
identity: google_cloud directive enables keyless authentication via Workload Identity Federation.adk deploy agent_engine command handles all the complexity of packaging and deploying your agent.With your pipeline configured:
.gitlab-ci.yml to GitLab.Once the pipeline succeeds, verify your deployment in the Google Cloud Console:
Test your agent using a curl command. You'll need three pieces of information:
us-central1) PROJECT_ID="<your-project-id>"
LOCATION="us-central1"
AGENT_ID="<your-agent-id>"
TOKEN=$(gcloud auth print-access-token)
curl -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
"https://${LOCATION}-aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/${LOCATION}/reasoningEngines/${AGENT_ID}:streamQuery" \
-d '{
"input": {
"message": "I make $85,000 per year and I prefer cities with mild winters and a vibrant cultural scene. I also want to be near the coast if possible. What Canadian cities would you recommend?",
"user_id": "demo-user"
}
}' | jq -r '.content.parts[0].text'
If everything is configured correctly, your agent will respond with personalized city recommendations based on the budget and lifestyle preferences provided.
This deployment pattern provides several security advantages:
Deploying AI agents to production doesn't have to be complex. By combining GitLab's DevSecOps platform with Google Cloud's Agent Engine, you get:
Watch the full demo:
Ready to try it yourself? Use this tutorial's complete code example to get started now. Not a GitLab customer yet? Explore the DevSecOps platform with a free trial.
Enjoyed reading this blog post or have questions or feedback? Share your thoughts by creating a new topic in the GitLab community forum.
Share your feedback