中文 | English
A fully automated coding agent powered by GitHub Copilot CLI and GitLab CI/CD. This system enables autonomous code implementation through issue assignments and merge request comments. If you are interested in AI Code Review in GitLab, refer to gitlab-copilot-code-review.
Youtube Demo videos
Setup:
How to use:
- Copilot Coding Agent for GitLab - How to use 2:30 – Create an issue in the app repo and assign it to Copilot
- Copilot Coding Agent for GitLab - How to use 11:24 – Let Copilot make some updates in the merge request via comments
Example repository
- Public GitLab Demo Repository app-repo-01
- Issue: a webhook receiver app
- MR: Copilot Generated MR for issue #9
- Update MR with comment: @copilot-agent change reamdme to Korean
graph TB
subgraph "App Repository (Target Repo)"
A[GitLab Issue/MR] -->|Issue assign to Copilot| C[Webhook Trigger]
A[GitLab Issue/MR] -->|MR comment @copilot-agent| C[Webhook Trigger]
end
subgraph "Webhook Service"
C -->|HTTP POST| D[Flask Service]
D -->|Validate & Extract| E[Pipeline Variables]
E -->|Trigger| F[GitLab API]
end
subgraph "Copilot Coding Agent Repo"
F -->|Start Pipeline| G[CI/CD Pipeline]
G -->|Issue: ack → plan → create_mr| H[Issue Workflow]
G -->|MR Note: mr_update only| I[MR Note Workflow]
H -->|implement → finalize| J[Copilot CLI]
I -->|implement changes| J
J -->|Generate Code| K[Git Commit & Push]
end
K -->|Update| A
J -->|Post Comments| A
style D fill:#e1f5ff
style G fill:#fff4e1
style J fill:#e8f5e9
- App Repository: Your application code repository where development happens
- Webhook Service: Flask-based relay service that captures GitLab events
- Copilot Coding Agent Repository: CI/CD orchestrator that runs the coding automation
Issue Assignment Workflow (Full automation):
Issue assigned to Copilot → Webhook → Trigger Pipeline →
Acknowledge Issue → Generate TODO Plan → Create MR →
Implement Code → Push Changes → Update MR & Issue
MR Note Workflow (Quick updates):
Comment @copilot-agent in MR → Webhook → Trigger Pipeline →
Acknowledge → Implement Changes → Push to Source Branch →
Post Summary Comment
- GitLab Account with API access
- GitLab Runner (Docker/Kubernetes executor) (for CI/CD execution)
- GitHub Copilot CLI access and subscription
- Docker (optional, for running webhook service in container)
- App Repository: Maintainer role (to receive webhooks and create MRs)
- Copilot Coding Agent Repository: Owner role (to configure CI/CD)
- GitLab Personal Access Token with scopes:
api(full API access)read_repositorywrite_repository
Suggested to create a dedicated GitLab user account for the Copilot agent for better permission management and activity auditing. You may use an existing account, but it is not recommended.
-
Create a new GitLab account named "Copilot" or similar
-
Generate a Personal Access Token for this account:
-
Grant appropriate permissions to this user (choose one approach):
- Option A (Recommended for organization-wide use): Set as GitLab Administrator or Group Owner
- This allows the Copilot user to access all repositories in the GitLab instance or group
- More convenient for managing multiple projects
- Option B (Recommended for limited scope): Add as a member to specific App Repositories
- Role: Developer or Maintainer
- More granular control, suitable if you prefer restricted access
- This user will be assigned to issues and create merge requests
- Option A (Recommended for organization-wide use): Set as GitLab Administrator or Group Owner
Using Copilot user operations
-
Import this repository to your GitLab via Git URL
-
Configure CI/CD Variables
Go to Settings → CI/CD → Variables, add the following:
Variable Description Protected Masked GITLAB_TOKENPersonal access token (from Step 1) ✅ ✅ GITHUB_TOKENGitHub Copilot CLI access token, including a valid GitHub Copilot subscription ✅ ✅ To generate the
GITHUB_TOKENwhich is a fine-grained PAT with the "Copilot Requests" permission enabled.:- Visit https://github.com/settings/personal-access-tokens/new
- Under "Permissions," click "add permissions" and select "Copilot Requests"
- Generate your token

Remember to change the role that can use pipeline variables to Developer

-
Setup GitLab Runner
If your GitLab instance already has available Runners with Docker/Kubernetes executors, you can skip this step.
Ensure you have a GitLab Runner configured with:
- Docker executor (recommended)
- Access to Docker image:
satomic/copilot-cli:latest
if using tags, ensure the Runner has the corresponding tags, or update
.gitlab-ci.ymlas needed. New Runner registration can be completed following GitLab's page guidance, and can be registered at the project or group level. Here is an example for project level:
-
Configure Copilot CLI Access
I have built the Docker image
satomic/copilot-cli:latestwhich includes:- GitHub Copilot CLI installed
- Authentication pre-configured, reading the
GITHUB_TOKENenvironment variable
Or build your own image with Copilot CLI access.
-
Create
.envfilecat > .env << EOF PIPELINE_TRIGGER_TOKEN=your-trigger-token, Generate in Settings → CI/CD → Pipeline trigger tokens of the repository created in Step 2 PIPELINE_PROJECT_ID=your-project-id, This repository's project ID (found in Settings → General) PIPELINE_REF=main GITLAB_API_BASE=https://gitlab.com # Change to self-hosted instance if needed WEBHOOK_SECRET_TOKEN= COPILOT_AGENT_USERNAME=copilot-agent # GitLab ID of the Copilot bot [email protected] # Email for git commits LISTEN_HOST=0.0.0.0 LISTEN_PORT=8080 EOF
-
Run with Docker
docker run -itd \ --name gitlab-copilot-coding-agent-hook \ -p 8080:8080 \ --env-file .env \ --restart unless-stopped \ satomic/gitlab-copilot-coding-agent-hook:latest
-
Run from source (optional)
git clone https://github.com/satomic/gitlab-copilot-coding-agent.git cd gitlab-copilot-coding-agent/ python3 main.py -
Hook URL Obtain the public URL of the webhook service, e.g.,
http://your-server-ip:8080/webhook
Generally, developers who want to use the Copilot coding agent only need to configure the webhook in their own app repository, without accessing the Copilot coding agent repository.
-
Go to your App Repository → Settings → Webhooks
-
Create Issue Webhook
-
Test the webhook
- Click Test → Issue events
- Check webhook service logs for successful reception
- Verify HTTP 200/202 response
-
Test Issue Assignment
-
Test MR Note
-
Check Logs
# Webhook service logs docker logs -f gitlab-copilot-coding-agent-hook # Check saved webhook payloads ls -la hooks/ # Check pipeline logs # Go to Copilot Coding Agent repo → CI/CD → Pipelines
-
Create an Issue in your App Repository
## Requirements - Implement user authentication - Add password hashing - Create login endpoint - Add JWT token generation
-
Assign to Copilot
- In the issue page, assign it to the "Copilot" user
- The system will automatically start working
-
Track Progress
- Copilot posts an acknowledgment comment with pipeline link
- A merge request is created with TODO checklist
- Code is implemented automatically
- Final comment notifies completion
-
Review & Merge
- Review the generated code in the MR
- Request changes if needed (see MR Note usage below)
- Approve and merge when satisfied
-
In an Existing MR, add a comment:
@copilot-agent add error handling to the login function -
Supported Instructions
- Add features:
@copilot-agent add unit tests for authentication - Fix bugs:
@copilot-agent fix the null pointer exception in line 45 - Refactor:
@copilot-agent refactor the user service to use dependency injection - Update:
@copilot-agent update dependencies to latest versions
- Add features:
-
Copilot will:
- Acknowledge your request
- Implement the changes
- Commit and push to the MR branch
- Post a summary of changes
Writing Effective Issue Descriptions:
- Be specific about requirements
- Include acceptance criteria
- Provide context and examples
- Use checklists for multiple tasks
Using MR Note Commands:
- One clear instruction per comment
- Reference specific files/functions when possible
- Be concise but descriptive
- Wait for completion before next instruction
Code Review:
- Always review generated code
- Test the implementation
- Check for security issues
- Verify coding standards compliance
The following files are generated during execution but excluded from commits:
patch_raw.txt- Raw Copilot outputtodo.md/todo_completed.md- Task checklistsplan.json- Execution plancommit_msg.txt- Generated commit messagemr_summary.txt- Change summary
-
Check webhook delivery
- App Repo → Settings → Webhooks → View Recent Deliveries
- Look for 2xx status codes
-
Verify webhook service
curl -X POST https://webhook.yourdomain.com/webhook \ -H "Content-Type: application/json" \ -d '{"test": true}'















