Use the State Tool in Your CI/CD Environments
The State Tool integrates with Continuous Integration and Continuous Delivery (CICD) pipelines to streamline the build, test, and deployment workflow for software projects. By incorporating the State Tool into your pipeline, you can download custom language runtimes configured with specific language versions and package dependencies, then execute build scripts at any stage of the process.
The basic process you need to follow is:
- Gather environment variable settings: Retrieve the environment variables required to authenticate with the ActiveState Platform.
- CI/CD Setup: Configure the integration between your CI/CD and your code repository.
- Platform Setup: Create a Platform project with your language, operating system, and package requirements.
- Generate an activestate.yaml: Configure
activestate.yaml: state activate to generate the activestate.yaml file for the project and add it to your code repository. - Build Setup: Add a configuration file to your repository with the build configuration for your CI/CD tool that installs the State Tool and runs any other build steps.
- Webhook Setup: Add a webhook to your version control repository if required. In some cases this may be completed automatically when you are integrating your code repository with the CI/CD tool in step 2. In other cases, it may be a manual step you need to complete.
For your convenience refer to this example dockerfile.
Gathering environment variable settings
Before you begin:
- You need an ActiveState Platform account. If you do not currently have an account you can sign up for free at: platform.activestate.com/create-account.
- You need to have the State Tool installed on your computer and authorized with the Platform using the
state auth command. You need this to run the command to retrieve the API key.
The State Tool will use the following environment variables if they are defined:
- ACTIVESTATE_API_KEY: This API key is used to authenticate the State Tool with the ActiveState Platform, as required, to download language projects, update packages, etc. If you use ActiveState Platform secrets in your build process or scripts run by the build process, you must also configure the ACTIVESTATE_PRIVATE_KEY.
- ACTIVESTATE_PRIVATE_KEY: Optional. The private key to use for decrypting secrets.
Obtaining your API Key
You can obtain an API key by opening a command prompt and running the following State Tool command:
state export new-api-key key-name
In this example, you would copy the token value (the long string at the end of the response) to use as the ACTIVESTATE_API_KEY environment variable in your CI/CD application.
Obtaining your Private Key
You can obtain your private key by opening a command prompt and running the following State Tool command:
Disabling Updates
It is recommended you disable updates on automated environments, so as not to interrupt your automations when state tool updates become available. To do this, simply run:
state config set autoupdate false
You can still manually update by running state update.
Blog posts about ActiveState working with popular CI/CD providers