Generate GitLab CI/CD pipeline configurations
$ dojops tools install gitlab-ci{projectPath}/.gitlab-ci.ymlYou are a CI/CD expert. Generate a GitLab CI/CD pipeline configuration as structured JSON.
Respond with valid JSON matching the GitLab CI structure. The object should contain "stages" as a top-level array, plus job definitions as top-level keys.
{
"stages": ["build", "test", "deploy"],
"variables": { "NODE_VERSION": "20" },
"default": { "image": "node:20-alpine" },
"build": {
"stage": "build",
"script": ["npm ci", "npm run build"],
"artifacts": { "paths": ["dist/"] }
},
"test": {
"stage": "test",
"script": ["npm ci", "npm test"]
},
"deploy": {
"stage": "deploy",
"script": ["echo 'Deploying...'"],
"only": ["main"]
}
}
IMPORTANT:
- "stages" is required and must be an array
- Each job must have "stage" and "script" fields
- "script" must be an array of strings
- Use "only"/"except" or "rules" for conditional jobs
- Respond with valid JSON only, no markdownGiven: "GitLab CI for a Node.js project with build, test, and deploy stages"
```json
{
"stages": ["build", "test", "deploy"],
"variables": {
"NODE_VERSION": "20"
},
"default": {
"image": "node:20-alpine",
"cache": {
"paths": ["node_modules/"]
}
},
"build": {
"stage": "build",
"script": ["npm ci", "npm run build"],
"artifacts": {
"paths": ["dist/"],
"expire_in": "1 hour"
}
},
"test": {
"stage": "test",
"script": ["npm ci", "npm test"],
"coverage": "/All files[^|]*\\|[^|]*\\s+([\\d\\.]+)/"
},
"deploy_staging": {
"stage": "deploy",
"script": ["echo 'Deploying to staging...'"],
"environment": {
"name": "staging"
},
"rules": [{ "if": "$CI_COMMIT_BRANCH == \"main\"" }]
}
}
```- Every job must have "stage" and "script" - Script entries must be strings - Use caching for dependency directories - Use artifacts for build outputs - Define environments for deploy jobs - Maximum 20 jobs per pipeline
gitlab, gitlab-ci, ci, cd, pipeline, job, stage, runner, deploy, build, test, artifact, cache, environment, gitlab-ci.yml
No comments yet.