Continuous Integration

You can use the State Tool with your Continuous Integration (CI) and Continuous Delivery (CD) processes and tools to define simple and reliable processes for building, testing, and deploying your software projects. You can download a custom language runtime with your code’s specific language and package requirements, and run scripts as required throughout the build process.

The basic process you need to follow is:

  1. Gather environment variable settings: Retrieve the environment variables required to authenticate with the ActiveState Platform.
  2. CI/CD Setup: Configure the integration between your CI/CD and your code repository. For example, link your GitHub repository to your AppVeyor account and provide the necessary authorization to AppVeyor.
  3. Platform Setup: Create a Platform project with your language, operating system, and package requirements.
  4. Configure activestate.yaml: state activate to generate the activestate.yaml file for the project and add it to your code repository.
  5. 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. For example, a Jenkinsfile for Jenkins, or an appveyor.yml file for AppVeyor.
  6. 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 you may want to check out our Example Dockerfile to get you started quickly.

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:

state export private-key

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.