Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/amazeelabs/algm_jenkins_scripts

Example script and documentation for deploying Lagoon environments using Jenkins
https://github.com/amazeelabs/algm_jenkins_scripts

Last synced: 2 days ago
JSON representation

Example script and documentation for deploying Lagoon environments using Jenkins

Awesome Lists containing this project

README

        

# Lagoon/Jenkins integration examples

The present repository demonstrates how to interact with a Lagoon instance from within a Jenkins build.

It describes the most basic integration and explains how one can use this functionality within your own build process.
Down the line, if there is a need, we can potentially build the functionality here into a shared Jenkins library.

There are two methods presented - one via an sh function, the other via a Jenkins function. Both methods are demonstrated in the present repo's Jenkinsfile.

## Setup

### Set up Jenkins credentials
Ssh credentials are needed for the script to connect to Lagoon and [pull down the JWT](https://lagoon.readthedocs.io/en/latest/using_lagoon/graphql_api/#connect-to-graphql-api) which will subsequently
be used to actually kick off the deployment on the Lagoon instance. Follow the steps described here: [https://jenkins.io/doc/book/using/using-credentials/](https://jenkins.io/doc/book/using/using-credentials/).

Note - the "id" of the credentials is what will be passed as the first argument to the `lagoonDeployEnvironment` function (described below).

### Using the Jenkins sh script

1. Copy the lagoon_bash_lib.sh file into your repository
2. Include the functions by running `. ./lagoon_bash_lib.sh` which will make the lagoon_deploy function available to your script
3. call `lagoon_deploy project-id environment`

### Using the Jenkins deploy scripts in your Jenkinsfile

The simplest way to (presently) use the scripts here for deployment is to simply copy/paste the `lagoonDeployEnvironment` function
from this repository's Jenkinsfile and paste it into your own pipeline.
The function can then be called from within your pipeline - it takes six arguments (the last three of which are optional, used for self hosted lagoon instances).
These are
1. sshAgentName - the id of the ssh credentials as described above
2. Lagoon project id
3. The Lagoon environment
4. (optional) the lagoon graphql endpoint - defaults to 'https://api.lagoon.amazeeio.cloud/graphql'
5. (optional) the lagoon ssh endpoint - defaults to 'ssh.lagoon.amazeeio.cloud'
6. (optional) the lagoon ssh port - defaults to 32222

It will return a boolean indicating whether the process of _calling_ the deploy was successful (whether the actual deploy is successful is a separate matter).