Publish To Gerrit

Action ID: publish:gerrit
NPM Package:

@backstage/plugin-scaffolder-backend-module-gerrit

Description

Initializes a git repository of the content in the workspace, and publishes it to Gerrit.

Input Schema

PropertyTypeDescriptionRequired
repoUrlstringRepository Location
signCommitbooleanSign commit with configured PGP private key
sourcePathstring-
descriptionstringRepository Description
defaultBranchstring-
gitAuthorNamestring-
gitAuthorEmailstring-
gitCommitMessagestring-

Output Schema

PropertyTypeDescriptionRequired
remoteUrlstringA URL to the repository with the provider
commitHashstringThe git commit hash of the initial commit
repoContentsUrlstringA URL to the root of the repository

Usage Examples

Publish a new service to Gerrit with default branch main

Publishes a freshly generated service to Gerrit using the main branch. Use this when creating a new project with a straightforward initial commit.

Copy
steps:
  - id: fetch-template
    action: fetch:template
    input:
      url: https://github.com/acme/templates/backend-service
      values:
        componentId: ${{ parameters.componentId }}
        owner: ${{ parameters.owner }}
        description: ${{ parameters.description }}

  - id: publish-to-gerrit
    action: publish:gerrit
    input:
      repoUrl: "gerrit.acme.corp?project=platform/${{ parameters.componentId }}"
      description: "Payments API service"
      defaultBranch: main
      gitAuthorName: "Scaffolder Bot"
      gitAuthorEmail: "scaffolder-bot@acme.corp"
      gitCommitMessage: "chore: scaffold ${{ parameters.componentId }} from template"

Publish a subdirectory to Gerrit from a multi-service template

Publishes only a specific subdirectory from the workspace to Gerrit. Use this when your template generates multiple services and you want to create one Gerrit project per service.

Copy
steps:
  - id: fetch-template
    action: fetch:template
    input:
      url: https://github.com/acme/templates/multi-service-repo
      values:
        componentId: ${{ parameters.componentId }}
        language: ${{ parameters.language }}

  - id: publish-service-subdir
    action: publish:gerrit
    input:
      repoUrl: "gerrit.acme.corp?project=services/${{ parameters.componentId }}"
      description: "Service ${{ parameters.componentId }} generated from multi-service template"
      sourcePath: "services/${{ parameters.componentId }}"
      defaultBranch: main
      gitAuthorName: "Scaffolder Bot"
      gitAuthorEmail: "scaffolder-bot@acme.corp"
      gitCommitMessage: "feat: initialize ${{
        parameters.componentId
      }} service"

Publish with signed initial commit and register in the catalog

Publishes with GPG-signed commit metadata and then registers the new component in Backstage. Use this when your organization enforces signed commits.

Copy
steps:
  - id: fetch-template
    action: fetch:template
    input:
      url: https://github.com/acme/templates/node-service
      values:
        componentId: ${{ parameters.componentId }}
        owner: ${{ parameters.owner }}
        description: ${{ parameters.description }}

  - id: publish-gerrit-signed
    action: publish:gerrit
    input:
      repoUrl: "gerrit.acme.corp?project=platform/${{ parameters.componentId }}"
      description: "Node service ${{ parameters.componentId }}"
      defaultBranch: main
      gitAuthorName: ${{ parameters.gitAuthorName }}
      gitAuthorEmail: ${{ parameters.gitAuthorEmail }}
      gitCommitMessage: "chore: initial commit for ${{ parameters.componentId }}"
      signCommit: true

  - id: register
    action: catalog:register
    input:
      catalogInfoUrl: "${{ steps['publish-gerrit-signed'].outputs.repoContentsUrl }}/catalog-info.yaml"

This example uses fetch:template and catalog:register alongside publish:gerrit.

Publish to a non-main default branch develop

Publishes the repository with develop as the default branch. Use this when your workflow promotes changes from develop to main after review.

Copy
steps:
  - id: fetch-skeleton
    action: fetch:plain
    input:
      url: https://github.com/acme/starters/go-service.tar.gz

  - id: publish-to-gerrit-develop
    action: publish:gerrit
    input:
      repoUrl: "gerrit.acme.corp?project=teams/payments/${{ parameters.componentId }}"
      description: "Go service ${{ parameters.componentId }} with develop as default branch"
      defaultBranch: develop
      gitAuthorName: "Backstage CI"
      gitAuthorEmail: "backstage-ci@acme.corp"
      gitCommitMessage: "init(${{
        parameters.componentId
      }}): scaffold on develop"

This example uses fetch:plain to bring in a starter, then publishes to Gerrit.

Publish using dynamic Gerrit host and project from parameters

Builds the repoUrl dynamically from user inputs, useful for multi-tenant Gerrit setups or when selecting a target host at runtime.

Copy
steps:
  - id: fetch-template
    action: fetch:template
    input:
      url: https://github.com/acme/templates/python-lib
      values:
        componentId: ${{ parameters.componentId }}
        owner: ${{ parameters.owner }}

  - id: publish-to-parametrized-gerrit
    action: publish:gerrit
    input:
      repoUrl: "${{ parameters.gerritHost }}?project=${{ parameters.projectPath }}"
      description: "Python library ${{ parameters.componentId }} published to ${{ parameters.projectPath }}"
      defaultBranch: main
      gitAuthorName: ${{ parameters.gitAuthorName }}
      gitAuthorEmail: ${{ parameters.gitAuthorEmail }}
      gitCommitMessage: "build: scaffold ${{ parameters.componentId }}"
      sourcePath: "."

In this example, parameters.gerritHost could be like gerrit.acme.corp and parameters.projectPath like libs/${{ parameters.componentId }}.

Other actions in @backstage/plugin-scaffolder-backend-module-gerrit