Shipa supports integrations with the main CI tools used by organizations today and can be leveraged by users to deploy existing applications and code directly on Shipa.
CI integrations are performed using Shipa's CI utility, called shipa-ci, which can be called and run from any standard CI tool available today.
The utility, shipa-ci, can be installed through PIP, the standard package manager for Python, as described below:
$ pip install shipa-ci
Today, shipa-ci is divided into two main sub-components, app and pool, through which users can create, move and update applications and create and update pools directly from their CI/CD pipeline.
Below are some of the commands available through shipa-ci
Creates an application on Shipa utilizing an existing pool
Moves an existing application between different pools
Deploys the application code into an existing Shipa application.
When performing Canary deployments, the following arguments are also available:
--steps: how many steps for the canary deployment
Removes an application from Shipa
Adds a pool to Shipa. Users can pass a pool template YAML file with the pool configuration to be added. More information can be found here
Updates an existing pool on Shipa
When leveraging shipa-ci, the following arguments are available to authenticate the shipa-ci component inside the CI/CD pipeline with the target Shipa instance:
Shipa target server (for example http://shipa-ci-integration.org:8080)
Shipa user email
Shipa user password
Shipa user token
If the goal is to utilize token instead of user and password for authentication, the user token should be created beforehand by running the command token-create command. More information can be found on the Tokens page of this manual.
Below you can find some examples when using shipa-ci:
Creating an application:
shipa-ci --server=$SHIPASERVER --email=$SHIPAEMAIL --password=$SHIPAPASSWORD app create <app-name> <platform> --team=<team-name> --pool=<pool-name>
Deploying an application (no canary):
shipa-ci --server=$SHIPASERVER --email=$SHIPAEMAIL --password=$SHIPAPASSWORD app deploy --app=<app-name>
Through shipa-ci, users can take advantage of Canary Deployments, as per example below:
shipa-ci --server=$SHIPASERVER --email=$SHIPAEMAIL --password=$SHIPAPASSWORD --verbose app deploy --app=travis --steps=3 --step-interval=1m --step-weight=20
The line above should be included inside your CI/CD pipeline.
More examples are described in the following section.
Below are a couple of examples of integrating Shipa with industry-standard CI tools.
When integrating Shipa with Travis CI, users should create a .travis.yml file in the code repository of your choice, such as Git. Users can then leverage the .travis.yml file to direct Travis CI to deploy the application to Shipa once the build is confirmed successfully.
Below is an example of a .travis.yml file:
language: python python: - "2.7" jobs: include: - stage: build script: 'pip install -r requirements.txt && python -m unittest discover' - stage: deploy script: 'pip install shipa-ci && shipa-ci app deploy --app=app-name --server=$SHIPASERVER --email=$SHIPAEMAIL --password=$SHIPAPASSWORD --verbose'
Another example of integration is CircleCI. When integrating Shipa with CircleCI, users should create a folder named .circleci in the root directory of their existing Git repositories. Inside this folder, a file called config.yml should be placed, where the integration with Shipa will be described.
Below is an example of a config.yml file for CircleCI:
version: 2 # use CircleCI 2.0 jobs: # A basic unit of work in a run build: # runs not using Workflows must have a `build` job as entry point # directory where steps are run working_directory: ~/sample docker: # run the steps with Docker # CircleCI Python images available at: https://hub.docker.com/r/circleci/python/ - image: circleci/python:3.6.4 steps: # steps that comprise the `build` job - checkout # check out source code to working directory - run: sudo chown -R circleci:circleci /usr/local/bin - run: sudo chown -R circleci:circleci /usr/local/lib/python3.6/site-packages - run: sudo chown -R circleci:circleci ~/sample - run: sudo pip install -r requirements.txt && python -m unittest discover - run: command: | sudo pip install shipa-ci - run: command: | sudo shipa-ci app deploy --app=app-name --server=http://x.x.x.x:8080 [email protected] --password=xxxx --verbose - store_test_results: # Upload test results for display in Test Summary: https://circleci.com/docs/2.0/collect-test-data/ path: test-results - store_artifacts: # Upload test summary for display in Artifacts: https://circleci.com/docs/2.0/artifacts/ path: test-results destination: tr1
Updated about 15 hours ago