Cloud customer?
Start for Free >
Upgrade in MyJFrog >
What's New in Cloud >





Overview

Global Templates are a set of templates that are shipped with Pipelines and available to all Pipelines users. Unlike other templates, such as system and local, global templates cannot be added as a template source and cannot be modified.


To use global templates while adding a pipeline source, a values.yml file should be available in the pipeline source repository. As shown in the examples below, the values.yml file should contain the values required for the global template to create the pipeline definition.

Pipelines currently includes the following global templates: 

Page Contents


HelloWorld

The HelloWorld template creates a simple pipeline that showcases a few of the basic features of JFrog Pipelines. 

  • Parallel steps
  • Reading and writing variables that persist across different steps in your pipeline
  • Reading from and writing to resources
  • Setting environment variables

This template does not require any special configuration or pre-existing integration for you to try.


HelloWorld
resources:
  - name: {{ .Values.namePrefix }}_bag
    type: PropertyBag
    configuration:
      releaseVersion: ""

{{ if .Values.repo.integrationName }}
  - name: {{ .Values.namePrefix }}_repo
    type: GitRepo
    configuration:
      path: {{ .Values.repo.path }}
      gitProvider: {{ .Values.repo.integrationName }}
      branches:
        include: {{ .Values.repo.branchPattern }}
{{ end }}

pipelines:
  - name: {{ .Values.namePrefix }}_hello_world
    steps:
      - name: first
        type: Bash
        {{ if .Values.repo.integrationName }}
        configuration:
          inputResources:
            - name: {{ .Values.namePrefix }}_repo
        {{ end }}
        execution:
          onStart:
            - echo "onStart can be used to do some setup or initialization of your dependencies to prepare for the execution."
          onExecute:
            - echo "onExecute is the main section where you would issue your build/test commands"
            - jfrog --version
          {{ if .Values.repo.integrationName }}
            - echo "{{ .Values.namePrefix }}_repo sha is $(find_resource_variable {{ .Values.namePrefix }}_repo commitSha)"
          {{ end }}
          onSuccess:
            - echo "onSuccess executes if the onStart or onExecute sections completed without errors"
          onFailure:
            - echo "onFailure executes if either onStart or onExecute end in failure or error."
          onComplete:
            - echo "onComplete executes after onSuccess or onFailure"

      - name: variable_selection
        type: Bash
        configuration:
          inputSteps:
            - name: first
          environmentVariables:
            forceFail:
              default: "false"
              description: "set to 'true' to force the step to fail."
              values:
                - "false"
                - "true"
        execution:
          onStart:
            - if [ ${forceFail} == "true" ]; then exit 1; fi
          onExecute:
            - echo "This step will succeed"
          onFailure:
            - echo "step has failed."
          onSuccess:
            - echo "step has succeeded."
          onComplete:
            - echo "onComplete executes regardless of success or failure. forceFail is ${forceFail}"

      - name: add_run_variable
        type: Bash
        configuration:
          inputSteps:
            - name: first
        execution:
          onStart:
            - echo "This step will save a value to a run variable."
          onExecute:
            - add_run_variables step_info="runNumber $run_number, step_name $step_name, pipeline_name $pipeline_name"

      - name: write_to_resource
        type: Bash
        configuration:
          inputSteps:
            - name: add_run_variable
            - name: variable_selection
          outputResources:
            - name: {{ .Values.namePrefix }}_bag
        execution:
          onStart:
            - echo "Printing the run variable 'step_info' from previous step"
            - echo "${step_info}"
          onExecute:
            - echo "Updating resource {{ .Values.namePrefix }}_bag with new key/value pairs"
            - write_output {{ .Values.namePrefix }}_bag "timestamp=$(date +%s)"
            - write_output {{ .Values.namePrefix }}_bag "releaseVersion=${pipeline_name}.${run_number}"
            - write_output {{ .Values.namePrefix }}_bag "stepInfo=${step_info}"

      - name: read_from_resource
        type: Bash
        configuration:
          inputResources:
            - name: {{ .Values.namePrefix }}_bag
        execution:
          onExecute:
            - echo "printing resource details"
            - echo "Release Version is -- ${res_{{ .Values.namePrefix }}_bag_releaseVersion}"
            - echo "Release timestamp is -- ${res_{{ .Values.namePrefix }}_bag_timestamp}"
            - echo "Step Info is -- ${res_{{ .Values.namePrefix }}_bag_stepInfo}"


values.yml: This is a sample values.yml. This can be edited to create your own version of the file.

values.yml
# This string will prefix the "HelloWorld" resource and pipeline.
# it will allow you to add the pipeline multiple times with unique names
namePrefix: intro

##
# The following section is optional. If you have a repository you'd like to
# experiment with, you can add it here.
##
repo:
  # Before creating your Pipeline Source, create an integration for one of the
  # source control providers and put the integration name here.
  integrationName: myGitIntegration

  # this is the full repository path. Usually org/repo or user/project
  # depending on which source control you use.
  path: "myorgname/myreponame"

  # branchPattern is a regex, so you could listen to all
  # features, for example, with "^feature.*", or you can
  # just configure it for an individual branch
  branchPattern: "^main$"

GoCI

The GoCI template creates a pipeline that showcases the features of the GoBuild, GoPublishBinary, and GoPublishModule native steps. These features include:

  • Building a Go binary and pushing the resulting artifact to Artifactory
  • Building a Go module and pushing the resulting artifact to Artifactory
  • Publishing Artifactory builds and updating output BuildInfo resources
  • Utilizing JFrog Xray to scan the artifacts for security vulnerabilities
  • Writing to output FileSpec resources that can be connected other pipelines.

This template can be used for binaries, modules, or both and the required configurations vary depending on the ultimate goal. Configuration must include the required settings for either GoBuild and GoPublishBinary or GoPublishModule and may include both to publish a binary and module.

In all cases these configurations must be set up:

  • An Artifactory integration for resolving dependencies and publishing artifacts
  • A Git integration (like GitHub) that can connect with your Gradle project
  • A resolver Artifactory repository from which to resolve dependencies

Publishing a binary with GoBuild and GoPublishBinary requires:

  • A binaryTargetRepository Artifactory repository to which to publish
  • A command to run as part of the GoBuild step (the part following "go")
  • An output file name

Publishing a binary with GoPublishModule requires:

  • A moduleTargetRepository Artifactory repository to which to publish
  • A version

GoCI
resources:
  - name: {{ .Values.namePrefix }}_repo
    type: GitRepo
    configuration:
      path: {{ .Values.repo.path }}
      gitProvider: {{ .Values.repo.gitIntegration }}
      branches:
        include: {{ .Values.repo.branchPattern | default "main" }}

{{ if .Values.publishBuild }}
  {{ if .Values.goConfig.binaryTargetRepository }}
  - name: {{ .Values.namePrefix }}_binary_info
    type: BuildInfo
    configuration:
      sourceArtifactory: {{ .Values.artIntegration }}

  - name: {{ .Values.namePrefix }}_binary_spec
    type: FileSpec
    configuration:
      sourceArtifactory: {{ .Values.artIntegration }}
      pattern: '{{ .Values.binaryBuildSpecPattern | default "*" }}'
      buildName: ${JFROG_CLI_BUILD_NAME}
      buildNumber: ${JFROG_CLI_BUILD_NUMBER}
  {{ end }}

  {{ if .Values.goConfig.moduleTargetRepository }}
  - name: {{ .Values.namePrefix }}_module_info
    type: BuildInfo
    configuration:
      sourceArtifactory: {{ .Values.artIntegration }}

  - name: {{ .Values.namePrefix }}_module_spec
    type: FileSpec
    configuration:
      sourceArtifactory: {{ .Values.artIntegration }}
      pattern: '{{ .Values.moduleBuildSpecPattern | default "*" }}'
      buildName: ${JFROG_CLI_BUILD_NAME}
      buildNumber: ${JFROG_CLI_BUILD_NUMBER}
  {{ end }}

{{ end }}


pipelines:
  - name: {{ .Values.namePrefix }}_go_ci
    steps:
    {{ if .Values.goConfig.binaryTargetRepository }}
      - name: build
        type: GoBuild
        configuration:
          affinityGroup: {{ .Values.namePrefix }}_go_binary_ci
          environmentVariables:
            JFROG_CLI_BUILD_NAME: {{ .Values.namePrefix }}_go_binary_ci
            JFROG_CLI_BUILD_NUMBER: ${run_id}
          integrations:
            - name: {{ .Values.artIntegration }}
          inputResources:
            - name: {{ .Values.namePrefix }}_repo
        {{ if .Values.goConfig.command }}
          goCommand: {{ .Values.goConfig.command }}
        {{ end }}
        {{ if .Values.goConfig.sourceLocation }}
          sourceLocation: {{ .Values.goConfig.sourceLocation }}
        {{ end }}
        {{ if .Values.goConfig.resolverRepo }}
          resolverRepo: {{ .Values.goConfig.resolverRepo }}
        {{ end }}
        {{ if .Values.goConfig.outputLocation }}
          outputLocation: {{ .Values.goConfig.outputLocation }}
        {{ end }}
        {{ if .Values.goConfig.outputFile }}
          outputFile: {{ .Values.goConfig.outputFile }}
        {{ end }}

      - name: publish
        type: GoPublishBinary
        configuration:
          affinityGroup: {{ .Values.namePrefix }}_go_binary_ci
          environmentVariables:
            JFROG_CLI_BUILD_NAME: {{ .Values.namePrefix }}_go_binary_ci
            JFROG_CLI_BUILD_NUMBER: ${run_id}
          integrations:
            - name: {{ .Values.artIntegration }}
          inputSteps:
            - name: build
        {{ if .Values.publishBuild }}
          outputResources:
            - name: {{ .Values.namePrefix }}_binary_info
            - name: {{ .Values.namePrefix }}_binary_spec
        {{ end }}
        {{ if .Values.publishBuild }}
          autoPublishBuildInfo: true
        {{ end }}
        {{ if and .Values.scanBuild .Values.publishBuild }}
          forceXrayScan: true
        {{ end }}
          targetRepository: {{ .Values.goConfig.binaryTargetRepository }}

      {{ if .Values.publishBuild }}
        execution:
          onSuccess:
            - write_output {{ .Values.namePrefix }}_binary_spec buildName="${JFROG_CLI_BUILD_NAME}"
            - write_output {{ .Values.namePrefix }}_binary_spec buildNumber="${JFROG_CLI_BUILD_NUMBER}"
      {{ end }}
    {{ end }}

    {{ if .Values.goConfig.moduleTargetRepository }}
      - name: module
        type: GoPublishModule
        configuration:
          environmentVariables:
            JFROG_CLI_BUILD_NAME: {{ .Values.namePrefix }}_go_module_ci
            JFROG_CLI_BUILD_NUMBER: ${run_id}
          integrations:
            - name: {{ .Values.artIntegration }}
          inputResources:
            - name: {{ .Values.namePrefix }}_repo
        {{ if .Values.publishBuild }}
          outputResources:
            - name: {{ .Values.namePrefix }}_module_info
            - name: {{ .Values.namePrefix }}_module_spec
        {{ end }}
        {{ if .Values.goConfig.sourceLocation }}
          sourceLocation: {{ .Values.goConfig.sourceLocation }}
        {{ end }}
        {{ if .Values.goConfig.version }}
          version: {{ .Values.goConfig.version }}
        {{ end }}
          targetRepository: {{ .Values.goConfig.moduleTargetRepository }}
        {{ if .Values.goConfig.resolverRepo }}
          resolverRepo: {{ .Values.goConfig.resolverRepo }}
        {{ end }}
        {{ if .Values.publishBuild }}
          autoPublishBuildInfo: true
        {{ end }}
        {{ if and .Values.scanBuild .Values.publishBuild }}
          forceXrayScan: true
        {{ end }}
      {{ if .Values.publishBuild }}
        execution:
          onSuccess:
            - write_output {{ .Values.namePrefix }}_module_spec buildName="${JFROG_CLI_BUILD_NAME}"
            - write_output {{ .Values.namePrefix }}_module_spec buildNumber="${JFROG_CLI_BUILD_NUMBER}"
      {{ end }}
    {{ end }}


values.yml: This is a sample values.yml. This can be edited to create your own version of the file.

values.yml
## This string will prefix the resources and pipeline, allowing you to add
## the pipeline source multiple times with unique names.
namePrefix: sample

## The name of your Artifactory integration
artIntegration: myArtIntegrationName

##### Artifactory Build Info
## set this to `true` to publish builds
#publishBuild: true
## set this to `true` to scan the published build(s)
#scanBuild: true
## When publishBuild is enabled, a FileSpec resource will be created
## that points to each published build. Here you can specify a pattern
## to further narrow down the Artifacts that are referenced by the specs.
## The binaryBuildSpecPattern filters the files included for the FileSpec
## output by the GoPublishBinary step.
#binaryBuildSpecPattern: "*"
## The moduleBuildSpecPattern filters the files included for the FileSpec
## output by the GoPublishModule step.
#moduleBuildSpecPattern: "*"

##### Repository Details
repo:
  path: org/repo
  gitIntegration: myGitIntegration
  branchPattern: "^main$"

goConfig:
  ### Settings used for both modules and binaries:
  ## The location of the source code in your repository.
  ## Commands will be executed here.
  sourceLocation: "."
  ## This repository, if specified, must first be created in Artifactory.
  ## The resolver is used to resolve dependencies. It is recommended to
  ## use a remote repository so that any external dependencies will be cached
  ## in your local Artifactory instance.
  resolverRepo: go-remote

  ### Settings used only for GoBuild and GoPublishBinary:
  ## Required to use these steps, the repository to which to upload the binary.
  ## The repository must first be created in Artifactory.
  binaryTargetRepository: go-local
  ## Here you specify any additional arguments to the command to execute
  ## it is executed as `go {{ command }}`
  command: "build -o $outputLocation/$outputFile"
  outputLocation: "GoBuild"
  outputFile: "myOutputFile"

  ### Settings used only for GoPublishModule:
  ## Required to use this step, the repository to which to upload the module.
  ## The repository must first be created in Artifactory.
  moduleTargetRepository: go-local
  ## The version specified in the go-publish command.
  version: v1.0.${run_number}

GradleCI

The GradleCI template creates a pipeline that showcases the features of the GradleBuild native step. These features include:

  • Building a Gradle project and pushing the resulting artifacts to Artifactory
  • Publishing an Artifactory build and updating an output BuildInfo resource
  • Utilizing JFrog Xray to scan the artifacts for security vulnerabilities
  • Writing to an output FileSpec resource that can be connected to another pipeline.

This template requires a few configurations to be set up:

  • An Artifactory integration for resolving dependencies and publishing artifacts
  • A Git integration (like GitHub) that can connect with your Gradle project
  • Resolver and deployer Artifactory repositories
  • A Gradle command to run as part of the GradleBuild step (the part following "gradle")


GradleCI
resources:
  - name: {{ .Values.namePrefix }}_repo
    type: GitRepo
    configuration:
      path: {{ .Values.repo.path }}
      gitProvider: {{ .Values.repo.gitIntegration }}
      branches:
        include: {{ .Values.repo.branchPattern | default "main" }}

{{ if .Values.publishBuild }}
  - name: {{ .Values.namePrefix }}_info
    type: BuildInfo
    configuration:
      sourceArtifactory: {{ .Values.artIntegration }}

  - name: {{ .Values.namePrefix }}_spec
    type: FileSpec
    configuration:
      sourceArtifactory: {{ .Values.artIntegration }}
      pattern: '{{ .Values.buildSpecPattern | default "*" }}'
      buildName: ${JFROG_CLI_BUILD_NAME}
      buildNumber: ${JFROG_CLI_BUILD_NUMBER}
{{ end }}


pipelines:
  - name: {{ .Values.namePrefix }}_gradle_ci
{{ if .Values.publishBuild }}
    configuration:
      environmentVariables:
        readOnly:
          JFROG_CLI_BUILD_NAME: ${pipeline_name}
          JFROG_CLI_BUILD_NUMBER: ${run_id}
{{ end }}
    steps:
      - name: build
        type: GradleBuild
        configuration:
          integrations:
            - name: {{ .Values.artIntegration }}
          inputResources:
            - name: {{ .Values.namePrefix }}_repo
        {{ if .Values.publishBuild }}
          outputResources:
            - name: {{ .Values.namePrefix }}_info
            - name: {{ .Values.namePrefix }}_spec
        {{ end }}
        {{ if .Values.publishBuild }}
          autoPublishBuildInfo: true
        {{ end }}
        {{ if and .Values.scanBuild .Values.publishBuild }}
          forceXrayScan: true
        {{ end }}
        {{ if .Values.gradleConfig.command }}
          gradleCommand: {{ .Values.gradleConfig.command }}
        {{ end }}
        {{ if .Values.gradleConfig.sourceLocation }}
          sourceLocation: {{ .Values.gradleConfig.sourceLocation }}
        {{ end }}
        {{ if .Values.useWrapper }}
          useWrapper: true
        {{ end }}
        {{ if .Values.gradleConfig.resolverRepo }}
          resolverRepo: {{ .Values.gradleConfig.resolverRepo }}
        {{ end }}
        {{ if .Values.gradleConfig.deployerRepo }}
          deployerRepo: {{ .Values.gradleConfig.deployerRepo }}
        {{ end }}
      {{ if .Values.publishBuild }}
        execution:
          onSuccess:
            - write_output {{ .Values.namePrefix }}_spec buildName="${JFROG_CLI_BUILD_NAME}"
            - write_output {{ .Values.namePrefix }}_spec buildNumber="${JFROG_CLI_BUILD_NUMBER}"
      {{ end }}


values.yml: This is a sample values.yml. This can be edited to create your own version of the file.

values.yml
## This string will prefix the resources and pipeline, allowing you to add
## the pipeline source multiple times with unique names.
namePrefix: sample

## The name of your Artifactory integration
artIntegration: myArtIntegrationName

##### Artifactory Build Info
## set this to `true` to publish a build
#publishBuild: true
## set this to `true` to scan the published build
#scanBuild: true
## When publishBuild is enabled, a FileSpec resource will be created
## that points to the published build. Here you can specify a pattern
## to further narrow down the Artifacts that are referenced by the spec.
#buildSpecPattern: "*"

##### Repository Details
repo:
  path: org/repo
  gitIntegration: myGitIntegration
  branchPattern: "^main$"

##### Gradle configuration
gradleConfig:
  ## Here you specify the command to execute
  ## it is executed as `gradle {{ command }}`
  command: "hello"
  sourceLocation: "."
  ## These repositories must first be created in Artifactory.
  ## The resolver is used to resolve dependencies. It is recommended to
  ## use a remote repository so that any external dependencies will be cached
  ## in your local Artifactory instance. Deployer is where your Artifacts
  ## will be uploaded.
  resolverRepo: gradle-remote
  deployerRepo: gradle-local
  ## If your project uses the Gradle Wrapper set useWrapper to true
  #useWrapper: true  

MavenCI

The MavenCI template creates a pipeline that showcases the features of the MvnBuild native step. These features include:

  • Building a Maven project and pushing the resulting artifacts to Artifactory
  • Publishing an Artifactory build and updating an output BuildInfo resource
  • Utilizing JFrog Xray to scan the artifacts for security vulnerabilities
  • Writing to an output FileSpec resource that can be connected to another pipeline

This template requires a few configurations to be set up:

  • An Artifactory integration for resolving dependencies and publishing artifacts
  • A Git integration (like GitHub) that can connect with your Maven project
  • Resolver and deployer Artifactory Maven repositories for snapshots and releases


MavenCI
resources:
  - name: {{ .Values.namePrefix }}_repo
    type: GitRepo
    configuration:
      path: {{ .Values.repo.path }}
      gitProvider: {{ .Values.repo.gitIntegration }}
      branches:
        include: {{ .Values.repo.branchPattern | default "main" }}

{{ if .Values.publishBuild }}
  - name: {{ .Values.namePrefix }}_info
    type: BuildInfo
    configuration:
      sourceArtifactory: {{ .Values.artIntegration }}

  - name: {{ .Values.namePrefix }}_spec
    type: FileSpec
    configuration:
      sourceArtifactory: {{ .Values.artIntegration }}
      pattern: '{{ .Values.buildSpecPattern | default "*" }}'
      buildName: ${JFROG_CLI_BUILD_NAME}
      buildNumber: ${JFROG_CLI_BUILD_NUMBER}
{{ end }}


pipelines:
  - name: {{ .Values.namePrefix }}_maven_ci
{{ if .Values.publishBuild }}
    configuration:
      environmentVariables:
        readOnly:
          JFROG_CLI_BUILD_NAME: ${pipeline_name}
          JFROG_CLI_BUILD_NUMBER: ${run_id}
{{ end }}
    steps:
      - name: build
        type: MvnBuild
        configuration:
          integrations:
            - name: {{ .Values.artIntegration }}
          inputResources:
            - name: {{ .Values.namePrefix }}_repo
        {{ if .Values.publishBuild }}
          outputResources:
            - name: {{ .Values.namePrefix }}_info
            - name: {{ .Values.namePrefix }}_spec
          autoPublishBuildInfo: true
        {{ end }}
        {{ if and .Values.scanBuild .Values.publishBuild }}
          forceXrayScan: true
        {{ end }}
        {{ if .Values.mavenConfig.command }}
          mvnCommand: {{ .Values.mavenConfig.command }}
        {{ end }}
        {{ if .Values.mavenConfig.sourceLocation }}
          sourceLocation: {{ .Values.mavenConfig.sourceLocation }}
        {{ end }}
        {{ if .Values.mavenConfig.resolverSnapshotRepo }}
          resolverSnapshotRepo: {{ .Values.mavenConfig.resolverSnapshotRepo }}
        {{ end }}
        {{ if .Values.mavenConfig.deployerSnapshotRepo }}
          deployerSnapshotRepo: {{ .Values.mavenConfig.deployerSnapshotRepo }}
        {{ end }}
        {{ if .Values.mavenConfig.resolverReleaseRepo }}
          resolverReleaseRepo: {{ .Values.mavenConfig.resolverReleaseRepo }}
        {{ end }}
        {{ if .Values.mavenConfig.deployerReleaseRepo }}
          deployerReleaseRepo: {{ .Values.mavenConfig.deployerReleaseRepo }}
        {{ end }}
      {{ if .Values.publishBuild }}
        execution:
          onSuccess:
            - write_output {{ .Values.namePrefix }}_spec buildName="${JFROG_CLI_BUILD_NAME}"
            - write_output {{ .Values.namePrefix }}_spec buildNumber="${JFROG_CLI_BUILD_NUMBER}"
      {{ end }}


values.yml: This is a sample values.yml. This can be edited to create your own version of the file.

values.yml
## This string will prefix the resources and pipeline.
## It will allow you to add a pipeline source from this
## template multiple times with unique names.
namePrefix: sample

## The name of your Artifactory integration
artIntegration: myArtIntegrationName

##### Artifactory Build Info
## set this to `true` to publish a build
#publishBuild: true
## set this to `true` to scan the published build
#scanBuild: true
## When publishBuild is enabled, a FileSpec resource will be created
## that points to the published build. Here you can specify a pattern
## to further narrow down the Artifacts that are referenced by the spec.
#buildSpecPattern: "*"

##### Repository Details
repo:
  path: org/repo
  gitIntegration: myGitIntegration
  branchPattern: "^main$"

##### Maven configuration
mavenConfig:
  ## Here you specify the command to execute
  ## it is executed as `mvn {{ command }}`
  command: clean install
  sourceLocation: "MavenCI/sample-project"
  ## These repos must first be created in Artifactory.
  ## resolver is used to resolve dependencies. It is recommended to
  ## use a remote repository so that any external dependencies will be cached
  ## in your local Artifactory instance. Deployer is where your Artifacts
  ## will be uploaded.
  resolverSnapshotRepo: maven-snapshot-remote
  resolverReleaseRepo: maven-release-remote
  deployerSnapshotRepo: maven-snapshot-local
  deployerReleaseRepo: maven-release-local


NpmCI

The NpmCI template creates a pipeline that showcases the features of the NpmBuild and NpmPublish native steps. These features include:

  • Building an npm project and pushing the resulting artifacts to Artifactory
  • Publishing an Artifactory build and updating an output BuildInfo resource
  • Utilizing JFrog Xray to scan the artifacts for security vulnerabilities
  • Writing to an output FileSpec resource that can be connected to another pipeline.

This template requires a few configurations to be set up:

  • An Artifactory integration for resolving dependencies and publishing artifacts
  • A Git integration (like GitHub) that can connect with your npm project
  • Resolver and deployer Artifactory repositories


NpmCI
resources:
  - name: {{ .Values.namePrefix }}_repo
    type: GitRepo
    configuration:
      path: {{ .Values.repo.path }}
      gitProvider: {{ .Values.repo.gitIntegration }}
      branches:
        include: {{ .Values.repo.branchPattern | default "main" }}

{{ if .Values.publishBuild }}
  - name: {{ .Values.namePrefix }}_info
    type: BuildInfo
    configuration:
      sourceArtifactory: {{ .Values.artIntegration }}

  - name: {{ .Values.namePrefix }}_spec
    type: FileSpec
    configuration:
      sourceArtifactory: {{ .Values.artIntegration }}
      pattern: '{{ .Values.buildSpecPattern | default "*" }}'
      buildName: ${JFROG_CLI_BUILD_NAME}
      buildNumber: ${JFROG_CLI_BUILD_NUMBER}
{{ end }}


pipelines:
  - name: {{ .Values.namePrefix }}_npm_ci
    configuration:
      affinityGroup: {{ .Values.namePrefix }}_npm_ci
    {{ if .Values.publishBuild }}
      environmentVariables:
        readOnly:
          JFROG_CLI_BUILD_NAME: ${pipeline_name}
          JFROG_CLI_BUILD_NUMBER: ${run_id}
    {{ end }}
    steps:
      - name: build
        type: NpmBuild
        configuration:
          integrations:
            - name: {{ .Values.artIntegration }}
          inputResources:
            - name: {{ .Values.namePrefix }}_repo

        {{ if .Values.npmConfig.npmArgs }}
          npmArgs: {{ .Values.npmConfig.npmArgs }}
        {{ end }}
        {{ if .Values.npmConfig.sourceLocation }}
          sourceLocation: {{ .Values.npmConfig.sourceLocation }}
        {{ end }}
        {{ if .Values.npmConfig.resolverRepo }}
          resolverRepo: {{ .Values.npmConfig.resolverRepo }}
        {{ end }}

      - name: publish
        type: NpmPublish
        configuration:
          integrations:
            - name: {{ .Values.artIntegration }}
          inputSteps:
            - name: build
        {{ if .Values.publishBuild }}
          outputResources:
            - name: {{ .Values.namePrefix }}_info
            - name: {{ .Values.namePrefix }}_spec
        {{ end }}
        {{ if .Values.publishBuild }}
          autoPublishBuildInfo: true
        {{ end }}
        {{ if and .Values.scanBuild .Values.publishBuild }}
          forceXrayScan: true
        {{ end }}
        {{ if .Values.npmConfig.deployerRepo }}
          deployerRepo: {{ .Values.npmConfig.deployerRepo }}
        {{ end }}
      {{ if .Values.publishBuild }}
        execution:
          onSuccess:
            - write_output {{ .Values.namePrefix }}_spec buildName="${JFROG_CLI_BUILD_NAME}"
            - write_output {{ .Values.namePrefix }}_spec buildNumber="${JFROG_CLI_BUILD_NUMBER}"
      {{ end }}


values.yml: This is a sample values.yml. This can be edited to create your own version of the file.

values.yml
## This string will prefix the resources and pipeline, allowing you to add
## the pipeline source multiple times with unique names.
namePrefix: sample

## The name of your Artifactory integration
artIntegration: myArtIntegrationName

##### Artifactory Build Info
## set this to `true` to publish a build
#publishBuild: true
## set this to `true` to scan the published build
#scanBuild: true
## When publishBuild is enabled, a FileSpec resource will be created
## that points to the published build. Here you can specify a pattern
## to further narrow down the Artifacts that are referenced by the spec.
#buildSpecPattern: "*"

##### Repository Details
repo:
  path: org/repo
  gitIntegration: myGitIntegration
  branchPattern: "^main$"

npmConfig:
  ## Here you specify any additional arguments to the command to execute
  ## it is executed as `npm install {{ npmArgs }}`
  npmArgs: "--no-install"
  sourceLocation: "."
  ## These repositories must first be created in Artifactory.
  ## The resolver is used to resolve dependencies. It is recommended to
  ## use a remote repository so that any external dependencies will be cached
  ## in your local Artifactory instance. Deployer is where your Artifacts
  ## will be uploaded.
  resolverRepo: npm-remote
  deployerRepo: npm-local

DockerBuildAndPush

The DockerBuildAndPush template creates a pipeline that builds a Docker image from an SCM repository and pushes it to a Docker registry. Version 1.0.0 of this template uses JFrog CLI v1 and version 1.1.0 uses JFrog CLI v2. Template version 1.0.0 requires targetRepository and sourceRepository settings (see template readme) and template version 1.1.0 does not use these settings.

DockerBuildAndPush.yml
resources:
  - name: {{ .Values.GitRepo.name | default "GitRepoRes" }}
    type: GitRepo
    configuration:
      gitProvider: {{ .Values.GitRepo.gitProvider }}
      path: {{ .Values.GitRepo.path }}
      {{- if or (.Values.GitRepo.branches.include) (.Values.GitRepo.branches.exclude) }}
      branches:
        {{- if .Values.GitRepo.branches.include }}
          include: {{ .Values.GitRepo.branches.include }}
        {{- end }}
        {{- if .Values.GitRepo.branches.exclude }}
          exclude: {{ .Values.GitRepo.branches.exclude }}
        {{- end }}
      {{- end }}

  - name: {{ .Values.Image.name | default "ImageRes" }}
    type: Image
    configuration:
      registry: {{ .Values.artifactoryIntegration }}
      imageName: {{ .Values.DockerBuild.dockerImageName }}
      imageTag: {{ .Values.DockerBuild.dockerImageTag | default "latest" }}
      autoPull: {{ .Values.Image.autopull | default true }}

  {{- if .Values.BuildInfo }}
  - name: {{ .Values.BuildInfo.name | default "BuildInfo" }}
    type: BuildInfo
    configuration:
      sourceArtifactory: {{ .Values.artifactoryIntegration }}
      buildName: {{ .Values.DockerPush.name | default "DockerPush" }}
      buildNumber: {{ .Values.BuildInfo.buildNumber | default 1 }}
  {{- end }}

pipelines:
  - name: {{ .Values.Pipeline.name | default "Pipeline" }}
    configuration:
      jfrogCliVersion: 2
    steps:
      - name: {{ .Values.DockerBuild.name | default "DockerBuild" }}
        type: DockerBuild
        configuration:
          affinityGroup: DockerBuildAndPush
          dockerFileLocation: {{ .Values.DockerBuild.dockerFileLocation | default "." | quote }}
          dockerFileName: {{ .Values.DockerBuild.dockerFileName | default "Dockerfile" }}
          dockerImageName: {{ .Values.DockerBuild.dockerImageName }}
          dockerImageTag: {{ .Values.DockerBuild.dockerImageTag }}
          inputResources:
            - name: {{ .Values.GitRepo.name | default "GitRepoRes" }}
          integrations:
            - name: {{ .Values.artifactoryIntegration }}

      - name: {{ .Values.DockerPush.name | default "DockerPush" }}
        type: DockerPush
        configuration:
          {{- if .Values.BuildInfo }}
          autoPublishBuildInfo: {{ .Values.BuildInfo.autoPublishBuildInfo | default true }}
          {{- end }}
          affinityGroup: DockerBuildAndPush
          integrations:
            - name: {{ .Values.artifactoryIntegration }}
          inputSteps:
            - name: {{ .Values.DockerBuild.name | default "DockerBuild" }}
          outputResources:
            - name: {{ .Values.Image.name | default "ImageRes" }}
            {{- if .Values.BuildInfo }}
            - name: {{ .Values.BuildInfo.name | default "BuildInfo" }}
            {{- end }}


values.yml: This is a sample values.yml. This can be edited to create your own version of the file.

values.yml
GitRepo:                                            # Required.
  name: fooGitRepo                                  # Name of the GitRepo resource. Defaults to GitRepoRes.
  gitProvider: github                               # Required. Name of the SCM integration which will be used to fetch the SCM. repository.
  path: jfrog/jfrog-pipelines-simple-example        # Required. Path to the SCM repository.
  branches:
    exclude: 'master'                               # Regex pattern to exclude branches.
    include: ^{{gitBranch}}$                        # Regex pattern to include branches.

artifactoryIntegration: art                         # Required. Name of the artifactory integration using which the docker image will be pushed.

Image:                                              # Required.
  name: fooImage                                    # Name of the Image resource. Defaults to ImageRes.
  autoPull: false                                   # Defaults to true.

DockerBuild:                                        # Required.
  name: foobuild                                    # Name of the DockerBuild step. Defaults to DockerBuild.
  dockerImageName: foo                              # Required. Name of the docker image getting built.
  dockerFileName: foo                               # Required. Name of the Dockerfile.
  dockerFileLocation: '.'                           # Required. Path to Dockerfile.
  dockerImageTag: ${run_number}                     # Name of the docker image tag. Defaults to latest.

Pipeline:
  name: foo                                         # Name of the pipeline. Defaults to Pipeline.

DockerPush:                                         # Required.
  name: foopush                                     # Name of the DockerPush step. Defaults to DockerPush.

BuildInfo:                                          # Optional, if the BuildInfo needs to be published.
  autoPublishBuildInfo: true                        # Defaults to true.
  name: fooBuildInfo                                # Name of the BuildInfo resource. Defaults to BuildInfo.

HelmPublishAndDeploy

The HelmPublishAndDeploy template creates a pipeline that publishes a Helm Chart to a Helm repository in Artifactory, creates a Build Info, promotes the Build, and then deploys the Helm Chart from the promoted Build resource using the HelmDeploy native step. Version 1.0.0 of this template uses JFrog CLI v1 and version 1.1.0 uses JFrog CLI v2.

HelmPublishAndDeploy.yml
resources:
  - name: {{ .Values.GitRepo.name | default "GitRepoRes" }}
    type: GitRepo
    configuration:
      gitProvider: {{ .Values.GitRepo.gitProvider }}
      path: {{ .Values.GitRepo.path }}
      {{- if or (.Values.GitRepo.branches.include) (.Values.GitRepo.branches.exclude) }}
      branches:
        {{- if .Values.GitRepo.branches.include }}
        include: {{ .Values.GitRepo.branches.include }}
        {{- end }}
        {{- if .Values.GitRepo.branches.exclude }}
        exclude: {{ .Values.GitRepo.branches.exclude }}
        {{- end }}
      {{- end }}
      {{- if or (.Values.GitRepo.files.include) (.Values.GitRepo.files.exclude) }}
      files:
        {{- if .Values.GitRepo.files.include }}
          include: {{ .Values.GitRepo.files.include }}
        {{- end }}
        {{- if .Values.GitRepo.files.exclude }}
          exclude: {{ .Values.GitRepo.files.exclude }}
        {{- end }}
      {{- end }}

  - name: {{ .Values.BuildInfo.name | default "BuildInfoRes" }}
    type: BuildInfo
    configuration:
      sourceArtifactory: {{ .Values.artifactoryIntegration }}

  {{- if .Values.BuildInfoPromoted }}
  - name: {{ .Values.BuildInfoPromoted.name | default "BuildInfoPromotedRes" }}
    type: BuildInfo
    configuration:
      sourceArtifactory: {{ .Values.artifactoryIntegration }}
  {{- end }}

  - name: {{ .Values.HelmChart.name | default "HelmChartRes" }}
    type: HelmChart
    configuration:
      sourceArtifactory: {{ .Values.artifactoryIntegration }}
      repository: {{ .Values.HelmChart.repository }}
      chart:  {{ .Values.HelmChart.chartName }}
      version: {{ .Values.HelmChart.chartVersion }}

pipelines:
  - name: {{ .Values.Pipeline.name | default "HelmDeployPipeline" }}
    configuration:
      jfrogCliVersion: 2
      {{- if or (.Values.BuildInfo.buildName) (.Values.BuildInfo.buildNumber) }}
      environmentVariables:
        readOnly:
          {{- if .Values.BuildInfo.buildName }}
          JFROG_CLI_BUILD_NAME: {{ .Values.BuildInfo.buildName }}
          {{- end }}
          {{- if .Values.BuildInfo.buildNumber }}
          JFROG_CLI_BUILD_NUMBER: {{ .Values.BuildInfo.buildNumber }}
          {{- end }}
      {{- end }}
    steps:
      - name: {{ .Values.HelmPublish.name | default "HelmPublish" }}
        type: HelmPublish
        configuration:
          helmVersion: {{ .Values.HelmChart.helmVersion | default 3 }}
          autoPublishBuildInfo: true
          chartPath: {{ .Values.HelmPublish.chartPath }}
          {{- if .Values.HelmPublish.flags }}
          flags:  {{ .Values.HelmPublish.flags }}
          {{- end }}
          {{- if .Values.HelmPublish.valueFilePaths }}
          valueFilePaths:
            {{- range $.Values.HelmPublish.valueFilePaths }}
            - {{ . }}
            {{- end }}
          {{- end }}
          lint: {{ .Values.HelmPublish.lint | default false }}
          {{- if .Values.HelmPublish.lintFlags }}
          lintFlags: {{ .Values.HelmPublish.lintFlags }}
          {{- end }}
          inputResources:
            - name: {{ .Values.GitRepo.name | default "GitRepoRes" }}
          outputResources:
            - name: {{ .Values.BuildInfo.name | default "BuildInfoRes" }}
            - name: {{ .Values.HelmChart.name | default "HelmChartRes" }}

      {{- if and (.Values.PromoteBuild) (.Values.BuildInfoPromoted) }}
      - name: {{ .Values.PromoteBuild.name | default "PromoteBuild" }}
        type: PromoteBuild
        configuration:
          copy: {{ .Values.PromoteBuild.copy | default false }}
          targetRepository: {{ .Values.PromoteBuild.targetRepository }}
          inputResources:
            - name: {{ .Values.BuildInfo.name | default "BuildInfoRes" }}
              trigger: {{ .Values.PromoteBuild.autoPromotion | default true }}
          outputResources:
            - name: {{ .Values.BuildInfoPromoted.name | default "BuildInfoPromotedRes" }}
      {{- end }}

      - name: {{ .Values.HelmDeploy.name | default "HelmDeploy" }}
        type: HelmDeploy
        configuration:
          {{- if .Values.HelmChart.namespace }}
          environmentVariables:
            HELM_NAMESPACE: {{ .Values.HelmChart.namespace }}
          {{- end }}
          integrations:
            - name: {{ .Values.kubernetesIntegration }}
          inputResources:
            {{- if and (.Values.PromoteBuild) (.Values.BuildInfoPromoted) }}
            - name: {{ .Values.BuildInfoPromoted.name | default "BuildInfoPromotedRes" }}
            {{- else }}
            - name: {{ .Values.BuildInfo.name | default "BuildInfoRes" }}
            {{- end }}
          chartPath: {{ .Values.HelmDeploy.chartPath }}
          chartName: {{ .Values.HelmChart.chartName }}
          chartVersion: {{ .Values.HelmChart.chartVersion }}
          helmVersion: {{ .Values.HelmChart.helmVersion | default 3 }}
          {{- if .Values.HelmDeploy.releaseName }}
          releaseName: {{ .Values.HelmDeploy.releaseName }}
          {{- end }}
          {{- if .Values.HelmChart.namespace }}
          namespace:  {{ .Values.HelmChart.namespace }}
          {{- end }}
          {{- if .Values.HelmDeploy.flags }}
          flags:  {{ .Values.HelmDeploy.flags }}
          {{- end }}
          {{- if .Values.HelmDeploy.valueFilePaths }}
          valueFilePaths:
            {{- range $.Values.HelmDeploy.valueFilePaths }}
            - {{ . }}
            {{- end }}
          {{- end }}
          lint: {{ .Values.HelmDeploy.lint | default false }}
          {{- if .Values.HelmDeploy.lintFlags }}
          lintFlags: {{ .Values.HelmDeploy.lintFlags }}
          {{- end }}
          test: {{ .Values.HelmDeploy.test | default false }}
          {{- if .Values.HelmDeploy.testFlags }}
          testFlags: {{ .Values.HelmDeploy.testFlags }}
          {{- end }}
Example
resources:
  - name: fooGitRepo
    type: GitRepo
    configuration:
      gitProvider: bb_benha
      path: ~benha/simplehelm
      branches:
        include: master
      files:
        include: simplehelm.*
  - name: fooBuild
    type: BuildInfo
    configuration:
      sourceArtifactory: art_v
  - name: fooBuildPromote
    type: BuildInfo
    configuration:
      sourceArtifactory: art_v
  - name: fooHelmChart
    type: HelmChart
    configuration:
      sourceArtifactory: art_v
      repository: simplecharts
      chart: simplehelm
      version: 0.3.0

pipelines: 
- name: fooHelmDeploy
configuration:
  environmentVariables:
    readOnly:
      JFROG_CLI_BUILD_NAME: foo
      JFROG_CLI_BUILD_NUMBER: '${run_number}'
steps:
  - name: HelmPublish
    type: HelmPublish
    configuration:
      helmVersion: 3
      autoPublishBuildInfo: true
      chartPath: ./simplehelm
      lint: false
      inputResources:
        - name: fooGitRepo
      outputResources:
        - name: fooBuild
        - name: fooHelmChart
  - name: fooPromoteBuild
    type: PromoteBuild
    configuration:
      copy: false
      targetRepository: helm-promote
      inputResources:
        - name: fooBuild
          trigger: true
      outputResources:
        - name: fooBuildPromote
  - name: fooHelmDeploy
    type: HelmDeploy
    configuration:
      environmentVariables:
        HELM_NAMESPACE: pipe-master-pool
      integrations:
        - name: k8s
      inputResources:
        - name: fooBuildPromote
      chartPath: .
      chartName: simplehelm
      chartVersion: 0.3.0
      helmVersion: 3
      releaseName: 'simplehelm-${run_id}'
      flags: >-
        --force --wait --timeout 900s --set
        image.repository=trriplejay/simplehelm --set image.tag=latest
      valueFilePaths:
        - values.yaml
      lint: true
      lintFlags: '--strict'
      test: true

values.yml: This is a sample values.yml, which can be edited to create your own version of the file.

values.yml
artifactoryIntegration: artifactory_integration     # Required. Name of the Artifactory integration.
kubernetesIntegration: kubernetes_integration       # Required. Name of the Kubernetes integration.

GitRepo:                                            # Required.
  name: fooGitRepo                                  # Name of the GitRepo resource. Defaults to GitRepoRes.
  gitProvider: github                               # Required. Name of the SCM integration which will be used to fetch the SCM repository.
  path: jfrog/jfrog-pipelines-simple-example        # Required. Path to the SCM repository.
  branches:                                         # Optional.
    exclude: ^master$                               # Regex pattern to exclude branches.
    include: ^{{gitBranch}}$                        # Regex pattern to include branches.
  files:                                            # Optional.
    exclude: ^fileName$                             # Regex pattern to exclude files.
    include: ^fileName$                             # Regex pattern to include files.

BuildInfo:                                          # Required.
  name: fooBuild                                    # Name of the BuildInfo resource. Defaults to BuildInfoRes.
  buildName: foo                                    # Optional. Name of the Artifactory Build that will be created. Defaults to $pipeline_name.
  buildNumber: $run_number                          # Optional. Number of the Artifactory Build that will be created. Defaults to $run_number.

BuildInfoPromoted:                                  # Optional.
  name: fooBuildInfoPromoted                        # Name of the promoted BuildInfo resource. Defaults to BuildInfoPromotedRes.
  autoPromotion: false                              # Optional. When set to false, indicates that Build promotion in the pipeline will be manually triggered. Defaults to true.

HelmChart:                                          # Required.
  name: fooHelmChart                                # Name of the HelmChart resource. Defaults to HelmChartRes.
  chartName: foo                                    # Required. Helm chart name.
  chartVersion: 0.0.1                               # Required. Helm chart version.
  repository: foo                                   # Required. The name of the Helm repository in Artifactory.
  helmVersion: 3                                    # Optional. A number representing the major version of Helm to use. Defaults to 3.
  namespace: foo                                    # Optional. Set the namespace used for the Helm operations. Only supported when used with Helm 3.

Pipeline:                                           # Optional.
  name: foo                                         # Name of the pipeline. Defaults to HelmDeployPipeline.

HelmPublish:                                        # Required.
  name: HelmPublish                                 # Name of the HelmPublish step. Defaults to HelmPublish.
  chartPath: '.'                                    # Required. The path to the Helm chart YAML in the GitRepo resource.
  flags: '--app-version=foo'                        # Optional. Command line options to pass to the helm package command.
  lint: true                                        # Optional. When set to true performs a lint to examine a Helm chart for possible issues.  Defaults to false.
  lintFlags: '--strict'                             # Optional. Flag string to pass to the helm lint command.
  valueFilePaths:                                   # Optional. Specifies values YAML file(s) that will be used in the lint command helm lint command.
    - values.yaml                                   # Optional. An exmaple of how to add a values YAML file.
    - values2.yaml                                  # Optional. An exmaple of how to add an additional values YAML file.

PromoteBuild:                                       # Optional.
  name: fooPromoteBuild                             # Name of the PromoteBuild step. Defaults to PromoteBuild.
  targetRepository: fooPromote                      # Required. The name of the repository in Artifactory to promote the build to.
  copy: false                                       # Optional. When set to true, copies the artifacts to the targetRepository vs moving them to the targetRepository. Defaults to false.

HelmDeploy:                                         # Required.
  name: fooHelmDeploy                               # Name of the HelmDeploy step. Defaults to HelmDeploy.
  chartPath: '.'                                    # Required. The path to the Helm chart YAML in the input BuildInfo resource.
  releaseName: foo                                  # Required. The release name. Equivalent to the --name (-n) option of the  helm install command.
  flags: '--wait --timeout 900s'                    # Optional. Command line options to pass to the helm upgrade command.
  lint: true                                        # Optional. When set to true performs a lint to examine a Helm chart for possible issues. Defaults to false.
  lintFlags: '--strict'                             # Optional. Flag string to pass to the helm lint command.
  valueFilePaths:                                   # Optional. Specifies values YAML file(s) for use with a --values (-f) option of the helm lint command.
    - values.yaml
    - values2.yaml
  test: true                                        # Optional. When set to true performs a test to run the tests for release. Defaults to false.
  testFlags:                                        # Optional. Flag string to pass to the helm test command.

Using Global Templates to Create a Pipeline Source

Perform the following steps to use a Global Template to create a pipeline source:

  1. Go to Administration | Pipelines | Pipeline Sources, and click Add Pipeline Source, and From Template

  2. Complete the resulting Select Template form: 



    • Click the Select Template Namespace field and select the jfrog namespace.
    • Click the Select Template Name field and select the DockerBuildAndPush or HelmPublishAndDeploy global template. 
    • Click the Select Template Version field and select the relevant version for the template.

  3. Click Next and complete the resulting Specify values file form to add the values.yml file. 



    • Click the Integration field and select your source control integration from the dropdown list.

    • In the Repository Full Name field, enter the path of the repository where your values.yml is stored.
    • Specify the Branch of the repository (for example, master).
    • In the Values File Path field, provide the path to the values.yml file, which contains the values for the global template. By default, this field is set to take the file from the root directory. If your values.yml file is stored in a different directory, enter the full path.

      When you do this, the values.yml file is parsed and values are added as configured in the file.

      For more information about the Specify values file form, see the section Adding a Pipeline Source


  4. Click Create Source to add the Pipeline Source.

The combination of pipeline template name, namespace, version and values.yml is parsed to create the pipeline definition. 

After your Pipeline Source syncs successfully, you can view the newly added pipeline by navigating to My Pipelines on the left navbar and clicking PipelinesMy Pipelines.

  • No labels
Copyright © 2022 JFrog Ltd.