Copy Jenkins Job

Action ID: jenkins:job:copy
NPM Package:

@backstage-community/plugin-scaffolder-backend-module-jenkins

Description

Creating a job jenkins given an existing job

Input Schema

PropertyTypeDescriptionRequired
sourceJobNamestringName of the source jenkins item
targetJobNamestringName of the target jenkins item

Output Schema

No output schema defined for this action.

Usage Examples

Copy a seed Jenkins job for a new microservice pipeline

Create a Jenkins pipeline for a new service by copying a curated seed job. After fetching project files with fetch:template, this step copies seed-node-pipeline to a target named from the componentId.

Copy
steps:
  - id: fetch-skeleton
    action: fetch:template
    input:
      url: ./skeleton
      targetPath: ./
      values:
        name: ${{ parameters.componentId }}
        owner: ${{ parameters.owner }}

  - id: copy-jenkins-job
    action: jenkins:job:copy
    input:
      sourceJobName: seed-node-pipeline
      targetJobName: ${{ parameters.componentId }}-pipeline

Create a branch-specific Jenkins job from a template

Copy a template job to provision a branch-specific build. Use this when setting up a pipeline for a repo’s default branch or a long-lived release branch as part of the scaffolding flow with fetch:template.

Copy
steps:
  - id: fetch-base
    action: fetch:template
    input:
      url: ./skeleton
      targetPath: ./
      values:
        name: ${{ parameters.componentId }}
        defaultBranch: ${{ parameters.defaultBranch }}

  - id: copy-jenkins-job
    action: jenkins:job:copy
    input:
      sourceJobName: ${{ parameters.jobTemplateName }}
      targetJobName: ${{ parameters.componentId }}-${{ parameters.defaultBranch }}