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 templates, 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: 


DockerBuildAndPush

The DockerBuildAndPush template creates a pipeline that builds a docker image from an SCM repository and pushes it to a docker registry. 

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 }}
      sourceRepository: {{ .Values.Image.sourceRepository }}
      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 }}
      buildNumber: {{ .Values.BuildInfo.buildNumber | default 1 }}
  {{- end }}

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

      - name: {{ .Values.DockerPush.name | default "DockerBuild" }}
        type: DockerPush
        configuration:
          {{- if .Values.BuildInfo }}
          autoPublishBuildInfo: {{ .Values.BuildInfo.autoPublishBuildInfo | default true }}
          {{- end }}
          affinityGroup: DockerBuildAndPush
          targetRepository: {{ .Values.DockerPush.targetRepository }}
          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.

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.
  sourceRepository: foo                             # Required. Name of the docker repository on artifactory
  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.
  targetRepository: foo                             # Required. Name of the artifactory repository where the image will be pushed to.

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.

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" }}
    {{- if or (.Values.BuildInfo.buildName) (.Values.BuildInfo.buildNumber) }}
    configuration:
      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 2 }}
          {{- if .Values.HelmDeploy.releaseName }}
          releaseName: {{ .Values.HelmDeploy.releaseName }}
          {{- 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 }}
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.

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.