Jenkins
Jenkins is a powerful, highly flexible and popular open source automation platform that is often used to automate builds and deployments.
Integrating Jenkins with Golive can allow you to:
Reading this page, you will find tutorials and example Jenkins pipelines that you can re-use to adapt your own pipelines.
Video tutorial
Jenkins Shared Lib
You can find documentation and sample scripts on our shared lib github project:
https://github.com/apwide/jira-jenkins-shared-lib
Use Case Examples
Send deployment information from a Jenkins pipeline (Shared Library)
Here are the steps you can re-use in your Jenkins pipelines, in order to send deployment information from Jenkins to Golive and keep track of status during deployment.
This example is using our open source Jenkins Shared Lib
If you want to use curl instead, refer to the next section.
@Library('apwide-jenkins-shared-lib')
pipeline {
agent any
environment {
// APW_JIRA_BASE_URL = 'https://mycompany.com/jira'
// APW_JIRA_CREDENTIALS_ID = 'jira-credentials'
// Better to define above environment variables globally
VERSION_NAME = "2.1.5.0"
BUILD_NUMBER = currentBuild.number
DEV_ENV_ID = 6 // identifies the target environment
DEPLOY_STATUS_NAME = "Deploy"
UP_STATUS_NAME = "Up"
}
parameters {
choice(
name: 'PROMOTE_TO_ENV',
choices: ['Dev', 'Demo'],
description: 'Should the output be promoted to an environment ?'
)
}
stages {
stage('Build & Test') {
steps {
script {
sh 'sleep 2s'
// this simulates a build stage
}
}
}
stage('Deploy on Dev') {
when {
equals expected: 'Dev', actual: params.PROMOTE_TO_ENV
}
steps {
apwSetEnvironmentStatus(
environmentId: env.DEV_ENV_ID,
status: env.DEPLOY_STATUS_NAME
)
sh "sleep 5s" // this simulated a deployment execution
apwSendDeploymentInfo(
environmentId: env.DEV_ENV_ID,
version: env.VERSION_NAME,
buildNumber: env.BUILD_NUMBER
)
// this pushes the deployment information to Golive
// N.B. This also automatically adds the list of Jira tickets
// found in commit history (since the last successful build),
// to the deployment description
apwSetEnvironmentStatus(
environmentId: env.DEV_ENV_ID,
status: env.UP_STATUS_NAME
)
}
}
}
}
Send deployment information from a Jenkins pipeline (curl)
Here are the steps you can re-use in your Jenkins pipelines, in order to send deployment information from Jenkins to Golive and keep track of status during deployment.
This example is using curl, which has to be present on the agent you are running the pipeline on.
If you want to use the Shared Lib instead, refer to the previous section.
pipeline {
agent {
label "mvn"
}
environment {
GOLIVE_BASE_URL = "https://golive.apwide.net/api"
ENV_ID = 6
// Jenkins credentials id of secret storing a previously generated golive token
// https://golive.apwide.com/doc/latest/cloud/rest-api#RestAPI-api-tokenAPITokenAuthentication
CREDENTIALS_ID = "golive-cloud-api-token"
DEPLOY_STATUS_NAME = "Deploy"
UP_STATUS_NAME = "Up"
}
parameters {
choice(
name: 'PROMOTE_TO_ENV',
choices: ['Dev', 'Demo'],
description: 'Should the output be promoted to an environment ?'
)
}
stages {
stage('Build & Test') {
steps {
script {
// simulate a build stage
sh 'sleep 2s'
}
}
}
stage("Deploy on Dev") {
when {
equals expected: 'Dev', actual: params.PROMOTE_TO_ENV
}
steps {
container("atlas-sdk") {
withCredentials([string(credentialsId: "${env.CREDENTIALS_ID}", variable: "goliveToken")]) {
script {
def versionName = "9.6.7"
def buildNumber = env.BUILD_NUMBER
// inform Golive of new deployment on going
sh """curl -H 'Authorization: Bearer ${goliveToken}' -X PUT -H 'Content-Type: application/json' -d '{"name":"${env.DEPLOY_STATUS_NAME}"}' ${env.GOLIVE_BASE_URL}/status-change?environmentId=${env.ENV_ID}"""
// simulate deployment
sh "sleep 5s"
// inform Golive of new deployed version
sh """curl -H 'Authorization: Bearer ${goliveToken}' -X PUT -H 'Content-Type: application/json' -d '{"versionName":"${versionName}","buildNumber":"${buildNumber}"}' ${env.GOLIVE_BASE_URL}/deployment?environmentId=${env.ENV_ID}"""
// inform Golive environment is up again
sh """curl -H 'Authorization: Bearer ${goliveToken}' -X PUT -H 'Content-Type: application/json' -d '{"name":"${env.UP_STATUS_NAME}"}' ${env.GOLIVE_BASE_URL}/status-change?environmentId=${env.ENV_ID}"""
}
}
}
}
}
}
}
Use Jenkins as an url checker to update statuses of your environments
In this example you will learn how you can easily put in place a Jenkins pipeline that will automatically monitor a set of Golive Environments thanks to our integration with Jenkins.
Liveness Probe components:
probe url : we will simply re-use the url set in Golive environments
job: jenkins pipeline job
job scheduler: jenkins
With the Apwide Jenkins Shared Lib
The following jenkins pipeline uses our Jenkins Shared Lib:
@Library('apwide-jenkins-shared-lib@develop') _
pipeline {
agent any
options {
disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: '1'))
}
triggers {
cron('*/10 * * * *') // triggered every 10 minutes
}
environment {
// check jenkins shared lib documentation to configure credentials
APW_GOLIVE_CLOUD_CREDENTIALS_ID = 'golive-cloud-api-token'
APW_UNAVAILABLE_STATUS = 'Down' // adapt to your own status name
APW_AVAILABLE_STATUS = 'Up' // adapt to your own status name
}
stages {
stage('Golive Environments Monitoring') {
steps {
// check the url of all golive environments for application "e-Com"
apwCheckEnvironmentsStatus application:'e-Com'
// check the url of all golive environments for application "ERP"
apwCheckEnvironmentsStatus application:'ERP'
}
}
}
}
Other more advanced examples of useful Jenkins pipelines to monitor your environments can be found here: https://github.com/apwide/apwide-jenkins-shared-lib/tree/master/examples/monitoring
Automatically get the versions of the apps installed on your Jira servers
At Apwide, we use several testing environments to deploy and test the various versions of our Jira apps. As we are installing our apps manually on certain Jira environments (ex: on our DEMO environment), we had to find a solution to retrieve this information directly from our test Jira instances.
Following the “eating your own dog food” principle, we are using Golive to track the versions of our apps that are deployed to our various Jira testing environments.
Model our testing environments in Golive
First step was to store all information (required to query our testing environments) in Golive:
create our Jira apps as Golive applications
create one Golive environment for each deployed Jira app
use environment attributes to store the app keys, Jira base urls,…

Some of our apps testing environments modeled in Golive
Jenkins job retrieving and pushing current deployment state of our apps to Golive
This pipeline is executed every 5 minutes by Jenkins to update status and deployment information of your Jira apps:
pipeline {
agent {
label 'monitoring'
}
options {
disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: '1'))
}
triggers {
cron('*/5 * * * *')
}
environment {
// APW_JIRA_BASE_URL = 'https://your-jira-data-center-base-url'
// APW_JIRA_CREDENTIALS_ID = 'jira-jenkins-user'
APW_GOLIVE_CLOUD_CREDENTIALS_ID = 'golive-cloud-api-token'
APW_UNAVAILABLE_STATUS = 'Down'
APW_AVAILABLE_STATUSA = 'Up'
}
stages {
stage('Apwide Jira Applications Monitoring') {
steps {
apwCheckEnvironmentsStatus criteria: [
'jira-plugin-key': '*'
], checkStatus: { environment ->
def pluginKey = java.net.URLEncoder.encode(environment.attributes['jira-plugin-key'], "UTF-8")
def baseUrl = environment.attributes['base-url']
echo "baseUrl: ${baseUrl}"
def credentialsId = credentialsMapping[environment.category.name]
def pluginInformation = apwCallJira(
jiraBaseUrl: baseUrl,
jiraCredentialsId: credentialsId,
path: "/rest/plugins/1.0/${pluginKey}-key" // https://ecosystem.atlassian.net/wiki/spaces/UPM/pages/6094960/UPM+REST+API
)
def pluginVersion = pluginInformation.version
echo "Plugin version: ${pluginVersion}"
apwSetDeployedVersion(
environmentId: environment.id,
version:pluginVersion
)
}
}
}
}
}