state resource is a special resource used to store information that can be shared between jobs upstream and downstream across your Assembly Line. This information can be a file and/or key:value pairs.
For any other job or resource, we do not allow workflows that have circular dependencies to avoid infinite loops. However, there are some situations where you do need information passed back and forth between jobs. A classic example is if you're provisioning and de-provisioning environments using Terraform, which means that the Terraform statefile will need to be persisted across job runs and shared between different jobs.
state resource allows circular references since it never triggers the dependent job when it changes. It is only meant to store information and make it available when the job needs it.
You can create a
state resource by adding it to shippable.yml.
resources: - name: <string> type: state
name-- should be an easy to remember text string
type-- is set to
Usage in Assembly Lines
This resource is used as an
runCI jobs. Please read the Using central state tutorial to learn about how you can store and use files and key-value pairs in the
Default Environment Variables
state is used as an
OUT for a
runCI job, a set of environment variables is automatically made available that you can use in your scripts.
<NAME> is the the friendly name of the resource with all letters capitalized and all characters that are not letters, numbers or underscores removed. Any numbers at the beginning of the name are also removed to create a valid variable. For example,
my-key-1 will be converted to
my_key_1 will be converted to
||The name of the resource.|
||The ID of the resource.|
||The type of the resource. In this case
||The operation of the resource; either
||The directory containing files for the resource.|
||The ID of the version of the resource being used.|
||The number of the version of the resource being used.|
Shippable Utility Functions
To make it easy to use these environment variables, the platform provides a command line utility that can be used to work with these values.
How to use these utility functions is documented here.