Use with Jenkins

Cycleops can be automated in a few steps to be part of your existing CI/CD system with Jenkins. All that is needed to integrate Jenkins actions is:

Requirements

  • Jenkins installed on a server
  • Python 3.11 or newer installed on the Jenkins server
  • An API key for Cycleops

Instructions

  1. Create a new Freestyle project
  2. Add an Execute shell build step to install the Cycleops CLI:
    pip install cycleops
    
  3. Add an Execute shell build step to update your Cycleops service with a new image:
    export CYCLEOPS_API_KEY=<your_cycleops_api_key>
    cycleops services update-container <service_name> <container_name> --image <image_name>:<image_tag>
    
  4. Add an Execute shell build step to deploy your Cycleops setup:
    export CYCLEOPS_API_KEY=<your_cycleops_api_key>
    cycleops setups deploy <setup_name>
    

The Cycleops CLI is open source with its documentation available at GitHub: https://github.com/stackmasters/cycleops.

Advanced

Use with Docker

You can use the Cycleops CLI via its Docker image (ghcr.io/stackmasters/cycleops), instead of depending on Python. In order to do this, pass your Cycleops API key in the CYCLEOPS_API_KEY environment variable, by using the -e flag and CYCLEOPS_API_KEY.

Example build step:

docker run -e CYCLEOPS_API_KEY=<your_cycleops_api_key> \
       ghcr.io/stackmasters/cycleops \
       cycleops services update-container <service_name> <container_name> --image <image_name>:<image_tag>

Credential bindings

Your Cycleops API key is sensitive and should be kept secret. For that reason, to further guard your system against attacks, it should be handled with a sensitive data manager like the Credential Binding Plugin. To set the value of your Cycleops API key in the Use secret text(s) or file(s) environment variable, in the project configuration page:

  1. Go to the Build environment section
  2. Select Use secret text(s) or file(s)
  3. Click Add and then Secret text
  4. Fill in CYCLEOPS_API_KEY in the Variable field
  5. Select Add and then Jenkins under Credentials
  6. Select the Global credentials (unrestricted) value under Domain
  7. Select Secret text under Kind
  8. Select the Global, under Scope
  9. Type the value of your Cycleops API key in Secret
  10. Type cycleops-api-key in ID
  11. Click Add

Now you can use your Cycleops API key securely via the CYCLEOPS_API_KEY environment variable.

Example with Cycleops CLI when installed with Python:

cycleops services update-container <service_name> <container_name> --image <image_name>:<image_tag>

Example with Cycleops CLI when used via Docker:

docker run -e CYCLEOPS_API_KEY=$CYCLEOPS_API_KEY \
       ghcr.io/stackmasters/cycleops \
       cycleops services update-container <service_name> <container_name> --image <image_name>:<image_tag>