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

https://github.com/opslevel/jenkins-opslevel-plugin

Jenkins plugin to notify OpsLevel about successful deploys from Jenkins projects and builds.
https://github.com/opslevel/jenkins-opslevel-plugin

Last synced: 12 months ago
JSON representation

Jenkins plugin to notify OpsLevel about successful deploys from Jenkins projects and builds.

Awesome Lists containing this project

README

          

# OpsLevel plugin for Jenkins
[![Overall](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fapp.opslevel.com%2Fapi%2Fservice_level%2F_ZFHfdnK9K5lBrdYKUY2XNKD-myqG3y2qsgkl_MK0eY)](https://app.opslevel.com/services/jenkins_plugin/maturity-report)

Provides Jenkins integration with OpsLevel. This allows you to notify OpsLevel when a deploy succeeds.

# Getting started
## Add a Jenkins Integration in OpsLevel
1. Get an OpsLevel account
1. In the OpsLevel app, Click **Integrations** in the left sidebar
1. Click on the **+ New Integration** button
1. Add the **Jenkins Integration**
![Jenkins Integration](docs/images/jenkins_integration.png)

## Install the Jenkins plugin
1. From your Jenkins home page, navigate to **Manage Jenkins**
1. Navigate to **Manage Plugins**
1. Change the tab to **Available**
1. Search for 'opslevel'
1. Check the box next to install & install the plugin

## Jenkins Configuration
### Global Configuration
1. From your Jenkins home page, navigate to **Manage Jenkins**
1. Navigate to **Configure System**
1. Find the **Global OpsLevel Integration** section
1. In the OpsLevel App, copy the webhook URL from the **Jenkins Integration** we made:
![Jenkins Integration Webhook URL](docs/images/jenkins_integration_webhook_url.png)
1. paste it into the **Deploy Webhook URL** box:
![Jenkins Global Configuration](docs/images/opslevel_global_configuration.png)
1. Click Save

OpsLevel will now be notified after every successful build!

If you need more fine grained control, you can override the notification parameters from within your builds/pipelines. Importantly, if you don't want to notify every single build, you could uncheck the **Notify for all builds** checkbox in the Global Configuration and just add build steps to the builds you care about. Similarly, if there only a few builds that you want to mute, you could enable notifications globally and override specific builds to not run. Here's a look at what the configuration looks like for both pipelines and freestyle jobs:

### Pipeline Configuration
1. Navigate to your job and click **Configure** in the left sidebar
1. Add an `opsLevelNotifyParams` post step with the desired parameter overrides:
![Jenkins Pipeline Configuration](docs/images/opslevel_pipeline_configuration.png)
1. Here's an example of the parameters you can override:
```
opsLevelNotifyParams(
webhookUrl: "https://app.opslevel.com/integrations/deploy/3e06d761-0347-4741-a617-XXXXXXXXXXX",
serviceAlias: "catalog_service",
environment: "Staging",
description: "Test Description",
deployUrl: "",
deployerId: "",
deployerEmail: "",
deployerName: "Jenkins Test Deploy",
run: true
)
```

### Freestyle Job Configuration
1. Navigate to your job and click **Configure** in the left sidebar
1. Add our post-build action **Publish successful build to OpsLevel**
1. You can override notification parameters here:
![Jenkins Configuration](docs/images/opslevel_post_build_action.png)

# Developer Instructions

Refer to jenkins plugin guidelines: [contribution guidelines](https://github.com/jenkinsci/.github/blob/master/CONTRIBUTING.md)

Install Maven and JDK.

```shell
$ mvn -version | grep -v home
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Java version: 15.0.2, vendor: N/A, runtime: /usr/local/Cellar/openjdk/15.0.2/libexec/openjdk.jdk/Contents/Home
Default locale: en_CA, platform encoding: UTF-8
OS name: "mac os x", version: "10.15.7", arch: "x86_64", family: "mac"
```

Run unit tests

```shell
mvn test
```

## Create plugin package
Create an HPI file to install in Jenkins

```shell
mvn clean package
```

## Running Locally

Clone this repo, install Java & Maven, run this, and open `http://localhost:8080/jenkins/` in your browser.
```
env -i PATH=$PATH mvn hpi:run
```
That optional `env -i PATH=$PATH` removes all env vars except `PATH`.

## LICENSE

Licensed under MIT, see [LICENSE](LICENSE.md)