Pipelines Extensions Tutorial

JFrog Pipelines Documentation

ft:sourceType
Paligo

Pipelines Extensions enable users to extend the capabilities of Pipelines by adding their own custom steps and resources to the Pipelines DSL.

The example in this tutorial can be found in the JFrog GitHub repository. You can fork this jfrog-pipelines-extensions-sample repo to your own GitHub account to try on your own installation of Pipelines.

The following subjects help you understand and work with the Example Extensions below:

Example Extensions

The repository provides the following simple examples, both in the namespace tutorials:

tutorials/HealthCheck - A step that performs a health check action to a website, with optional notification to a Slack instance on success and failure.

stepModel.yml

configuration:
  healthCheckUrl:
    type: Url
  notifyOnSuccess:
    type: Boolean
  notifyOnFailure:
    type: Boolean
  stuff:
    type: String[]

onExecute.sh

checkHealth() {
  local success=true
  local url=$(find_step_configuration_value "healthCheckUrl")
  {
    local statusCode=$(curl --silent --output /dev/stderr --write-out "%{http_code}" "$url")
  } || exitCode=$?
  if test $statusCode -ne 200; then
    export success=false
    echo "Health check failed with statusCode: $statusCode & exitCode: $exitCode for url: $url"
  else
    echo "Health check succeeded"
  fi

  $success
}

execute_command checkHealth

tutorials/test - A resource type that holds some example data types

resourceModel.yml

configuration:
  alpha:
    type: String
    validate:
      isRegex: "^[a-zA-Z_][a-zA-Z0-9_]*$"
  number:
    type: Int
  flag:
    type: Boolean

To add your Pipelines DSL extension definitions so they can be used in your pipelines, you must add the forked repository to Pipelines as an extension source.