Cloud customer?
Start for Free>
Upgrade in MyJFrog >
What's New in Cloud >







TheUtility Functionsare 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.

bump_semver

Description

Increments the providedsemver versionwith the given action.

Usage

bump_semver  
  • semver string我s the semver version to be incremented
  • action我s 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 analphapre-release tag. For example,v1.1.1becomesv1.1.1-alphaandv1.1.1-alphabecomesv1.1.1-alpha.1. Any other pre-release tags will be removed.
  • beta: Increment or add abetapre-release tag. For example,v1.1.1becomesv1.1.1-betaandv1.1.1-betabecomesv1.1.1-beta.1. Any other pre-release tags will be removed.
  • rc: Increment or add anrcpre-release tag. For example,v1.1.1becomesv1.1.1-rcandv1.1.1-rcbecomesv1.1.1-rc.1. Any other pre-release tags will be removed.
  • final: Remove any pre-release tags, leavingmajor.minor.patch.
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 shellenv. 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   

你的文件有占位符的格式吗$ENVIRONMENT_VARIABLE_NAMEor${ENVIRONMENT_VARIABLE_NAME}.

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

Bash retry_command
PowerShell
retry_command
  • shell command我s the command to be retried
Bash Example

retry_commanddocker push mydirectory/myImage

PowerShell Example

retry_commanddocker push mydirectory/myImage

Page Contents

get_uuid

Description

Puts a uuid to stdout. Uses/proc/sys/kernel/random/uuid我f available and falls back touuidgen我f not. The function callsexit 1我f neither of these are available.

Usage

Bash get_uuid
Bash Example

my_uuid=$(get_uuid)

save_artifact_info

Description

Saves metadata about an artifact. When saved, this metadata is used to enable signed pipelines for the artifacts.

Usage

Bash save_artifact_info [--build-name --build-number --project-key ]
PowerShell save_artifact_info [-build-name -build-number -release-bundle-name -release-bundle-version -project-key ]


  • artifact type: This is the type of artifact. Eitherfile,buildInfo, orreleaseBundle.
  • file path: This我s the path to the metadata file to be saved.
Bash Powershell

Description

--build-name -build-name

这s is name of the build. Required when artifact type isbuildInfo.

--build-number -build-number

这s is number of the build. Required when artifact type isbuildInfo.

--release-bundle-name -release-bundle-name

这s is name of the Release Bundle. Required when artifact type isreleaseBundle.

--release-bundle-version -release-bundle-version

这s is version of the Release Bundle. Required when artifact type isreleaseBundle.

--project-key -project-key (optional)Defaults to the environment'sproject_key. Can be specified to save info for a different project.
Bash Example for buildInfo

save_artifact_info 'buildInfo' './myBuildDetailedSummary.json' --build-name myBuild --build-number 42

Bash Example for file

save_artifact_info 'file' './myFileDetailedSummary.json'

PowerShell Example for buildInfo

save_artifact_info buildInfo myBuildDetailedSummary.json -build-name myBuild -build-number 42

PowerShell Example for file

save_artifact_info文件myFileDetailedSummary.json

PowerShell Example for releaseBundle

save_artifact_info releaseBundle myFileDetailedSummary.json -release-bundle-name myBundle -release-bundle-version 1

validate_artifact

Description

Validates the signature of an artifact. Requires signed pipelines to be enabled.

Usage

Bash validate_artifact [--build-name --build-number --project-key ]
PowerShell validate_artifact [-build-name -build-number -project-key ]


  • artifact type: This is the type of artifact. Supportsbuildinfo.
  • file path: This我s the path to the metadata file to be validated.
Bash Powershell Description
--build-name -build-name

这s is name of the build. Required when artifact type isbuildInfo.

--build-number -build-number

这s is number of the build. Required when artifact type isbuildInfo.

--project-key -project-key (optional)Defaults to the environment'sproject_key. Can be specified to validate info for a different project.
Bash Example for buildInfo

validate_artifact 'buildInfo' './myBuildDetailedSummary.json' --build-name myBuild --build-number 42

PowerShell Example for buildInfo

validate_artifact buildInfo myBuildDetailedSummary.json -build-name myBuild -build-number 42

configure_jfrog_cli

Description

Configures the JFrog CLI (version 1 or 2 specified asjfrogCliVersion我n thepipeline configurationdiff)提供凭证,处理erent formats for different minor versions. Artifactory integrations listed in the integrations section of the step will be automatically configured, but this may be useful for resources or if the credentials are provided to the step in another way. When using v2, a non-default Xray URL may also be specified using the environment variable JFROG_XRAY_URL.

Usage

Bash

configure_jfrog_cli——artifactory-url [--xray-url --user USER --apikey --access-token --server-name ]

PowerShell

configure_jfrog_cli-artifactory-url [-xray-url -user USER -apikey -access-token -server-name ]

  • artifactory-url: Required. The Artifactory URL.
  • xray-url: Optional. The Xray URL. Only used with CLI v2.
  • user: The user. Required when an API key is provided.
  • apikey: An API key. Requires --user and may not be used with --access-token.
  • access-token: An Access token. May not be used with --access-token or --user.
  • server-name: Defaults todefault. Can be specified to configure the CLI with that name.


Bash Example

configure_jfrog_cli --artifactory-urlhttps://my-artifactory.local/artifactory--user me --apikey AKCp8jQTdMTFdbkX14MJ8whtyV5Su5eawFhi2granysttMuyRPRA9FgxpfKzi1vFwDJXqYw9R --server-name myAPIKeyArtifactory

configure_jfrog_cli --artifactory-urlhttps://my-artifactory.local/artifactory--access-token eyJ2ZXIiOiIyIiwidHlwIjoiSldUIiwiYWxnIjoiUlMyNTYiLCJraWQiOiJTMmVLcmRLdElWR2JnSTJWbVM2T0NQRDFHYW1ZbVpwSXYtWS1meFN6TFJJIn0.eyJzdWIiOiJqZmZlQDAwMFwvdXNlcnNcL2FkbWluIiwic2NwIjoiYXBwbGllZC1wZXJtaXNzaW9uc1wvYWRtaW4gYXBpOioiLCJhdWQiOiJqZnJ0QCoiLCJpc3MiOiJqZmZlQDAwMCIsImV4cCI6MTYzMDY0NTM1OCwiaWF0IjoxNjMwNjQxNzU4LCJqdGkiOiI5YzcyMjMxOC01ZjBmLTQ1MTEtYTY2Yi1lMzVhMDkyYmFlMWMifQ.YOP6a2GmooC9nQcYROxGuN_1ZS7wt5YaTyqUs8ZIrUvkXxeMzLO0GI5q6KxFNIagVwetb5RP2tmLKm29HM7qp4HoK_EW5QnGQPZOY-kOPm8Z1IzXKHaAKBpPttFkCKu1unj8bByRJL8mn63nG1gMORS2Eh2fvpzej3yyuRDnD65273AC5Qs4uNxp_4DqaqhgB_Xu0b2xzHAjqLKBqWelICKBLcRbZQc4oSvphw2lj10wQHFqedOFej0akNaz8WGUo28l4GlJR7uPzQjAO0VWarKC_U3JySGSM_SAxH1z72AVHAErHCzM7tr5gDbRsfRCuAHok66PeLiDAQxfXmsYZg --server-name myAccessTokenArtifactory

PowerShell Example

configure_jfrog_cli -artifactory-urlhttps://my-artifactory.local/artifactory-user me -apikey AKCp8jQTdMTFdbkX14MJ8whtyV5Su5eawFhi2granysttMuyRPRA9FgxpfKzi1vFwDJXqYw9R -server-name myAPIKeyArtifactory

configure_jfrog_cli -artifactory-urlhttps://my-artifactory.local/artifactory-access-token eyJ2ZXIiOiIyIiwidHlwIjoiSldUIiwiYWxnIjoiUlMyNTYiLCJraWQiOiJTMmVLcmRLdElWR2JnSTJWbVM2T0NQRDFHYW1ZbVpwSXYtWS1meFN6TFJJIn0.eyJzdWIiOiJqZmZlQDAwMFwvdXNlcnNcL2FkbWluIiwic2NwIjoiYXBwbGllZC1wZXJtaXNzaW9uc1wvYWRtaW4gYXBpOioiLCJhdWQiOiJqZnJ0QCoiLCJpc3MiOiJqZmZlQDAwMCIsImV4cCI6MTYzMDY0NTM1OCwiaWF0IjoxNjMwNjQxNzU4LCJqdGkiOiI5YzcyMjMxOC01ZjBmLTQ1MTEtYTY2Yi1lMzVhMDkyYmFlMWMifQ.YOP6a2GmooC9nQcYROxGuN_1ZS7wt5YaTyqUs8ZIrUvkXxeMzLO0GI5q6KxFNIagVwetb5RP2tmLKm29HM7qp4HoK_EW5QnGQPZOY-kOPm8Z1IzXKHaAKBpPttFkCKu1unj8bByRJL8mn63nG1gMORS2Eh2fvpzej3yyuRDnD65273AC5Qs4uNxp_4DqaqhgB_Xu0b2xzHAjqLKBqWelICKBLcRbZQc4oSvphw2lj10wQHFqedOFej0akNaz8WGUo28l4GlJR7uPzQjAO0VWarKC_U3JySGSM_SAxH1z72AVHAErHCzM7tr5gDbRsfRCuAHok66PeLiDAQxfXmsYZg -server-name myAccessTokenArtifactory

check_xray_available

Description

With JFrog CLI v2 (version 2 specified asjfrogCliVersion我n thepipeline configuration), checks that Xray is available for the specified CLI configuration, or the default configuration if none is specified.

Usage

Bash

check_xray_available[--server-name ]

PowerShell

check_xray_available[-server-name ]

  • server-name: Optional. Specifies a JFrog CLI configuration to check.
Bash Example

check_xray_available--server-name myArtifactoryIntegration

PowerShell Example

check_xray_available--server-name myArtifactoryIntegration

cleanup_jfrog_cli

Description

Removes configuration for the JFrog CLI (v1), handling the different formats for different minor versions. Artifactory integrations listed in the integrations section of the step will be automatically removed at the end of the step, but this may be useful to remove the credentials earlier or when usingconfigure_jfrog_cli.

Usage

Bash

cleanup_jfrog_cli[--server-name ]

PowerShell

cleanup_jfrog_cli[-server-name ]

  • server-name: Defaults todefault. Can be specified to remove that configuration.


Bash Example

cleanup_jfrog_cli --server-name myArtifactory

PowerShell Example

configure_jfrog_cli -artifactory-urlhttps://my-artifactory.local/artifactory-user me -apikey AKCp8jQTdMTFdbkX14MJ8whtyV5Su5eawFhi2granysttMuyRPRA9FgxpfKzi1vFwDJXqYw9R -server-name myAPIKeyArtifactory

configure_jfrog_cli -artifactory-urlhttps://my-artifactory.local/artifactory-access-token eyJ2ZXIiOiIyIiwidHlwIjoiSldUIiwiYWxnIjoiUlMyNTYiLCJraWQiOiJTMmVLcmRLdElWR2JnSTJWbVM2T0NQRDFHYW1ZbVpwSXYtWS1meFN6TFJJIn0.eyJzdWIiOiJqZmZlQDAwMFwvdXNlcnNcL2FkbWluIiwic2NwIjoiYXBwbGllZC1wZXJtaXNzaW9uc1wvYWRtaW4gYXBpOioiLCJhdWQiOiJqZnJ0QCoiLCJpc3MiOiJqZmZlQDAwMCIsImV4cCI6MTYzMDY0NTM1OCwiaWF0IjoxNjMwNjQxNzU4LCJqdGkiOiI5YzcyMjMxOC01ZjBmLTQ1MTEtYTY2Yi1lMzVhMDkyYmFlMWMifQ.YOP6a2GmooC9nQcYROxGuN_1ZS7wt5YaTyqUs8ZIrUvkXxeMzLO0GI5q6KxFNIagVwetb5RP2tmLKm29HM7qp4HoK_EW5QnGQPZOY-kOPm8Z1IzXKHaAKBpPttFkCKu1unj8bByRJL8mn63nG1gMORS2Eh2fvpzej3yyuRDnD65273AC5Qs4uNxp_4DqaqhgB_Xu0b2xzHAjqLKBqWelICKBLcRbZQc4oSvphw2lj10wQHFqedOFej0akNaz8WGUo28l4GlJR7uPzQjAO0VWarKC_U3JySGSM_SAxH1z72AVHAErHCzM7tr5gDbRsfRCuAHok66PeLiDAQxfXmsYZg -server-name myAccessTokenArtifactory

set_trigger_payload

Description

添加一个或多个键=值对作为定制的步pipeline variables to a JSON payload that can be used to call the pipelines trigger API.

Multiple key=value pairs can be given in a single command or can be split across multiple commands.

If a key is added twice, the original value will be replaced.

Usage

Bash

set_trigger_payload[stepVariables|pipelineVariables]

PowerShell

Not currently supported in PowerShell

  • stepVariables: These key value pairs will be present in the environment of the triggered step
  • pipelineVariables: These key value pairs will be present in the environment of every step in the run that is triggered.


Bash Example

set_trigger_payload stepVariables "shouldScan=true" "notify=email"

set_trigger_payload pipelinesVariables "releaseVersion=1.2.3"

set_trigger_payload pipelinesVariables "collectData=true"

get_trigger_payload

Description

Prints on stdout a payload that can be used with the pipelines trigger API.

Useset_trigger_payloadto add additional values to the payload.

Usage

Bash

get_trigger_payload

PowerShell

Not currently supported in PowerShell

Bash Example

curl -XPOST -H "authorization: Bearer " -H "content-type: application/json" /pipelines/api/v1/pipelineSteps/:id/trigger -d "$(get_trigger_payload)"


end_step

Description

Stops execution of the onStart or onExecute section and immediately continues to the onSuccess, onFailure, or onComplete section setting the specified status. If "success" is provided, the onSuccess and onComplete sections will be executed. For "failure," the onFailure and onComplete sections will be executed. And for "skipped," only the onComplete section. The end_step utility function may only be called in the onStart and onExecute sections and the only statuses supported are success, failure, and skipped.

Usage

Bash

end_step[success|failure|skipped]

PowerShell

end_step[success|failure|skipped]

Bash Example

end_step success

PowerShell Example

end_step success

update_run_description

Description

Provide dynamic description for a run, which will be shown in the UI. This is useful for providing more context about a run. The run description can be updated at any time.

Usage

Bash

update_run_description"description"

PowerShell

update_run_description"description"

Bash Example

update_run_description"$msg"

PowerShell Example

update_run_description"$msg"

name: UpdateRunDescription steps: - name: update_l type: Bash execution: onStart: - msg="Run description updated from step $step_id" - update_run_description "$msg" - name: update_2 type: Bash configuration: inputSteps: - name: update_l execution: onStart: - msg="Run description updated from step $step_id" - update_run_description "$msg"

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.

Bash compare_git[--path | --resource] [options]
PowerShell
compare_git[-path | -resource] [options]
  • path我s the file system path to a git repository.
  • resource我s the name of thegitRepo resource.
  • commit-rangeoptionspecifies the range of commits to look for changes (Example:HEAD~1..HEAD).
  • directories-onlyoptionlists only the directories containing changes.
  • depthoptionreturns file/folder at certain depth. Root directory has depth value 1.
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

PowerShell Examples

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

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

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

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

git repository not found at path: ./microserv

update_commit_status

Description

Updates thestatusof the commit on the source provider. Status options areprocessing,success, andfailure.

Usage

Bash

update_commit_status --status --message --context

PowerShell

update_commit_status -status -message -context

update_commit_status --status --message --context

  • gitRepo resource name我sthe name of thegitReporesource.
  • status我s the status to be set on the source provider:processing,success, orfailure.
    If no status is specified:
    • processingwill be assumed inonStartandonExecute
    • successwill be assumed我nonSuccess
    • failurewill be assumed我nonFailure
  • message我s the message (description) string to send with the status.
    If no message is specified, the default message will be "Step in pipeline $pipeline_name"
  • context我sthe context (key) for thestatus. 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"
Bash Examples

update_commit_status myGitRepoResource

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

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

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

save_tests testreport.xml


Encryption

encrypt_string

Description

Uses the provided public key to encrypt the specified string.

Usage

Bash
encrypt_string --key  
PowerShell

encrypt_string -key

  • key我s the fully qualified path of the public key file
  • source string我s the string to be encrypted
Bash Example

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

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.

这s is typically used to decrypt information that was encrypted usingencrypt_stringwith the corresponding public key.It helps you avoid building your own encrypt-decrypt system.

Usage

Bash decrypt_string --key
PowerShell
decrypt_string -key  
  • key我s the fully qualified path of the private key file
  • encrypted string我s the string to be decrypted
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

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  [--output ] 
PowerShell
encrypt_file -key  [-output ] 
  • key我s the fully qualified path of the public key file
  • output我s the name of the resulting encrypted file. Defaults to “encrypted”
  • source filename我s the file to be decrypted
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=

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.

这s is typically used to decrypt information that was encrypted usingencrypt_filewith the corresponding public key.It helps you avoid building your own encrypt-decrypt system.

Usage

Bash decrypt_file --key [--output ]
PowerShell
decrypt_file -key  [-output ] 
  • key我s the fully qualified path of the private key file
  • output我s the name of the resulting decrypted file. Defaults to “decrypted”
  • source filename我s the file to be decrypted
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

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.

For more information, seeSending Notifications from Pipelines.

Usage

send_notification  [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.

Bash Examples

- send_notification pipelines_mqtest_slack --text "Pipeline - $pipeline_name | Step - $step_name \n Committer - <$committer> "

AirBrake

Creates an AirBrake deployment through anAirbrake Integration.Not supported in PowerShell.

Bash Option Description
--project-id

the project ID to send the notification for

--environment the environment value to use when posting the deployment
--username 在发布一个减速板部署时使用
--email the email to be used when posting the AirBrake deployment
--repository the repository to use when posting the AirBrake deployment
--revision the deployment revision
--version the version to use when posting the AirBrake deployment
--type

currently only type “deploy” is supported


--description description of the deployment
--payload path 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).

Bash Powershell Option 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 therecognized Jira issue types

--summary -summary a 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 aNewRelic Integration.Not supported in PowerShell.

Bash Option Description
--type the type of object to be posted. At the moment, only “deployment” is supported
--description description of the deployment
--username the user recording the deployment. Defaults to “JFrog Pipelines”
--changelog

the changelog value to use in the deployment

--revision

the deployment revision (required)

--appId the 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

PagerDuty Events

Sends an event through aPagerDuty Events Integration.

Bash

Powershell

Option Description

--text -text

The main text to display in the event on PagerDuty.


Slack

Sends a message on Slack through aSlack Integration.

Bash Powershell Option 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 anSMTP Credentials Integration.

Bash Powershell Option 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 anOutgoingWebhookresource. When the OutgoingWebhook is specified in a step'soutputresourcesthe payload is sent when the step is complete.

Usage

Bash

set_payload [--file]

PowerShell
set_payload   [-file]
  • resource我s the name of anOutgoingWebhookresource.
  • payload我s 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.
  • fileoption specifies that thepayloadparameter is a file. If not specified,payloadwill be processed as a string.
Bash Examples

set_payloadmyExternalHookResource"{\"test\":\"payload\"}"

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

PowerShell Examples

set_payloadmyExternalHookResource"{`"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.

这s 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我s suggested as an alternative.


Usage

read_json  
  • path to file我s the fully qualified path of theJSON file
  • field name is the field for which you want to read the value. Use dot notation and [n] for arrays.
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


2022世界杯阿根廷预选赛赛程

replicate_resource

Description

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

Usage

Bash replicate_resource [--options]
PowerShell
replicate_resource   [-options]
  • from_resource我s the name of the我nputResourcesresource that you're copying from.
  • to_resource我s the name of theoutputResourcesresource that will receive the replicated data from thefrom_resource.Any pre-existing files or key-value pairs in theto_resourcewill be replaced.
  • match-settingsoptionshould be set when you want the replication to adhere to any branch/tag settings in theto_resource.For example, If yourfrom_resourcegitRepo can trigger on both commits and pull requests, but you only want to update yourto_resourceon commits, you can replicate with --match-settings, and theto_resourcewill only be updated when thefrom_resourcehad a commit.
Bash Examples

replicate_resource myRepo1 myRepo2 --match-settings
replicate_resource myTestImage myStageImage

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

Bash
write_output  ...[--overwrite]
PowerShell

write_output ...[-overwrite]

  • resource我s the resource to update
  • key value pair我s 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.
Bash Powershell Option Description
--overwrite -overwrite

If supplied, all key value pairs will be replaced.

Examples

write_output myImage我mageTag=mastersha=$commitShadescription=\"hello world\"


The newly attached properties can be accessed as environment variables of the formres_{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 canreduce 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我s a file or directory to store in the cache
  • name我s a name to give the stored file or directory (without spaces)
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 in the cache.

Usage

restore_cache_files

  • name我s the name the file or driectory to be restored was given when cached.
  • path我s a path at which to place the file or directory.
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.

If the following variables are set, they will be used:

  • JFROG_CLI_BUILD_NAME: If set, the pipeline uses this value instead of the default pipeline name for the build info collected.
  • JFROG_CLI_BUILD_NUMBER: If set, the pipeline uses this value instead of the default run number for the build info collected.
  • USE_LOCAL_JFROG_CLI: Ifset astrue, the local JFrog CLI on the host or in the image (depending onruntimeconfiguration) is used instead of the version packaged with JFrog Pipelines. This is not recommended and native steps may not be able to run with the local JFrog CLI version.

Usage

add_run_variables ...

  • key value pair我s 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.
Examples

add_run_variables我mageTag="master"

export_run_variables

Description

源文件包含运行变量。这s will be done automatically, but may also be used to “reset” the environment variables in the current step.

Usage

export_run_variables

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我sa file or directory to store in the run state

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

Examples

add_run_files cachefile.txt my_file

add_run_files directory/subdirectory my_directory

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 in the run state.

Usage

restore_run_files

  • name我sthe name the files to be restored were given when added to the run state.
  • path我s a path at which to place the file or files.
Examples

restore_run_files my_file cachefile.txt

restore_run_files my_directory directory/subdirectory


Affinity Group State Management

add_affinity_group_files

Description

Copies files or directories given as input into the affinity group workspace for use in later steps in the affinity group. Files or directories may be specified using wildcards (*) or as multiple input parameters preceding the name under which the files will be stored.

Usage

add_affinity_group_files

file or directory我sa file or directory to store in the run state.

name我s a name to give the stored file or directory (without spaces).

Examples

add_affinity_group_files cachefile.txt my_file

add_affinity_group_files myDirectory myOtherDirectory/subdirectory my_directories

add_affinity_group_files myDirectory/*.txt my_text_files

add_affinity_group_files ../adjacentDirectory my_adjacent_directory

restore_affinity_group_files

Description

Copies files stored in the affinity group workspace byadd_affinity_group_filesto the specified location. The restore behavior differs from the other state restore functions to better handle wildcard patterns with a variable number of matching files or directories. Withrestore_affinity_group_files, the relative path specified in theadd_affinity_group_filesfunction will be preserved (excluding any traversal to parent directories) and the path specified should be the base for that relative path. The following examples are to symmetrically restore the files saved in the examples above foradd_affinity_group_files.No error will occur if no files were saved for .

Usage

restore_affinity_group_files

  • name我sthe name the files to be restored were given when storing the files withadd_affinity_group_files.
  • path我s a path at which to place the file or files.
Examples

restore_affinity_group_files my_file .

restore_affinity_group_files my_directories .

restore_affinity_group_files my_text_files .

restore_affinity_group_files my_adjacent_directory ..


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.

If the following variables are set, they will be used:

  • JFROG_CLI_BUILD_NAME: If set, the pipeline uses this value instead of the default pipeline name for the build info collected.
  • JFROG_CLI_BUILD_NUMBER: If set, the pipeline uses this value instead of the default run number for the build info collected.
  • USE_LOCAL_JFROG_CLI: Ifset astrue, the local JFrog CLI on the host or in the image (depending onruntimeconfiguration) is used instead of the version packaged with JFrog Pipelines. This is not recommended and native steps may not be able to run with the local JFrog CLI version.

Usage

add_pipeline_variables ...

  • key value pair我s 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.
Examples

add_pipeline_variables我mageTag="master"

add_pipeline_variables我mageName="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

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我sa file or directory to store in the pipeline state.
  • name我sa name to give the stored file or directory (without spaces). This cannot be pipeline.env.
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 in the run state.

Usage

restore_pipeline_files

  • name我sthe name the file to be restored was given when added to the pipeline state.
  • path我s a path at which to place the file or files.
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我s the name of the resource.
  • propertyName我s the name of the resource property whose value to retrieve.
Examples

find_resource_variable myGitHubcommitSha

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

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我nputResourcesoroutputResources. Available to extension steps to get the name of the first input or output resource of a particular type.

Usage

get_resource_name --type --operation --syntax-version

  • resource type我s the name of aPipelines Resource type
  • IN | OUTselects whether the resource is named in我nputResourcesoroutputResources
  • semver我s the semantic version number of the resource's syntax version
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

get_resource_names

Description

Retrieves an array of names of the type specified in我nputResourcesoroutputResources. Available to extension steps to get the names of input or output resource of a particular type.

Usage

get_resource_names --type --operation --syntax-version

  • resource type我s the name of aPipelines Resource type
  • IN | OUTselects whether the resource is named in我nputResourcesoroutputResources
  • semver我s the semantic version number of the resource's syntax version
  • In PowerShell, a native PowerShell array is returned. In Bash, a JSON array is returned that can be handled with jq.
Examples

get_resource_names --type GitRepo --operation IN

get_resource_names --type BuildInfo --operation OUT

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

get_affinity_group_step_names

Description

Retrieves a JSON array of names of steps of the type specified in the current affinity group.

Usage

get_affinity_group_step_names [--type ] [--syntax-version ] [--namespace ]

  • --type我s used to specify the type of the steps to be found. If not specified, steps of all types will be returned.
  • --syntax-version我s used with extension steps to specify the syntax version of the steps to be found.
  • --namespace我s used with extension steps to specify the namespace of the steps to be found.
Examples

get_affinity_group_step_names

get_affinity_group_step_names --type GitRepo

get_affinity_group_step_names --type MyExtension --syntax-version 1.5.0

get_affinity_group_step_names --type MyExtension --namespace myNamespace --syntax-version 1.5.0

find_step_configuration_value

Description

Retrieves the value of theconfigurationproperty 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我s the name of the step's configuration property whose value to retrieve
Examples

find_step_configuration_value forceXrayScan

  • No labels
Copyright © 2023 JFrog Ltd.