gitlab-ci-job-configuration

$npx mdskill add TheBushidoCollective/han/gitlab-ci-job-configuration

Define GitLab CI jobs with scripts, environments, and rules.

  • Configure complex pipelines with conditional execution logic.
  • Integrates with GitLab CI YAML syntax and shell scripting.
  • Executes commands based on branch conditions and pipeline sources.
  • Outputs structured YAML configurations for direct job creation.

SKILL.md

.github/skills/gitlab-ci-job-configurationView on GitHub ↗
---
name: gitlab-ci-job-configuration
user-invocable: false
description: Use when defining GitLab CI jobs, configuring scripts, setting up environments, or managing job dependencies. Covers job structure and execution options.
allowed-tools:
  - Read
  - Write
  - Edit
  - Bash
  - Grep
  - Glob
---

# GitLab CI - Job Configuration

Configure GitLab CI jobs with proper scripts, environments, and execution settings.

## Basic Job Structure

```yaml
job_name:
  stage: test
  image: node:20-alpine
  before_script:
    - npm ci
  script:
    - npm test
  after_script:
    - echo "Cleanup tasks"
  rules:
    - if: $CI_COMMIT_BRANCH == "main"
```

## Script Configuration

### Multi-Line Scripts

```yaml
build:
  script:
    - echo "Building application..."
    - npm run build
    - echo "Build complete"
```

### Script with Exit Codes

```yaml
test:
  script:
    - npm test || exit 1
    - npm run lint
  allow_failure: false
```

## Environment Configuration

```yaml
deploy:production:
  stage: deploy
  script:
    - ./deploy.sh
  environment:
    name: production
    url: https://example.com
    on_stop: stop:production
  rules:
    - if: $CI_COMMIT_BRANCH == "main"
      when: manual

stop:production:
  stage: deploy
  script:
    - ./teardown.sh
  environment:
    name: production
    action: stop
  when: manual
```

## Job Rules

### Conditional Execution

```yaml
job:
  rules:
    - if: $CI_COMMIT_BRANCH == "main"
      when: always
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
      when: on_success
    - when: never
```

### Changes-Based Rules

```yaml
test:frontend:
  rules:
    - changes:
        - "src/frontend/**/*"
        - "package.json"
```

### Exists-Based Rules

```yaml
docker:build:
  rules:
    - exists:
        - Dockerfile
```

## Job Dependencies

### Using Dependencies

```yaml
build:
  stage: build
  script: npm run build
  artifacts:
    paths:
      - dist/

test:
  stage: test
  dependencies:
    - build
  script: npm test
```

### Using Needs (DAG)

```yaml
test:unit:
  needs:
    - job: build
      artifacts: true
  script: npm run test:unit
```

## Parallel Jobs

### Matrix Jobs

```yaml
test:
  parallel:
    matrix:
      - NODE_VERSION: ["18", "20", "22"]
        OS: ["alpine", "bullseye"]
  image: node:${NODE_VERSION}-${OS}
  script: npm test
```

### Simple Parallel

```yaml
test:
  parallel: 5
  script: npm run test:shard
```

## Resource Configuration

```yaml
heavy_job:
  tags:
    - high-memory
  resource_group: deploy
  timeout: 2h
  retry:
    max: 2
    when:
      - runner_system_failure
      - stuck_or_timeout_failure
```

More from TheBushidoCollective/han

SkillDescription
absinthe-resolversUse when implementing GraphQL resolvers with Absinthe. Covers resolver patterns, dataloader integration, batching, and error handling.
absinthe-schemaUse when designing GraphQL schemas with Absinthe. Covers type definitions, interfaces, unions, enums, and schema organization patterns.
absinthe-subscriptionsUse when implementing real-time GraphQL subscriptions with Absinthe. Covers Phoenix channels, PubSub, and subscription patterns.
act-docker-setupUse when configuring Docker environments for act, selecting runner images, managing container resources, or troubleshooting Docker-related issues with local GitHub Actions testing.
act-local-testingUse when testing GitHub Actions workflows locally with act. Covers act CLI usage, Docker configuration, debugging workflows, and troubleshooting common issues when running workflows on your local machine.
act-workflow-syntaxUse when creating or modifying GitHub Actions workflow files. Provides guidance on workflow syntax, triggers, jobs, steps, and expressions for creating valid GitHub Actions workflows that can be tested locally with act.
ameba-configurationUse when configuring Ameba rules and settings for Crystal projects including .ameba.yml setup, rule management, severity levels, and code quality enforcement.
ameba-custom-rulesUse when creating custom Ameba rules for Crystal code analysis including rule development, AST traversal, issue reporting, and rule testing.
ameba-integrationUse when integrating Ameba into development workflows including CI/CD pipelines, pre-commit hooks, GitHub Actions, and automated code review processes.
analyze-performanceAnalyze performance metrics and identify slow transactions in Sentry