Key-Value Pair Integration

Key-Value Pair Integration is used to inject configurations into Shippable DevOps Assembly Lines activities.

Creating an Integration

You can add this integration by following steps on the Adding an integration page.

Here is the information you need to create this integration:

  • Integration type -- Key-value
  • Name -- choose a friendly name for the integration
  • Key Values -- A collection of Key-Values

Usage in CI

You can use a Key-value integration with CI by adding it as an integration resource IN to the runCI job or by adding it to your shippable.yml as follows:

integrations:  # this section can contain several different types of integrations
  generic:     # k/v pair should be under the 'generic' header
    - integrationName: my-key-value-integration # whatever name you chose for your integration

You can also set Key-value pairs directly as environment variables in CI instead of using an integration.

Usage in Assembly Lines

The Key-value integration can be used in the following resources:

It can also be added directly to the integrations section of a runSh job as shown in the runSh yml.

Default Env Vars

When you create a resource with this integration, and use it as an IN or OUT for a runSh or 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-integration-resource will be converted to MYINTEGRATIONRESOURCE, and my_integration_resource will be converted to MY_INTEGRATION_RESOURCE.

Environment variable Description
<NAME>_INTEGRATION_NAME Name supplied in the integration
MY_KEY_1 Name of the First Key defined and will have value set
MY_KEY_N Name of the Nth Key defined and will have value set
<NAME>_INTEGRATION_MY_KEY_1 The value for the key MY_KEY_1 or my_key_1 in the integration

Shippable Utility Functions

The platform also provides a command line utility called shipctl that can be used to retrieve the values of these environment variables.

The specific function that can be used in the jobs yml is: shipctl get_integration_resource_field <resource name> <field name>.

Here is a table that provides the mapping from the environment variable to the field name.

Environment variable Field Name
<RESOURCE_NAME>_INTEGRATION_MY_KEY_1 my_key_1
<RESOURCE_NAME>_INTEGRATION_MY_KEY_N MY_KEY_N

More information on other utility functions is documented here.

Further Reading