Cloud customer?
 Upgrade in MyJFrog >

Search





Overview

Pipelines enables creation of user-defined resources to extend the Pipelines DSL. 


Resources typically contain information needed for a step in a pipeline to execute and can also be used to store information produced by a step. 

Extension resources enable Pipelines users to extend the Pipelines DSL by specifying their own resource types. When loaded into Pipelines, these user-defined resources can be used in any pipeline just like any other resource in the Pipelines DSL. 

In this way, teams and organizations can create and share their own re-usable, custom resource types for frequently used information in their pipelines.

Extension resources are defined within a namespace, to ensure that all resources in the set have unique names.

Extension resources are versioned, and can be invoked in pipelines by their semantic version number to ensure compatibility.


Page Contents


Files

Extension resource definitions must be stored in a subdirectory path of the form: resources/<namespace>/<resourceTypeName>.

  • namespace  is the namespace for the set of extension sets. This parent subdirectory may contain multiple step definition subdirectories.
  • resourceTypeName is the named type of resource. Must be alphabetic characters only, and is case-sensitive. The subdirectory can hold the following files to define the resource.
FileDescriptionRequired/Optional
resourceModel.ymlSyntax model for the resourceRequired
onInput.shShell script to execute when named in a step's inputResources Optional
onOutput.shShell script to execute when named in a step's outputResources Optional
ReadMe.mdDocumentation for the custom resourceOptional
icon.svg

Icon graphic to represent the resource type in the interactive diagram.                   

If not provided, Pipelines will use the default icon for the resource.

Optional

Extension resrouce definitions are loaded from the source repository when it is configured in the Pipelines UI as an extension source.

For information on administering extension sources and extension version lifecycle staging, see Managing Pipelines Extensions.


Syntax Model


resourcemodel.yml
description: <string>		    # User can provide an optional description

configuration:                  # array of properties
  <property name string>:
    type: <data type>           # required
    immutable: <boolean>        # optional: field value cannot/can be changed
    validate:                   # optional
      <validation specifiction>

   # more property definitions


userDefinedDataType:             # array of data type definitions
  - type: <string>               # Defines a new data type
    configuration:
      - <string>:                # Specifies a property of the data type
        type: <data type>           # required
        validate:                   # optional
          <validation specifiction>

   # more data type property definitions

description

Optional

Value: String

A user-friendly description of the resource's function that will be available for display in the Pipelines UI.

configuration

Begins a block of property definitions. Each property definition begins with the name of the property (letters only, case-sensitive), followed by these subordinate tags:

TagDescription of usageRequired/Optional
type Specifies an inbuilt or user-defined data typeRequired

immutable

When set to true, the field cannot be changed from its initial valueOptional
validate Begins a validation specification blockOptional
configuration Examples
configuration:
  gitProvider:
    type: Integration
    immutable: yes        # Once the resource is created, it is immutable
    validate:
      isIntegrationType: SCM  # Check to see what are the integration types and publish the list as well
  fileName:
    type: String                   
    immutable: yes        # Once the resource is created, it is immutable
    validate:
      notContains: 'bar'
  editors:
    type: String[]
    validate:
      isRegex:  ["^[a-z]+$",'i']    # Each element in array is validated with this
  fileDtTm:
    type: Date
  scanInterval:
    type: Int
    validate:
      min: 1
      max: 60
  creds:
    type: Credential       # User-defined data type


userDefinedDataType

Begins a set of data type definitions. User-defined data types specify property types with validation rules, and can be used as type values. (In other userDefinedDataType defs?)

TagDescription of UsageRequired/Optional
typeString that identifies this user-defined type. Must conform to alpha validation (letters only).Required
configurationBegins a block of property definitionsRequired

Each property definition begins with the name of the property (letters only, case-sensitive), followed by these subordinate tags:

TagDescription of UsageRequired/Optional
type String that identifies an inbuilt or user-defined data type propertyRequired
validate Begins a validation specification blockOptional
userDefinedDataType Example
userDefinedDataType:
  - type: Credential               # User-defined data type
    configuration:
      - userName:                  # first property
        type: String
        validate:                       	
          isRegex: ["^[a-z]+$",'i']         # RegExp from a string
      - password:                 # second property
        type: String
        validate:                      	    
          isRegex: ["^[a-z]+$",'i']

Shell Scripts

An extension resource definition may include optional shell scripts to be executed when the resource is used in a step as an input or output. These may be useful for:

  • Additional validation of properties
  • Testing for a property value to trigger a conditional action

onInput.sh

When present in the resource definition's repository directory, the file onInput.sh shell script will be executed whenever the resource is named among the step's inputResources.

For example:

onInput.sh
test_input() {
  echo "onInput Executed"
  echo "resource name: $1"
}

execute_command "test_input %%context.resourceName%%"

onOutput.sh

When present in the resource definition's repository directory, the file onOutput.sh shell script will be executed whenever the resource is named among the step's outputResources.

For example:

onOutput.sh
test_output() {
  echo "onOutput Executed"
  echo "resource name: $1"
}

execute_command "test_output %%context.resourceName%%"
  • No labels
Copyright © 2020 JFrog Ltd.