Jenkins: Start and Trigger Workflows


Disclaimer

Your use of this download is governed by Stonebranch’s Terms of Use, which are available at https://www.stonebranch.com/integration-hub/Terms-and-Privacy/Terms-of-Use/

Overview

This integration improves the functionality of Jenkins when orchestrated from Universal Controller. It encourages collaboration by enabling the well-controlled and automated deployment of applications over to the operations side.

  • UAC communicates with Jenkins through the Python Jenkins module.

  • Jenkins can make REST-API calls to the Universal Controller to trigger any task or workflow.

  • This task can trigger or start an existing build job in Jenkins. Universal controller will monitor the build execution in Jenkins until completion, then send the build results to the Controller. With this task, users can create a build job in Jenkins from the Controller. Any Jenkins build job definitions in XML will be stored centrally in the Controller.

  • This task offers the functionality to fetch the Jenkins job build information and list running build info in Jenkins from Universal Controller.

  • Enable/disable Jenkins jobs and nodes and delete/copy/rename Jenkins jobs from Universal Controller.

  • When users list the Installed plugin in Jenkins, a plugin install can be triggered from the Universal Controller.

  • Set the next build info for Jenkins build jobs. 

Software Requirements

This integration requires an Universal Agent and a Python runtime to execute the Universal Task against a Jenkins instance.

Software Requirements for Universal Template and Universal Task

  • Requires Python 3.6 or higher. Tested with the Universal Agent bundled Python distribution.

  • Python modules required:

    • requests

    • Jenkins

Software Requirements for Universal Agent

Either:

  • Universal Agent for Windows x64 Version 7.0 and later with python options installed

  • Universal Agent for Linux Version 7.0 and later with python options installed

Software Requirements for Universal Controller

  • Universal Controller Version 7.0.0.0 and later

Software Requirements for the Application to be Scheduled

This Universal Task has been tested with the following Jenkins versions:

  • 2.1

  • 2.2

Technical Considerations

This Universal Task uses the Python Jenkins Module functions (https://python-jenkins.readthedocs.io/en/latest/) to make REST API calls to Jenkins server.

Jenkins Integration Key Features

Feature

Description

Get Jenkins Jobs build information

Get a Jenkins job build information details

Create a Jenkins Build Job

Allows you to create a Jenkins build job by passing the XML configuration script from Universal Controller

Get Last build number

Get the latest build number for a job

Set Next build number

Allows to set the next build number for the Jenkins job

Trigger or start an existing build job

Trigger an existing Jenkins build job in Jenkins and Universal Controller will monitor the build execution in Jenkins until completion, then send the build results to the Controller

List running build info

Allows to list the build job that are running

Enable/Disable Jenkins Job

function to enable or disable a Jenkins build job

Delete/Copy/Rename Jenkins Job

function to copy or delete or rename a Jenkins Job

Get Console output for a build

Get the output of a Jenkins Build job

Enable / disable Nodes in Jenkins

Enable or Disable a Jenkins node

Get all installed plugins info

List all the plugins that are installed in a Jenkins server

Install a plugin for Jenkins environment

Allows to install a specific Jenkins plugin

Import Jenkins Integration Downloadable Universal Template

To use this downloadable Universal Template, you first must perform the following steps:

  1. This Universal Task requires the Resolvable Credentials feature. Check that the Resolvable Credentials Permitted system property has been set to true.
  2. To import the Universal Template into your Controller, follow the instructions here.
  3. When the files have been imported successfully, refresh the Universal Templates list; the Universal Template will appear on the list.

Configure Jenkins Integration Universal Task

For the new Universal Task type, create a new task, and enter the task-specific details that were created in the Universal Template.

Field Descriptions for Jenkins Integration Universal Task

Field

Description

Jenkins Function

Select the desired function you would need to perform in Jenkins

Jenkins URL

URL of the Jenkins server, to make api calls

Jenkins Credentials

Jenkins User credentials or auth token to authenticate API calls

Jenkins Function

Select the desired function you would need to perform in Jenkins

Jenkins Job Name

Name of the Jenkins Job Name

Jenkins Job Parameters

The parameters that would need to passed along for starting a Jenkins Build

Job Token

If the Jenkins can be triggered remotely by using a job token then pass on the Job token parameter

Config XML

Provide the XML script for the creation of new job in Jenkins

Rename Job

specify the job name that needs to be renamed

From jobname

give the existing from where its needs to be copied eg: demo_job or folder/demo_job

To Job Name

copy/rename to a new Job Name eg: demo_job or folder/demo_job

Enable Node

specify the node name that needs to be enabled

Disable Node

specify the node name that needs to be disabled

Delete Job

Specify the job that needs to be deleted in Jenkins

Next Build Number(+ Last Build Number)

should be greater than the last builder otherwise jenkins will ignore the request

Enable Job

Specify the job name that needs to be enabled

Disable Job

specify the job that needs to be disabled

Jenkins Build Number

Jenkins build number for the job(int)

Jenkins Connection Timeout(in secs)

Specify the connection time out interval in seconds

Jenkins Plugin Name

Provide the Jenkin Plugin short name to be installed

Examples for Jenkins Integration Universal Tasks

Start a Jenkins Build

Create a Jenkins Job

New Jenkins Job XML Configuration

Get Plugins List

Job Build Information


Document References

This document references the following documents:

Name

Description

Universal Templates

User documentation for creating Universal Templates in the Universal Controller user interface.

Universal Tasks

User documentation for creating Universal Tasks in the Universal Controller user interface.