CI/CD
Integra GitScrum CLI en pipelines CI/CD. Ejemplos para GitHub Actions, GitLab CI y Bitbucket Pipelines con actualizaciones automáticas.
Automatiza actualizaciones de tareas, reportes y sincronización desde tus pipelines.
Autenticación
Usa la variable de entorno GITSCRUMACCESSTOKEN:
export GITSCRUM_ACCESS_TOKEN="tu-token-oauth"Almacena el token en los secretos de tu plataforma CI:
| Plataforma | Ubicación |
|---|---|
| GitHub Actions | Settings → Secrets → Actions |
| GitLab CI | Settings → CI/CD → Variables |
| Bitbucket | Settings → Pipelines → Variables |
GitHub Actions
Actualizar Estado en Deploy
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Instalar GitScrum CLI
run: curl -fsSL https://cli.gitscrum.com/install.sh | sh
- name: Deploy aplicación
run: ./deploy.sh
- name: Actualizar tarea
run: |
TASK_ID=$(git log -1 --format=%s | grep -oE 'GS-[0-9]+' | head -1)
if [ -n "$TASK_ID" ]; then
gitscrum task update $TASK_ID --status deployed
fi
env:
GITSCRUM_ACCESS_TOKEN: ${{ secrets.GITSCRUM_ACCESS_TOKEN }}Reportes Programados
name: Reporte Semanal
on:
schedule:
- cron: '0 17 * * 5' # Viernes 17:00
jobs:
report:
runs-on: ubuntu-latest
steps:
- name: Generar reportes
run: |
curl -fsSL https://cli.gitscrum.com/install.sh | sh
gitscrum analytics velocity --format json > velocity.json
env:
GITSCRUM_ACCESS_TOKEN: ${{ secrets.GITSCRUM_ACCESS_TOKEN }}
- uses: actions/upload-artifact@v4
with:
name: reportes-semanales
path: velocity.jsonGitLab CI
stages:
- deploy
- notify
deploy:
stage: deploy
script:
- ./deploy.sh
actualizar-gitscrum:
stage: notify
script:
- curl -fsSL https://cli.gitscrum.com/install.sh | sh
- TASK_ID=$(echo $CI_COMMIT_MESSAGE | grep -oE 'GS-[0-9]+' | head -1)
- |
if [ -n "$TASK_ID" ]; then
gitscrum task update $TASK_ID --status deployed
fi
variables:
GITSCRUM_ACCESS_TOKEN: $GITSCRUM_ACCESS_TOKENBitbucket Pipelines
pipelines:
branches:
main:
- step:
name: Deploy
script:
- ./deploy.sh
- step:
name: Actualizar GitScrum
script:
- curl -fsSL https://cli.gitscrum.com/install.sh | sh
- export PATH=$PATH:/usr/local/bin
- TASK_ID=$(git log -1 --format=%s | grep -oE 'GS-[0-9]+' | head -1)
- |
if [ -n "$TASK_ID" ]; then
gitscrum task update $TASK_ID --status deployed
fiPatrones Comunes
Extraer Task ID del Commit
TASK_ID=$(git log -1 --format=%s | grep -oE 'GS-[0-9]+' | head -1)Extraer Task ID de la Rama
TASK_ID=$(echo $BRANCH_NAME | grep -oE 'GS-[0-9]+')Actualización Condicional
if [ -n "$TASK_ID" ]; then
gitscrum task update $TASK_ID --status deployed
fiMejores Prácticas
- Almacena tokens como secretos — Nunca en código
- No imprimas tokens — Evita
echo $GITSCRUMACCESSTOKEN - Maneja errores — Usa
|| truesi la actualización es opcional - Cachea el CLI — Evita descargar en cada ejecución
Cachear CLI en GitHub Actions
- uses: actions/cache@v4
with:
path: /usr/local/bin/gitscrum
key: gitscrum-cli-v1