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.

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 <projectname>

Example response:

Note that this key is not stored by ActiveState. Please store the value for later use as you cannot retrieve it again. XYZjMmMwYTgtZWRkOS00ZGRiLThmMWEtNDM4NjlhNzE0MTI0IkNlUnZpQml12345678910

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