Skip to content

CircleCI

fmenkes edited this page Jan 11, 2018 · 6 revisions

Setup

First you need to set up your staging and production machines. See the other guides in this wiki. You'll need to make some changes to the Ansible files so that they point to the correct machines.

In devops/environments/staging/inventory.yml, change ansible_hostname to the appropriate IP of the Openstack staging machine.

In devops/environments/production/inventory.yml, change ansible_hostname to the appropriate IP of the Openstack production machine.

Don't commit anything yet! Save it for when the pipeline is all set up.

To set up the slotmachine CircleCI continuous integration pipeline, follow these steps.

  • First, connect your GitHub account to CircleCI.
  • Then, in the "Add Project" section of the CircleCI dashboard, click on the repo you wish to add to CircleCI.
  • Since you already have a config.yml file, all you need to do is click on "Start Building."
  • You'll need to cancel the build as soon as it starts because the environment variables are missing!
  • Add the environment variables in the project settings. See below.
  • Success! The project will start building as soon as you push a commit to the repo.
  • Click on workflows to see the process in action.

Environment variables:

The following environment variables need to be entered into CircleCI, in Environment Variables under the project settings (Projects -> click the gear to the right of the project name). If the column "Required value" is not empty, the variable must be set to this value. It's probably faster to use the API. See below the table for a JSON document you can edit and send into the API.

You can skip any variables with PRODUCTION in the name if you are not planning on setting up a production machine. Just don't click on the "release" step in the CircleCI dashboard because it will fail!

Name Required value Description
ANSIBLE_HOSTNAME slotmachine the name of the host machine in Ansible
ANSIBLE_HOST_KEY_CHECKING False to make sure Ansible does not fail because of host key checking
DOCKER_HUB_CONTAINER_NAME the name of the container to upload to Docker Hub.
DOCKER_USER Your Docker Hub username
DOCKER_PASSWORD Your Docker Hub password
GITHUB_TOKEN GitHub auth token for student repo organization/user with privileges in the organization
JENKINS_USERNAME Jenkins username
JENKINS_PASSWORD Jenkins password
JENKINS_URL Openstack Jenkins machine URL
SLACK_API_TOKEN_STAGING Slack API token used in staging environment. Starts with xoxp-
SLACK_API_TOKEN_PRODUCTION See above, but for production
SLACK_VERIFICATION_TOKEN_STAGING Slack verification token used in staging environment. Found under "basic information"
SLACK_VERIFICATION_TOKEN_PRODUCTION See above, but for production app
PRODUCTION_URL The domain name/IP of the API in production. Needed for the smoke test to know what server to curl
STAGING_URL See above, but for staging
WORKING_DIRECTORY  /usr/src/app  Working directory of the API Docker container
{
  "ANSIBLE_HOSTNAME":"slotmachine",
  "ANSIBLE_HOST_KEY_CHECKING":"False",
  "DOCKER_HUB_CONTAINER_NAME":"",
  "DOCKER_USER":"",
  "DOCKER_PASSWORD":"",
  "GITHUB_TOKEN":"",
  "JENKINS_USERNAME":"",
  "JENKINS_PASSWORD":"",
  "JENKINS_URL":"",
  "SLACK_API_TOKEN_STAGING":"",
  "SLACK_API_TOKEN_PRODUCTION":"",
  "SLACK_VERIFICATION_TOKEN_STAGING":"",
  "SLACK_VERIFICATION_TOKEN_PRODUCTION":"",
  "PRODUCTION_URL":"",
  "STAGING_URL":"",
  "WORKING_DIRECTORY":"/usr/src/app"
}

Clone this wiki locally