Skip to content
gradle-ci-cd-integration logo

Gradle CI/CD Integration

gradle-ci-cd-integration

Configures Gradle builds for CI/CD platforms including GitHub Actions, GitLab CI, Jenkins, and CircleCI. Use when setting up automated builds, configuring caching strategies, running tests in pipelines, or building Docker images in CI. Triggers on "setup Gradle CI", "configure GitHub Actions", "o...

SKILL.md

Full skill instructions

Gradle CI/​CD Integration

Table of Contents

Purpose

Configure Gradle builds for continuous integration and deployment with caching, artifact management, test reporting, and Docker image building. Covers GitHub Actions, GitLab CI, Jenkins, and CircleCI with production-ready optimizations.

When to Use

Use this skill when you need to:

  • Set up automated builds in GitHub Actions, GitLab CI, Jenkins, or CircleCI
  • Configure dependency and build caching for faster CI pipelines
  • Generate and publish test reports in CI/​CD
  • Build and push Docker images in automated pipelines
  • Optimize CI build performance with parallel execution
  • Handle build artifacts and code coverage reports

Quick Start

GitHub Actions .github/​workflows/​build.yml:

name: Build

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/​checkout@v4

    - uses: actions/​setup-java@v4
      with:
        java-version: '21'
        distribution: 'temurin'

    - uses: gradle/​actions/​setup-gradle@v4
      with:
        cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}

    - run: ./​gradlew build --parallel --build-cache --scan

GitLab CI .gitlab-ci.yml:

image: gradle:8.11-jdk21-alpine

variables:
  GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dorg.gradle.caching=true"

build:
  script:
    - ./​gradlew build --parallel --build-cache
  cache:
    paths:
      - .gradle/​wrapper
      - .gradle/​caches

Instructions

Step 1: Use Gradle Wrapper in CI

Always use the Gradle wrapper for consistent versions:

# Use wrapper (recommended)
./​gradlew build

# Not this
gradle build

Ensure wrapper is executable:

chmod +x ./​gradlew
git add gradlew

Step 2: Configure Build Caching

Enable caching in your CI configuration:

GitHub Actions:

- uses: gradle/​actions/​setup-gradle@v4
  with:
    cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
    cache-read-only: ${{ github.ref != 'refs/​heads/​main' }}

GitLab CI:

cache:
  key: "$CI_COMMIT_REF_SLUG"
  paths:
    - .gradle/​wrapper
    - .gradle/​caches

Jenkins:

agent {
    docker {
        image 'gradle:8.11-jdk21'
        args '-v $HOME/​.gradle:/​home/​gradle/​.gradle'
    }
}

See references/​detailed-guide.md for complete caching strategies.

Step 3: Optimize Build Performance

Use these flags for faster CI builds:

./​gradlew build \
  --parallel \              # Parallel execution
  --build-cache \          # Remote build cache
  --configuration-cache \  # Configuration cache (Gradle 8+)
  --scan                   # Build scan for analysis

Configure in gradle.properties:

org.gradle.parallel=true
org.gradle.caching=true
org.gradle.daemon=false  # Disable for CI

Step 4: Configure Test Reporting

JUnit XML reports:

# GitHub Actions
- name: Publish Test Results
  uses: mikepenz/​action-junit-report@v4
  if: always()
  with:
    report_paths: '**/​build/​test-results/​test/​TEST-*.xml'

GitLab CI:

test:
  script:
    - ./​gradlew test
  artifacts:
    reports:
      junit: build/​test-results/​test/​TEST-*.xml

See references/​detailed-guide.md for coverage reporting with JaCoCo.

Step 5: Build and Push Docker Images

GitHub Actions with Jib:

- name: Build Docker Image (PR)
  if: github.event_name == 'pull_request'
  run: ./​gradlew jibDockerBuild

- name: Build and Push (Main)
  if: github.ref == 'refs/​heads/​main'
  run: ./​gradlew jib
  env:
    DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
    DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

GitLab CI:

docker-build:
  stage: deploy
  only:
    - main
  script:
    - ./​gradlew jib
  environment:
    name: production

See references/​detailed-guide.md for Jenkins and CircleCI configurations.

Step 6: Handle Build Artifacts

Upload artifacts:

# GitHub Actions
- name: Upload Build Artifacts
  uses: actions/​upload-artifact@v4
  with:
    name: build-artifacts
    path: |
      build/​libs/
      build/​reports/

GitLab CI:

build:
  artifacts:
    paths:
      - build/​libs/
    expire_in: 1 day

Step 7: Implement Build Scans

Enable build scans for troubleshooting:

// build.gradle.kts
plugins {
    id("com.gradle.enterprise") version "3.16.1"
}

gradleEnterprise {
    buildScan {
        termsOfServiceUrl = "https://gradle.com/​terms-of-service"
        termsOfServiceAgree = "yes"
        publishAlways()
    }
}

Run with --scan:

./​gradlew build --scan

Requirements

  • Gradle Wrapper: 8.11+ recommended
  • Java: JDK 17+ (21 recommended for latest features)
  • CI Platform: GitHub Actions, GitLab CI, Jenkins, or CircleCI
  • Dependencies:
    • gradle/​actions/​setup-gradle@v4 for GitHub Actions
    • Docker for container-based builds
  • Secrets: Store credentials securely
    • GRADLE_ENCRYPTION_KEY for cache encryption
    • DOCKER_USERNAME, DOCKER_PASSWORD for registry auth

See Also

More DevOps & CI/CD skills

Project scaffolding, deployment configuration, and CI/CD setup for Google ADK agents.

6K 472.6K
View

Set up tracing, logging, and monitoring for deployed ADK agents across Cloud Trace, BigQuery, and third-party platforms.

6K 472.6K
View

Enterprise Azure infrastructure architect generating Bicep or Terraform from workload descriptions.

1.5K 454.3K
View
azure-kubernetes logo
DevOps & CI/CD

azure-kubernetes

Plan and configure production-ready Azure Kubernetes Service clusters with Day-0 and Day-1 best practices.

1.5K 447.1K
View

Raw mechanical interfaces fusing Swiss typographic print with military terminal aesthetics. Rigid grids, extreme type scale contrast, utilitarian color, analog degradation effects. For data-heavy dashboards, portfolios, or editorial sites that need to feel like declassified blueprints.

92.7K 354.9K
View
just-scrape logo
DevOps & CI/CD

just-scrape

Web search, scraping, extraction, crawling, and monitoring via ScrapeGraph AI CLI.

69 245K
View

Skill for working with Firebase Hosting (Classic). Use this when you want to deploy static web apps, Single Page Apps (SPAs), or simple microservices. Do NOT use for Firebase App Hosting.

462 159.7K
View

Deploy and manage web apps with Firebase App Hosting. Use this skill when deploying Next.js/Angular apps with backends.

462 159.1K
View
deploy-to-vercel logo
DevOps & CI/CD

deploy-to-vercel

Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment".

31.9K 146.6K
View
programmatic-seo logo
DevOps & CI/CD

programmatic-seo

Build SEO-optimized pages at scale using templates, data, and proven playbook patterns.

53.3K 140.1K
View

Design and build isolated, reusable Convex backend components with clear boundaries and app-facing wrappers.

63 123.5K
View

Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".

31.9K 116.1K
View

Coding & apps AI tools

Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View
Imagica logo
Coding & apps

Imagica

Build a no-code AI app in minutes.

Freemium
View
E
Coding & apps

Emergent.sh

An IDE for code migration from legacy to modern frameworks through coding agents.

Freemium
View
Wonder Dynamics logo
Coding & apps

Wonder Dynamics

Automate CGI animation in live-action scenes

Paid
View
M
Coding & apps

Mixo

Launch a website in seconds with AI.

Paid
View
AI Code Convert logo
Coding & apps

AI Code Convert

Streamline Your Coding Experience with AI Code Helper

Free
View