HelloWorld

JFrog Pipelines Documentation

Products
JFrog Pipelines
Content Type
User Guide
ft:sourceType
Paligo

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 YAML

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.

# 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$"