Search


Cloud customer?
Upgrade in MyJFrog >


Working with an older version?

JFrog Artifactory 6.x
JFrog Xray 2.x
JFrog Mission Control 3.x
JFrog Distribution 1.x
JFrog Enterprise+ (Pre-Platform Release)




The Utility Functions are built-in shell functions that can be used in steps to interact with the runtime environment.


Most utility functions are available in both Bash (Linux) and Powershell (Windows) OS runtimes. 

Page Contents

bump_semver

Description

Increments the provided  semver versionwith the given action.

Usage

bump_semver <semver string> <action>
  • semver string is the semver version to be incremented
  • action is the type of increment to be applied

The valid actions are:

  • major: Increment the major version. The minor and patch versions are reset to 0.
  • minor: Increment the minor version. The patch version is reset to 0.
  • patch: Increment the patch version.
  • alpha: Increment or add an alpha pre-release tag For example, v1.1.1 becomes v1.1.1-alpha and v1.1.1-alpha becomes v1.1.1-alpha.1. Any other pre-release tags will be removed.
  • beta: Increment or add a beta pre-release tag For example, v1.1.1 becomes v1.1.1-beta and v1.1.1-beta becomes v1.1.1-beta.1. Any other pre-release tags will be removed.
  • rc: Increment or add an rc pre-release tag For example, v1.1.1 becomes v1.1.1-rc and v1.1.1-rcbecomes v1.1.1-rc.1. Any other pre-release tags will be removed.
  • final: Remove any pre-release tags, leaving major.minor.patch.
 Click for examples
Examples

ubuntu:~$ bump_semver v1.0.0 major
v2.0.0

ubuntu:~$ bump_semver v1.0.0 minor
v1.1.0

ubuntu:~$ bump_semver v1.0.0 patch
v1.0.1

ubuntu:~$ bump_semver v1.0.0 rc
v1.0.0-rc

ubuntu:~$ bump_semver v1.0.0-rc rc
v1.0.0-rc.1

ubuntu:~$ bump_semver v1.0.0 alpha
v1.0.0-alpha

ubuntu:~$ bump_semver v1.0.0 beta
v1.0.0-beta

ubuntu:~$ bump_semver v1.0.0-rc.12 final
v1.0.0

ubuntu:~$ bump_semver v1. rc
error: Invalid semantic version given in the argument.

ubuntu:~$ bump_semver v1.0.0 badaction
error: Invalid action given in the argument.

replace_envs

Description

Replaces variables in a file with values based on your current shell env. This is useful to create config files from templates, for example.

If the file contains placeholders that are not defined in the environment, they will become empty strings (“”).  The original file is overwritten with the modified file.

Usage

replace_envs <filename1> <filename2> <filenameN>

where your files have placeholders in the format $ENVIRONMENT_VARIABLE_NAME or ${ENVIRONMENT_VARIABLE_NAME}.

 Click for examples
Examples

replace_envs properties.json deploy.json run.json

retry_command

Description

Execute any command up to three times if it returns a non-zero error code. This is useful when you need to execute a command that can be flaky as a result of network hiccups for example.

Usage

Bashretry_command "<shell command>"
PowerShell
retry_command <shell command> 
  • shell command is the command to be retried
 Click for Bash example
Bash Example

retry_command "docker push mydirectory/myImage"

 Click for Powershell example
PowerShell Example

retry_command docker push mydirectory/myImage


Source Control

compare_git

Lists the files/directories containing changes within a commit range. This function is useful when building a monorepo (monolithic repository) to determine which services have changes.

Bashcompare_git [--path | --resource] [options]
PowerShell
compare_git [-path | -resource] [options]
  • path is the file system path to a git repository.
  • resource is the name of the gitRepo resource.
  • commit-range option specifies the range of commits to look for changes (Example: HEAD~1..HEAD). 
  • directories-only option lists only the directories containing changes.
  • depth option returns file/folder at certain depth. Root directory has depth value 1.
 Click for Bash examples
Bash Examples

ubuntu:~$ compare_git --path ./microservices --commit-range HEAD~2..HEAD
api/common/utilities/leftpad.js
api/main.js
notifier/main.js

ubuntu:~$ compare_git --path ./microservices --commit-range HEAD~2..HEAD --directories-only
api/common/utilities/
api/
notifier/

ubuntu:~$ compare_git --path ./microservices --commit-range HEAD~2..HEAD --directories-only --depth 1
api
notifier

ubuntu:~$ compare_git --path ./microserv --commit-range HEAD~2..HEAD --directories-only --depth 1

git repository not found at path: ./microserv

 Click for Powershell examples
PowerShell Examples

PS C:\Users\windowsuser> compare_git -path microservices -commit-range HEAD~2..HEAD
api/common/utilities/leftpad.js
api/main.js
notifier/main.js

PS C:\Users\windowsuser> compare_git -path microservices -commit-range HEAD~2..HEAD -directories-only
api/common/utilities/
api/
notifier/

PS C:\Users\windowsuser> compare_git -path microservices -commit-range HEAD~2..HEAD -directories-only -depth 1
api
notifier

PS C:\Users\windowsuser> compare_git -path microserv -commit-range HEAD~2..HEAD -directories-only -depth 1

git repository not found at path: ./microserv

update_commit_status

Description

Updates the statusof the commit on the source provider.  Status options are processing, success, and failure.

Usage

Bash

update_commit_status <gitRepo resource name> --status <status> --message <message> --context <context>

PowerShell

update_commit_status <gitRepo resource name> -status <status> -message <message> -context <context>

update_commit_status <gitRepo resource name> --status <status> --message <message> --context <context>

  • gitRepo resource name is the name of the gitRepo resource.
  • status is the status to be set on the source provider: processing, success, or failure.
    If no status is specified:
    • processing will be assumed in onStart and onExecute
    • success will be assumed in onSuccess
    • failure will be assumed in onFailure
  • message is the message (description) string to send with the status.
    If no message is specified, the default message will be "Step <status> in pipeline $pipeline_name"
  • context is the context (key) for the status. The source provider will retain only the latest status received for that context.
    If no context is specified, the default is "$pipeline_name_$step_name"
 Click for Bash examples
Bash Examples

update_commit_status myGitRepoResource

update_commit_status myGitRepoResource --status processing --message “my description” --context $step_name

 Click for Powershell examples
PowerShell Examples

update_commit_status myGitRepoResource

update_commit_status myGitRepoResource -status processing -message “my description” -context $step_name


Test Reports

save_tests

Description

Copies test reports given as input to later be parsed and uploaded (if file storage is available).

Usage

save_tests <file or directory>

  • file or directory specifies either a filename for the test report file, or a directory name for a directory of test report files
 Click for examples
Examples

save_tests testreport.xml


Encryption

encrypt_string

Description

Uses the provided public key to encrypt the specified string.

Usage

Bash
encrypt_string --key <path> <source string>
PowerShell

encrypt_string -key <path> <source string>

  • key is the fully qualified path of the public key file
  • source string is the string to be encrypted
 Click for Bash examples
Bash Example

ubuntu:~$ encrypt_string --key pub.pem "admin:passw0rd"
LbuD69yxEC6wi1M2B+/06ZY0vS+VcahcWeHovWi8GnUC04zBFrFXBmkAbG4TWRRvwbROgSsj2fo+
06SsaSPnb8fZDKuFP6Z89yJnLsh8UCq3gUbvFcGtgTQHUzIHQ0PVfrKrk9IyIvJex6+0ZPkVqa6t
dVK0X/5pCTWBKk5nIvw=

 Click for Powershell examples
PowerShell Example

PS C:\Users\windowsuser> encrypt_string "admin:passw0rd" -key pub.pem
LbuD69yxEC6wi1M2B+/06ZY0vS+VcahcWeHovWi8GnUC04zBFrFXBmkAbG4TWRRvwbROgSsj2fo+
06SsaSPnb8fZDKuFP6Z89yJnLsh8UCq3gUbvFcGtgTQHUzIHQ0PVfrKrk9IyIvJex6+0ZPkVqa6t
dVK0X/5pCTWBKk5nIvw=

decrypt_string

Description

Uses the provided private key to decrypt the specified string.

This is typically used to decrypt information that was encrypted using encrypt_string with the corresponding public key. It helps you avoid building your own encrypt-decrypt system.

Usage

Bashdecrypt_string --key <path> <encrypted string>
PowerShell
decrypt_string -key <path> <encrypted string>
  • key is the fully qualified path of the private key file
  • encrypted string is the string to be decrypted
 Click for Bash examples
Bash Examples

ubuntu:~$ decrypt_string --key key.pem LbuD69yxEC6wi1M2B+/06ZY0vS+VcahcWeHovWi8GnUC04zBFrFXBmkAbG4TWRRvwbROgSsj2fo+06SsaSPnb8fZDKuFP6Z89yJnLsh8UCq3gUbvFcGtgTQHUzIHQ0PVfrKrk9IyIvJex6+0ZPkVqa6tdVK0X/5pCTWBKk5nIvw=

admin:passw0rd


ubuntu:~$ decrypt_string LbuD69yxEC6wi1M2B+/06ZY0vS+VcahcWeHovWi8GnUC04zBFrFXBmkAbG4TWRRvwbROgSsj2fo+06SsaSPnb8fZDKuFP6Z89yJnLsh8UCq3gUbvFcGtgTQHUzIHQ0PVfrKrk9IyIvJex6+0ZPkVqa6tdVK0X/5pCTWBKk5nIvw=
decrypt_string: ERROR - Key file not found

 Click for Powershell examples
PowerShell Examples

PS C:\Users\windowsuser> decrypt_string -key key.pem LbuD69yxEC6wi1M2B+/06ZY0vS+VcahcWeHovWi8GnUC04zBFrFXBmkAbG4TWRRvwbROgSsj2fo+06SsaSPnb8fZDKuFP6Z89yJnLsh8UCq3gUbvFcGtgTQHUzIHQ0PVfrKrk9IyIvJex6+0ZPkVqa6tdVK0X/5pCTWBKk5nIvw=

admin:passw0rd


PS C:\Users\windowsuser> decrypt_string LbuD69yxEC6wi1M2B+/06ZY0vS+VcahcWeHovWi8GnUC04zBFrFXBmkAbG4TWRRvwbROgSsj2fo+06SsaSPnb8fZDKuFP6Z89yJnLsh8UCq3gUbvFcGtgTQHUzIHQ0PVfrKrk9IyIvJex6+0ZPkVqa6tdVK0X/5pCTWBKk5nIvw=
key is mandatory, please provide a value.

encrypt_file

Description

Uses the provided public key to encrypt the specified file to a new file.

Usage

Bash
encrypt_file --key <path> [--output <filename>] <source filename>
PowerShell
encrypt_file -key <path> [-output <filename>] <source filename>
  • key is the fully qualified path of the public key file
  • output is the name of the resulting encrypted file. Defaults to “encrypted”
  • source filename is the file to be decrypted
 Click for Bash examples
Bash Examples

ubuntu:~$ cat secrets.json
{"TOP_SECRET_CONFIDENTIAL_FORMULA": "uuddlrlrbas"}
ubuntu:~$ encrypt_file secrets.json --key pub.pem
encrypt_file: Encrypting secrets.json using key pub.pem
encrypt_file: Encrypted secrets.json to encrypted
ubuntu:~$ cat encrypted
dGpLiI2IORfkRpSEhhuN9A8U/dQLlyHD6EKermRM5bnoIBcM7TWpLU3Y53f4zsAKTSmmQKHucPxJ
YFOVc6F1AWItYIgTSp2dEY4ugIZ7uTn/IIa0qU7EGUREtPyrdu9N5phS2UybTn0u80CSP7Bf/HF+
5xHBCvlenuFanIFLDbo=

 Click for Powershell examples
PowerShell Examples

PS C:\Users\windowsuser> type secrets.json
{"TOP_SECRET_CONFIDENTIAL_FORMULA": "uuddlrlrbas"}
PS C:\Users\windowsuser> encrypt_file secrets.json -key pub.pem
encrypt_file: Encrypting secrets.json using key pub.pem
encrypt_file: Encrypted secrets.json to encrypted
PS C:\Users\windowsuser> type encrypted
dGpLiI2IORfkRpSEhhuN9A8U/dQLlyHD6EKermRM5bnoIBcM7TWpLU3Y53f4zsAKTSmmQKHucPxJ
YFOVc6F1AWItYIgTSp2dEY4ugIZ7uTn/IIa0qU7EGUREtPyrdu9N5phS2UybTn0u80CSP7Bf/HF+
5xHBCvlenuFanIFLDbo=

decrypt_file

Description

Uses the provided private key to decrypt the specified file to a new file.

This is typically used to decrypt information that was encrypted using encrypt_file with the corresponding public key. It helps you avoid building your own encrypt-decrypt system.

Usage

Bashdecrypt_file --key <path> [--output <filename>] <source filename>
PowerShell
decrypt_file -key <path> [-output <filename>] <source filename>
  • key is the fully qualified path of the private key file
  • output is the name of the resulting decrypted file. Defaults to “decrypted”
  • source filename is the file to be decrypted
 Click for Bash examples
Bash Examples

ubuntu:~$ cat encrypted
dGpLiI2IORfkRpSEhhuN9A8U/dQLlyHD6EKermRM5bnoIBcM7TWpLU3Y53f4zsAKTSmmQKHucPxJ
YFOVc6F1AWItYIgTSp2dEY4ugIZ7uTn/IIa0qU7EGUREtPyrdu9N5phS2UybTn0u80CSP7Bf/HF+
5xHBCvlenuFanIFLDbo=


ubuntu:~$ decrypt_file encrypted --key key.pem
decrypt_file: Decrypting encrypted using key key.pem
decrypt_file: Decrypted encrypted to decrypted


ubuntu:~$ cat decrypted
{"TOP_SECRET_CONFIDENTIAL_FORMULA": "uuddlrlrbas"}


ubuntu:~$ decrypt_file encrypted --key key.pem --output secrets.json
decrypt_file: Decrypting encrypted using key key.pem
decrypt_file: Decrypted encrypted to secrets.json

 Click for Powershell examples
PowerShell Examples

PS C:\Users\windowsuser> type encrypted
dGpLiI2IORfkRpSEhhuN9A8U/dQLlyHD6EKermRM5bnoIBcM7TWpLU3Y53f4zsAKTSmmQKHucPxJ
YFOVc6F1AWItYIgTSp2dEY4ugIZ7uTn/IIa0qU7EGUREtPyrdu9N5phS2UybTn0u80CSP7Bf/HF+
5xHBCvlenuFanIFLDbo=


PS C:\Users\windowsuser> decrypt_file encrypted -key key.pem
decrypt_file: Decrypting encrypted using key key.pem
decrypt_file: Decrypted encrypted to decrypted


PS C:\Users\windowsuser> type decrypted
{"TOP_SECRET_CONFIDENTIAL_FORMULA": "uuddlrlrbas"}


PS C:\Users\windowsuser> decrypt_file encrypted -key key.pem -output secrets.json
decrypt_file: Decrypting encrypted using key key.pem
decrypt_file: Decrypted encrypted to secrets.json


Notifications

send_notification

Description

Utilizes notification integration to send custom messages at any time during the build to any recipient.

Usage

send_notification <integration> [options]

The options can be specified as part of the command, or defined as environment variables before the command is issued. 

The command line arguments take priority over the environment variables.

Command line options

AirBrake

Creates an AirBrake deployment through an Airbrake IntegrationNot supported in PowerShell.

BashOption Description
--project-id

the project ID to send the notification for

--environmentthe environment value to use when posting the deployment
--usernameused when posting an AirBrake deployment
--emailthe email to be used when posting the AirBrake deployment
--repositorythe repository to use when posting the AirBrake deployment
--revisionthe deployment revision
--versionthe version to use when posting the AirBrake deployment
--type

currently only type “deploy” is supported


--descriptiondescription of the deployment
--payloadpath to a valid JSON file that contains a payload to use to POST the AirBrake deployment


Jira

Creates a Jira issue (also known as a ticket).

BashPowershellOption Description
--project-id-project-id

the Project Key of the project to associate the new issue with. The project key is the short string that begins all issue numbers for the project (e.g., "EXAMPLE-1234")

--type-type

the issue type for the new issue (e.g., "Bug", "Task", etc.). This string must be one of the  recognized Jira issue types

--summary-summarya string for the new issue's Summary field (it's title)
--description--description(optional) a string for the new issue's Description field
--attach-file--attach-file

(optional) a path to a file that you’d like to attach to the issue


NewRelic

Creates a NewRelic deployment through a NewRelic IntegrationNot supported in PowerShell.

BashOption Description
--typethe type of object to be posted. At the moment, only “deployment” is supported
--descriptiondescription of the deployment
--usernamethe user recording the deployment. Defaults to “JFrog Pipelines”
--changelog

the changelog value to use in the deployment

--revision

the deployment revision (required)

--appIdthe ID of the app being deployed. If not provided, --appName must be present
--appName

the name of the app being deployed. If not provided, --appId must be present


--payload

path to a valid JSON file that contains a payload to use to POST the NewRelic deployment


Slack

Sends a message on Slack through a Slack Integration.

BashPowershellOption Description
--payload-payload(optional) A path to a valid json file to act as the payload of the message. If a payload is provided, all other parameters are ignored. This payload is directly sent to Slack, so please view the Slack API documentation for information on how the payload should be formatted.
--username-username(optional) shows in the heading of the Slack message
--pretext-pretext(optional) a string that becomes the first part of the Slack message. Defaults to current date/time
--text-text

(optional) the main text to display in the message.

--color-color(optional) hex string that changes the color of the status bar to the left of the Slack message.
--recipient-recipient(optional) the target of the message. Should start with “@” or “#” for user or channel, respectively.
--icon-url-icon-url(optional) the url of the icon to show next to the message


smtpCreds (email)

Sends an email through an SMTP Credentials Integration.

BashPowershellOption Description
--recipients-recipients

one or more email addresses

--subject-subject(optional) add a message to the subject. Does not replace the default subject
--body-body(optional) specify some text to add to the body of the email. Does not replace the existing body information
--status-status(optional) can be set to a valid status string. By default it will be set based on the section of scrip the command is executed in.
--attachments-attachments(optional) a list of files to attach to the email. Combined total of all files cannot exceed 5MB
--attach-logs-attach-logs(optional) ‘true’ or ‘false’. Defaults to false.  All available logs for the step will be attached to the email.  Note that it can only attach logs that have already been created, so using this option in the onStart section, for example, would not have very detailed logs.
--show-failing-commands-show-failing-commands(optional) 'true’ or ‘false’. Defaults to false.  The existing logs for the step will be parsed. Any failed command that is detected will be added to the body of the email, along with up to 100 preceding lines (if printed from the same command)


Environment Options

All of the above options can also be included as environment variables instead of arguments.  The command line argument will have priority over the environment. Here is the full list of ENVs:

  • NOTIFY_USERNAME (--username/-username)
  • NOTIFY_PASSWORD (--password/-password)
  • NOTIFY_RECIPIENT (--recipient/-recipient)
  • NOTIFY_PRETEXT (--pretext/-pretext)
  • NOTIFY_TEXT (--text/-text)
  • NOTIFY_COLOR (--color/-color)
  • NOTIFY_ICON_URL (--icon-url/-icon-url)
  • NOTIFY_PAYLOAD (--payload/-payload)
  • NOTIFY_TYPE (--type/-type)
  • NOTIFY_PROJECT_ID (--project-id/-project-id)
  • NOTIFY_ENVIRONMENT (--environment/-environment)
  • NOTIFY_REVISION (–revision/-revision)
  • NOTIFY_SUMMARY (--summary/-summary)
  • NOTIFY_ATTACH_FILE (--attach-file/-attach-file)
  • NOTIFY_REPOSITORY (--repository/-repository)
  • NOTIFY_EMAIL (–email--email/-email)
  • NOTIFY_STATUS (--status/-status)
  • NOTIFY_VERSION (--version/-version)
  • NOTIFY_CHANGELOG (--changelog/-changelog)
  • NOTIFY_DESCRIPTION (–description--description/-description)
  • NOTIFY_ATTACHMENTS (–attachments--attachments/-attachments)
  • NOTIFY_ATTACH_LOGS (--attach-logs/-attach-logs)
  • NOTIFY_SHOW_FAILING_COMMANDS (--show-failing-commands/-show-failing-commands)
  • NOTIFY_SUBJECT (--subject/-subject)
  • NOTIFY_BODY (–body)



JSON

set_payload

Description

Sets an optional JSON payload (string or file) for an OutgoingWebhook resource. When the OutgoingWebhook is specified in a step's outputresources the payload is sent when the step is complete.

Usage

Bash

set_payload <resource> <payload> [--file]

PowerShell
set_payload <resource> <payload> [-file] 
  • resource is the name of an OutgoingWebhook resource.
  • payload is a JSON string or file to attach to the resource that will be sent as part of the outgoing webhook. A file can be specified as a path relative to the current directory, absolute path, or path relative to the step workspace directory.
  • file option specifies that the payload parameter is a file. If not specified, payload will be processed as a string.
 Click for Bash examples
Bash Examples

set_payload myExternalHookResource "{\"test\":\"payload\"}"

echo "{\"test\":\"payload\"}" > testpayload.json
set_payload myExternalHookResource testpayload.json --file

 Click for Powershell examples
PowerShell Examples

set_payload myExternalHookResource "{`"test`":`"payload`"}"

Set-Content -Path testpayload.json -Value "{`"test`":`"payload`"}"
set_payload myExternalHookResource testpayload.json -file

read_json

Description

Extracts the json property value from the specified file.

This simplifies handling of a JSON file to read specific property values that are required for your workflow.

Not supported in PowerShell

In PowerShell, ConvertTo-Json is suggested as an alternative.


Usage

read_json <path to file> <field name>
  • path to file is the fully qualified path of the JSON file
  • field name is the field for which you want to read the value. Use  dot notation and [n] for arrays.
 Click for examples
Examples

ubuntu:~$ cat secrets.json
{
 "TOP_SECRET_CONFIDENTIAL_FORMULA": "uuddlrlrbas",
 "LESSER_SECRET_FORMULA": "dyddy",
 "TOP_5_PASSWORDS_LIST": [
   "admin",
   "passw0rd",
   "testing123",
   "correcthorsebatterystaple"
 ],
   “nesting”: {
      “is”: {
      “fun”: “yay”
      }
   }
}

ubuntu:~$ read_json secrets.json "LESSER_SECRET_FORMULA"
dyddy

ubuntu:~$ read_json secrets.json "TOP_5_PASSWORDS_LIST[3]"
correcthorsebatterystaple

ubuntu:~$ read_json secrets.json "nesting.is.fun"
yay


Resources

replicate_resource

Description

This command takes an input resource and creates an exact copy. This helps you to transfer metadata from one step to the next.

Usage

Bashreplicate_resource <from_resource> <to_resource> [--options]
PowerShell
replicate_resource <from_resource> <to_resource> [-options]

  • from_resource is the name of the inputResources  resource that you're copying from. 
  • to_resource is the name of the outputResources  resource that will receive the replicated data from the from_resource. Any pre-existing files or key-value pairs in the to_resource will be replaced.
  • webhook-data-only option limits replication solely to shaData from the from_resource metadata of a GitRepo resource's webhook . This can be used to conveniently copy repository data without overwriting the to_resource  branch settings. This flag only impacts from_resource that is a GitRepo type.
  • match-settings option should be set when you want the replication to adhere to any branch/tag settings in the to_resourceFor example, If your from_resource gitRepo can trigger on both commits and pull requests, but you only want to update your to_resource on commits, you can replicate with --match-settings, and the to_resource will only be updated when the from_resource had a commit.
 Click for Bash examples
Bash Examples

replicate_resource myRepo1 myRepo2 --match-settings
replicate_resource myTestImage myStageImage

 Click for Powershell examples
PowerShell Examples

replicate_resource myRepo1 myRepo2 -match-settings
replicate_resource myTestImage myStageImage

write_output

Description

Adds data to an output resource in the form of key/value pairs that will become properties of the resource.

Usage

write_output <resource> <key value pair>...

  • resource is the resource to update
  • key value pair is a single string with a key and a value, separated by an “=”.  Multiple of these strings can be supplied as input. A value with spaces should be surrounded by quotes.
 Click for examples
Examples

write_output myImage imageTag=master sha=$commitSha description=\"hello world\"


The newly attached properties can be accessed as environment variables of the form res_{Resource Name}_{Key Name}.  

For example, the above created properties can be accessed as these environment variables:

$ printenv res_myImage_master
master
$ printenv res_myImage_sha
d6cd1e2bd19e03a81132a23b2025920577f84e37
$ printenv res_myImage_description
"hello world"

Caching

Caching helps you speed up execution of your steps by preserving and restoring packages and dependencies between runs of a step. In this way, you can reduce build times by avoiding repeating the installation or loading of large dependencies.

add_cache_files

Description

Copies files given as input to later be uploaded if file storage is available.

Usage

add_cache_files <file or directory> <name>

  • file or directory is a file or directory to store in the cache
  • name is a name to give the stored file or directory (without spaces)
 Click for examples
Examples

add_cache_files cachefile.txt my_file

add_cache_files directory/subdirectory my_directory

restore_cache_files

Description

Copies stored cache (if file storage is available) to the specified location.  No error will occur if nothing is available for <name> in the cache.

Usage

restore_cache_files <name> <path>

  • name is the name the file or driectory to be restored was given when cached.
  • path is a path at which to place the file or directory.
 Click for examples
Examples

restore_cache_files my_file cachefile.txt

restore_cache_files my_directory directory/subdirectory


Run State Management

add_run_variables

Description

Allows you to add environment variables that will be available in the following steps of the run.

Usage

add_run_variables <key value pair>...

  • key value pair is a single string with a key and a value, separated by an “=”.  Multiple of these strings can be supplied as input. Each value will be exported as an environment variable at the time this command is used and automatically in any later steps within the run.
 Click for examples
Examples

add_run_variables imageTag="master"

export_run_variables

Description

Sources the file containing the run variables.  This will be done automatically, but may also be used to “reset” the environment variables in the current step.

Usage

export_run_variables

 Click for examples
Examples

export_run_variables

add_run_files

Description

Copies files given as input into the run state for use in later steps in the run, if file storage is available.

Usage

add_run_files <file or directory> <name>

file or directory is a file or directory to store in the run state

name is a name to give the stored file or directory (without spaces).  This cannot be run.env.

 Click for examples
Examples

add_run_files cachefile.txt my_file

add_run_files directory/subdirectory my_directory

restore_run_files

Description

Copies files stored in the run state (if file storage is available) to the specified location.  No error will occur if nothing is available for <name> in the run state.

Usage

restore_run_files <name> <path>

  • path is the name the files to be restored were given when added to the run state.
  • file or directory is a path at which to place the file or files.
 Click for examples
Examples

restore_run_files my_file cachefile.txt

restore_run_files my_directory directory/subdirectory


Pipeline State Management

add_pipeline_variables

Description

Allows you to add environment variables that will be available in the following steps of the run and in future runs.  These variables may be overridden by another variable with the same key added to the current run.

Usage

add_pipeline_variables <key value pair>...

  • key value pair is a single string with a key and a value, separated by an “=”.  Multiple of these strings can be supplied as input. Each value will be exported as an environment variable at the time this command is used and automatically in any steps that start after this run is complete.
 Click for examples
Examples

add_pipeline_variables imageTag="master"

add_pipeline_variables imageName="myimage" imageTag="master"

export_pipeline_variables

Description

Sources the file containing the pipeline variables.  This will be done automatically, but may also be used to “reset” the environment variables in the current step.

Usage

export_pipeline_variables

 Click for examples
Examples

export_pipeline_variables

add_pipeline_files

Description

Copies files given as input into the pipeline state for use in later steps in the run and future runs, if file storage is available.

Usage

add_pipeline_files <file or directory> <name>

  • file or directory is a file or directory to store in the pipeline state.
  • name is a name to give the stored file or directory (without spaces).  This cannot be pipeline.env.
 Click for examples
Examples

add_pipeline_files cachefile.txt my_file

add_pipeline_files directory/subdirectory my_directory

restore_pipeline_files

Description

Copies files stored in the pipeline state (if file storage is available) to the specified location.  No error will occur if nothing is available for <name> in the run state.

Usage

restore_pipeline_files <name> <path>

  • name is the name the file to be restored was given when added to the pipeline state.
  • path is a path at which to place the file or files.
 Click for examples
Examples

restore_pipeline_files my_file cachefile.txt

restore_pipeline_files my_directory directory/subdirectory


Step Properties

find_resource_variable

Description

Retrieves the value of the named property of a resource. 

Usage

find_resource_variable <resourceName> <propertyName>

  • resourceName is the name of the resource.
  • propertyName is the name of the resource property whose value to retrieve.
 Click for examples
Examples

find_resource_variable myGitHub commitSha

find_resource_variable myImage imageTag

get_integration_name

Description

Retrieves the name of the first integration found of the type specified.  Available to extension steps to get the name of the first input integration of a particular type. 

Usage

get_integration_name --type <integration type>

 Click for examples
Examples

get_integration_name --type Slack

get_integration_name --type "Docker Registry"

get_resource_name

Description

Retrieves the name of the first resource found of the type specified in inputResources or outputResources. Available to extension steps to get the name of the first input or output resource of a particular type. 

Usage

get_resource_name --type <resource type> --operation <IN | OUT> --syntax-version <semver>

  • resource type  is the name of a Pipelines Resource type
  • IN | OUT  selects whether the resource is named in inputResources or outputResources 
  • semver is the semantic version number of the resource's syntax version
 Click for examples
Examples

get_resource_name --type GitRepo --operation IN

get_resource_name --type BuildInfo --operation OUT

get_resource_name --type GitRepo --operation IN --syntax-version 1.5.0

find_step_configuration_value

Description

Retrieves the value of the configuration  property for the currently executing step.  If the property is a collection, the first value will be returned. Available to extension steps to get the value of a configuration.

Usage

find_step_configuration_value <propertyName>

  • propertyName is the name of the step's configuration property whose value to retrieve
 Click for examples
Examples

find_step_configuration_value forceXrayScan 

  • No labels
Copyright © 2020 JFrog Ltd.