Our next-gen architecture is built to help you make sense of your ever-growing data Watch a 4-min demo video!

Back to All Integrations

Jenkins Plugin Jenkins Plugin

Last Updated: Apr. 24, 2023

This Coralogix Jenkins plugin adds support for sending console logs & stats and pushes tags to Coralogix.
NOTE: The Coralogix plugin will work on Jenkins version 2.277.2 and above, if your Jenkins isn’t in the mentioned versions, you may try our Curl commands located further in the doc.

Installation

  • Download the hpi file from GitHub releases
  • Put the hpi file in the directory $JENKINS_HOME/plugins
  • Restart Jenkins
jenkins plugin

Configuration

This document includes cluster dependent URL’s. Each URL has a variable part (in Italic). Please match this part with a row entry within the following table. Copy the table row entry located under the column that matches the top level domain of your Coralogix account (.com, .in etc.). Choose the correct region from the drop box.

RegionEU (.com)IN(.in)US(.us)
Cluster URLcoralogix.comcoralogix.inapp.coralogix.us

Go to Manage Jenkins, open Configure system, find Coralogix section and configure your account private key for sending system/audit/security logs and metrics (take note that Send system log wont chcek since it’s not currently supported):

You can configure as many keys as you want.

coralogix jenkins setup

If your Coralogix account top level domain is different than ‘.com’ overwrite the Coralogix API endpoint value by going to the Advanced... section and inserting,

https://api.Cluster URL

Credentials

Before usage you need to create Jenkins credentials with Coralogix private key for your team,
go to  Manage Jenkins > Manage Credentials and click on Jenkins under Stores scoped to Jenkins.
You will be welcomed by this table:

coralogix private key

Next, create a new credentail of kind: Coralogix API key, this keys’ value is taken from: Data flow > API keys copy the “Alerts, Rules and Tags API Key” (the first on the list) and insert it into the field.
This will allow us to use the “push tags” function, since it will allow creation of a tag each time there is a build in the pipe.

To push Tags you need to go under your config and click add build step.

Select Push Tags to Coralogix and select the Tags key from your credentials.

Usage

This plugin supports sending build logs and tags pushing both for Freestyle project and Pipelines.

Send logs

Send your build logs to Coralogix.

Freestyle project
Just check the Send build logs to Coralogix, select Private Key, and provide Application name:

jenkins build environment

Pipeline

This is the Groovy implementation:

pipeline {
    agent any
    stages {
        stage('Test') {
            steps {
                echo "Hello world!"
            }
        }
    }
    post {
        always {
            coralogixSend privateKeyCredentialId: 'coralogix-production',
                          application: 'MyApp',
                          subsystem: "${env.JOB_NAME}",
                          splitLogs: true
        }
    }
}

Curl

It’s possible to use Curl command to create a log, choose the correct endpoint and run the command below.
NOTE: “text”, “severity” are optional fields.

ClusterEndpoint
EUhttps://api.coralogix.com/logs/rest/singles
UShttps://api.coralogix.us/logs/rest/singles
INhttps://api.app.coralogix.in/logs/rest/singles
curl --location --request POST '<endpoint>' \
--header 'private_key: <privatekey>' \
--header 'Content-Type: application/json' \
--data-raw '{"applicationName": "prd", "subsystemName": "app", "text": "hello world", "severity": "3"}'

Send metrics

Send your pipeline metrics to Coralogix.

Pipeline

This is the Groovy implementation:

pipeline {
    agent any
    stages {
        stage('Test') {
            steps {
                echo "Hello world!"
            }
        }
    }
    post {
        always {
            coralogixMetricsSend privateKeyCredentialId: 'coralogix-production',
                                 application: 'MyApp',
                                 subsystem: "${env.JOB_NAME}",
                                 splitStages: false
        }
    }
}

Push tag

Push version tag to Coralogix.

Freestyle project
Add build step Push Coralogix tag and configure:

  • Private Key – your Coralogix account private key
  • Tag name – version tag name
  • Application name – your application name
  • Subsystem names – your subsystem names
  • Icon(optional) – your own tag picture

Pipeline

This is the Groovy representation of Push Coralogix tag build step:

pipeline {
    agent any
    stages {
        stage('Test') {
            steps {
                echo "Hello world!"
            }
        }
    }
    post {
        success {
            coralogixTag apiKeyCredentialId: 'coralogix-production-api',
                         tag: '1.0.0',
                         applications: [
                            [name: 'MyApp']
                         ],
                         subsystems: [
                            [name: 'staging'],
                            [name: 'production']
                         ],
                         icon: 'https://raw.githubusercontent.com/coralogix/jenkins-coralogix-plugin/master/docs/images/logo.svg'
        }
    }
}

Curl

It’s possible to use Curl command to create a tag, choose the right Endpoint, add the “APIkey” and run the command below.
NOTE: “timestamp” and “iconUrl” are optional fields.

ClusterEndpoint
.comhttps://webapi.coralogix.com/api/v1/external/tags/
.ushttps://webapi.coralogix.us/api/v1/external/tags/
.inhttps://webapi.app.coralogix.in/api/v1/external/tags/
curl --location --request POST '<yourCoralogixEndpoint>' \
--header 'Authorization: Bearer <APIKey>' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "test tag",
"timestamp": <currentTimeinMilliseconds>
"application": ["prd", "dev"],
"subsystem": ["app", "mobile"],
"iconUrl": "<iconUrl>"
}'

License

The Coralogix Plugin is licensed under the Apache 2.0 License.

On this page