Quick test script for GitLab API operations - creates groups, users, makes commits, and runs some Robot Framework tests.
The script handles:
- Clones a repo using OAuth token
- Creates a test group and user via API
- Adds the user to the group
- Makes a commit and pushes it
- Runs Robot Framework API tests
- Cleans everything up automatically
You'll need these tools installed:
git- for repo operationscurl- API callsjq- JSON parsing (grab it here)robot- Robot Framework testing
Install Robot Framework:
pip install robotframework robotframework-requestsOr use Docker:
docker pull robotframework/robotframeworkSet these environment variables before running:
export GITLAB_API_URL="https://gitlab.example.com"
export GITLAB_PRIVATE_TOKEN="your_personal_access_token"
export SAMPLE_PROJECT_REPO="https://gitlab.example.com/group/project.git"Token permissions needed:
- Create users & groups
- Push to repositories
- API read access
Make it executable first:
chmod +x gitlab_feature_test.sh
chmod +x gitlab_feature_testingv2.shThen just run it:
./gitlab_feature_test.sh
./gitlab_feature_testingv2.shThe script validates everything before starting - if something's missing it'll tell you.
- Checks dependencies and config
- Tests GitLab connection
- Clones your sample repo
- Creates a test group (CI-Test-Group)
- Creates a test user (newuser)
- Adds user to group with developer access
- Updates README.md and pushes
- Generates Robot Framework tests
- Runs the tests
- Cleans up everything (even if something fails)
Logs are saved to test_run_YYYYMMDD_HHMMSS.log in the same directory.
Robot Framework results go to the results/ folder.
Don't worry about cleanup - it's automatic. The script tracks what it creates and deletes everything on exit (success or failure).
Resources deleted:
- Test group
- Test user
- Cloned directory
- Project (if specified)
Edit these variables in the script if you want different test data:
GROUP_NAME="CI-Test-Group"
GROUP_PATH="ci-test-group"
USER_EMAIL="newuser@example.com"
USER_USERNAME="newuser"
USER_PASSWORD="NewUserPassword"
ACCESS_LEVEL=30 # 30 = DeveloperAccess levels:
- 10 = Guest
- 20 = Reporter
- 30 = Developer
- 40 = Maintainer
- 50 = Owner
Connection fails:
- Check GITLAB_API_URL is correct (include https://)
- Verify token has proper permissions
- Make sure GitLab instance is reachable
Clone fails:
- Token needs push access to the repo
- Check SAMPLE_PROJECT_REPO URL is correct
- Remove
.gitsuffix or keep it - both work
Tests fail:
- Check the
results/log.htmlfor details - Verify created resources exist before tests run
- Token might not have API read access
Dependencies missing:
# Ubuntu/Debian
apt-get install git curl jq
pip install robotframework robotframework-requests
# macOS
brew install git curl jq
pip install robotframework robotframework-requests- Commit messages include
[skip ci]to prevent recursive CI runs - User creation skips email confirmation
- Script uses
set -euo pipefailfor strict error handling - All curl calls use
-s(silent) and-f(fail on HTTP errors)