Pipery Java CI#

Reusable GitHub Action for a complete Java CI pipeline with structured logging via Pipery.

GitHub Marketplace Version License: MIT

Table of Contents#

Quick Start#

name: CI
on: [push, pull_request]

jobs:
  ci:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: pipery-dev/java-ci@v1.1.0
        with:
          project_path: .
          java_version: "21"
          github_token: ${{ secrets.GITHUB_TOKEN }}

Pipeline Overview#

StepToolSkip InputDescription
SASTSpotBugs, PMDskip_sastDetects Java security and quality issues
SCAOWASP Dependency-Checkskip_scaIdentifies vulnerable dependencies
LintCheckstyleskip_lintEnforces code style
BuildMaven/Gradle/Ant/Groovyskip_buildCompiles Java project
TestJUnitskip_testRuns unit and integration tests
VersionSemantic versioningskip_versioningBumps version and creates git tag
PackageMaven package / Gradle build / Ant targetskip_packagingCreates JAR/Docker artifact
ReleaseMaven Central / Docker pushskip_releasePublishes to registry
ReintegrateGit mergeskip_reintegrationMerges back to default branch

Configuration Options#

NameDefaultDescription
project_path.Path to the project source tree.
config_file.pipery/config.yamlPath to Pipery config file.
java_version21Java version to use (e.g., 11, 17, 21).
build_toolautoBuild tool to use: auto, maven, gradle, ant, or groovy.
tests_path``Test target passed to the build tool (e.g., a test class or pattern).
registryghcr.ioContainer registry for packaging.
registry_username``Registry username for authentication.
registry_password``Registry password for authentication.
version_bumppatchVersion bump type: patch, minor, or major.
target_branchmainTarget branch for reintegration.
github_token``GitHub token for release and reintegration.
log_filepipery.jsonlPath to the JSONL structured log file.
skip_sastfalseSkip the SAST step.
skip_scafalseSkip the SCA step.
skip_lintfalseSkip the lint step.
skip_buildfalseSkip the build step.
skip_testfalseSkip the test step.
skip_versioningfalseSkip the versioning step.
skip_packagingfalseSkip the packaging step.
skip_releasefalseSkip the release step.
skip_reintegrationfalseSkip the reintegration step.

Usage Examples#

Example 1: Maven project with Java 21#

name: CI
on: [push, pull_request]

jobs:
  ci:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: pipery-dev/java-ci@v1.1.0
        with:
          project_path: .
          java_version: "21"
          build_tool: maven
          github_token: ${{ secrets.GITHUB_TOKEN }}

Example 2: Gradle project with Java 17#

- uses: pipery-dev/java-ci@v1.1.0
  with:
    project_path: .
    java_version: "17"
    build_tool: gradle
    github_token: ${{ secrets.GITHUB_TOKEN }}

Example 3: Run specific test suite#

- uses: pipery-dev/java-ci@v1.1.0
  with:
    project_path: .
    build_tool: maven
    tests_path: com.example.IntegrationTest
    github_token: ${{ secrets.GITHUB_TOKEN }}

Example 4: Docker image packaging and push#

- uses: pipery-dev/java-ci@v1.1.0
  with:
    project_path: .
    build_tool: gradle
    registry: ghcr.io
    registry_username: ${{ secrets.REGISTRY_USERNAME }}
    registry_password: ${{ secrets.REGISTRY_PASSWORD }}
    github_token: ${{ secrets.GITHUB_TOKEN }}

Example 5: Skip security checks for faster CI#

- uses: pipery-dev/java-ci@v1.1.0
  with:
    project_path: .
    skip_sast: true
    skip_sca: true
    github_token: ${{ secrets.GITHUB_TOKEN }}

Example 6: Major version bump for release#

- uses: pipery-dev/java-ci@v1.1.0
  with:
    project_path: .
    version_bump: major
    registry_password: ${{ secrets.REGISTRY_PASSWORD }}
    github_token: ${{ secrets.GITHUB_TOKEN }}

GitLab CI#

Use the GitLab mirror template when .gitlab-ci.yml is published for this pipeline family. Import it from the mirrored GitLab project or use it as a reference implementation for running the same Pipery pipeline outside GitHub Actions.

The GitLab pipeline maps action inputs to CI/CD variables, publishes pipery.jsonl as an artifact, and maintains the same skip controls. Store credentials as protected GitLab CI/CD variables.

include:
  - project: pipery-dev/java-ci
    ref: v1.1.0
    file: /.gitlab-ci.yml

GitLab CI Variables#

Configure these protected variables in Settings > CI/CD > Variables:

  • GITHUB_TOKEN - GitHub API access for release and reintegration
  • REGISTRY_PASSWORD - Container registry password (if packaging)
  • JAVA_VERSION - Java version (default: 21)
  • BUILD_TOOL - maven/gradle/ant/groovy/auto (default: auto)
  • VERSION_BUMP - patch/minor/major (default: patch)

Bitbucket Pipelines#

Bitbucket Cloud pipelines provide an alternative to GitHub Actions. Use Bitbucket shared pipeline imports to reference the exported Pipery pipeline instead of copying YAML into every application repository.

Getting Started#

  1. Add a Bitbucket import source for the shared Pipery pipeline and import the exported pipeline by name:
definitions:
  imports:
    pipery-shared: pipery-dev/java-ci:v1.1.0
    pipery-custom: pipery-dev/java-ci:v1.1.0:.bitbucket/shared-pipelines.yml

pipelines:
  branches:
    main:
      import: pipery-java-ci@pipery-shared

  custom:
    run-pipery:
      import: pipery-java-ci@pipery-custom

Use {project-path}/{repo-slug}:{branch-or-tag} for a shared repository bitbucket-pipelines.yml, or {project-path}/{repo-slug}:{branch-or-tag}:{config-filepath} for another exported YAML file.

  1. Configure Protected Variables in Repository Settings > Pipelines > Repository Variables:
    • GITHUB_TOKEN - GitHub API access (for release and reintegration)
    • REGISTRY_PASSWORD - Container registry password
    • JAVA_VERSION - Java version (default: 21)
  2. Commit and push to trigger the pipeline

Pipeline Stages#

The Bitbucket equivalent follows the same structure:

checkout → setup → SAST (SpotBugs, PMD) → SCA (Dependency-Check) → lint (Checkstyle) → build → test → versioning → packaging → release → reintegration → logs

Skip Flags#

Disable any stage using environment variables:

  • SKIP_SAST, SKIP_SCA, SKIP_LINT, SKIP_BUILD, SKIP_TEST, SKIP_VERSIONING, SKIP_PACKAGING, SKIP_RELEASE, SKIP_REINTEGRATION

Example: Set SKIP_LINT=true to skip code style enforcement.

Features#

  • Multiple Java versions (11, 17, 21)
  • Maven and Gradle support
  • Static analysis (SpotBugs, PMD, Checkstyle)
  • Dependency vulnerability checking
  • Docker image packaging
  • Automatic versioning and tagging
  • JSONL-based pipeline logging
  • 30-90 day artifact retention

About Pipery#

Pipery Pipery is an open-source CI/CD observability platform. Every step script runs under psh (Pipery Shell), which intercepts all commands and emits structured JSONL events — giving you full visibility into your pipeline without any manual instrumentation.

Development#

# Run the action locally against test-project/
pipery-actions test --repo .

# Regenerate docs
pipery-actions docs --repo .

# Dry-run release
pipery-actions release --repo . --dry-run