Types of State
JFrog Pipelines supports three types of state: run state, pipeline state, and resource state. Each of these states is characterized by the scope of information persistence.
Run State
A pipeline's run state is persistent only between steps within the same run. Information stored in one step is available to subsequent steps in the run of that pipeline. Once the run is complete, that state information is no longer available.
To preserve state across steps, use the utility functions for run state management. Pipelines supports two types of run state information that can be preserved between steps.
Key-Value Pairs
Using the add_run_variables
utility function, you can store a key-value pair to the run state. That key-value pair will automatically be available to all subsequent steps in the run as an environment variable.
Files
Using the add_run_files
utility function, a step can store a file to the run state. Any subsequent step can then use the restore_run_files
function to retrieve the file from the run state.
Pipeline State
A pipeline state is persistent for all runs of the same pipeline. Information stored by a step during a pipeline's run is available to subsequent runs of that pipeline.
To preserve state across pipelines, you may use the utility functions for pipeline state management. Pipelines supports two types of run state information that can be preserved between steps.
Key-Value Pairs
Using the add_pipeline_variables
utility function, you can store a key-value pair to the pipeline state. That key-value pair will automatically be available to all subsequent runs as an environment variable.
Files
Using the add_pipeline_files
utility function, a step can store a file to the pipeline state. Any step can then use the restore_pipeline_files
function to retrieve the file from the pipeline state.
Resource-based State
Using the write_output
utility function, key-values can be stored as a property in any output resource. Every step that has the resource as an input can access the key-value information in its scripts as an environment variable.
The environment variable for the value will be of the form res_<resource name>_<key name>
.
Resource-based state information is persistent across pipelines, so it can be used as a mechanism for passing information from one pipeline to the next.