The following sections describe the tasks you need to complete to set up a CI/CD process with AppVeyor, your version control system (VCS), and the ActiveState Platform. You need the appropriate access to these systems to complete the setup. In the examples below, we show configuration steps for GitHub specifically. You may need to adjust some of the tasks if you are using a different VCS.
Before you begin:
state auth
command, in order to run the command to retrieve the API key, and to access your private.key
file if you are using secrets.The State Tool will use the following environment variables if they are defined:
You can obtain an API key by opening a command prompt and running the following State Tool command:
state export new-api-key APIKeyForCI
Example response:
Note that this key is not stored by ActiveState. Please store the value for later use as you cannot retrieve it again.
XYZjMmMwYTgtZWRkOS00ZGRiLThmMWEtNDM4NjlhNzE0MTI0IkNlUnZpQmlQXYZYXYZ
In this example, you would copy the token value on the second line to use as the ACTIVESTATE_API_KEY environment variable in your CI/CD application.
You can find the private key value at <configdir>/activestate/cli-unstable/private.key
.
The configdir varies per platform, but in most cases will be at one of:
%HOME%\AppData\Roaming\activestate\cli-unstable\
~/config/activestate/cli-unstable/
~/Library/Application\ Support/activestate/cli-unstable/
The private key environment variable expects the contents of the private.key
file, not the filepath.
The ACTIVESTATE_API_KEY is used to authenticate the State Tool automatically whenever required by the CI/CD build steps.
You can use either the Dashboard or the State Tool to create a new project and add the language, platforms, and packages your project requires. Set up your project by:
After you create an ActiveState project, complete the following steps to activate your project and add the configuration file to your code repository, so that the CI/CD has access to it.
state activate <owner/project_name>
. For example: state activate acmetech/python-3-6-6
.activestate.yaml
configuration file to the root directory of your code repository.activestate.yaml
to add any scripts, variables, or secrets you want CI/CD to run or have access to. For more information on these options, see Getting started.activestate.yaml
to the repository and check in your changes.You need to add an appveyor.yml
file to the root of your code repository that includes all of the steps required to build, test, and deploy your code. The example provided demonstrates the State Tool-specific steps for installing the State Tool and running scripts that are defined in the activestate.yaml
file for the project. The AppVeyor project is configured to build on Windows.
version: 1.0.{build}
image: Visual Studio 2019
init:
- ps: ''
install:
- ps: >-
(New-Object Net.WebClient).DownloadFile('https://platform.activestate.com/dl/cli/install.ps1', 'install.ps1')
Invoke-Expression "install.ps1 -n"
build_script:
- cmd: state --version
test_script:
- cmd: >-
state pull
state run pip_install_pkgs_win
state run build_installer_win
dir
The scripts being executed in the appveyor.yml
file are defined in the scripts section of the activestate.yaml
file for the project:
scripts:
- name: clean
description: Run the data cleaner script
value: python3 cleaner.py
- name: which-python
description: Determine which python interpreter is being used
language: python3
value: |
import sys
print("Python script running with: ", sys.executable)
If you successfully configured your AppVeyor CI project, you will see a job start and complete successfully each time someone pushes new code changes to the repository.