Kicking off a Jenkins pipeline in a Workflow
After integrating Cortex with Jenkins, you can use a Cortex Workflow to kick off your pipeline directly through Cortex, rather than switching to Jenkins to launch a build.
For full instructions on creating and configuring Workflows, see the Workflows documentation.
How to kick off a Jenkins pipeline in a Workflow
Prerequisites
Before getting started:
Generate an API token in Jenkins
In Jenkins, navigate to user settings > Configure > API Token.
Generate a base64-encoded authentication header. After generating the header, copy it and store it in a secure location, as you will need it in the next step.
You can generate the header with a command line tool or a basic authentication tool such as Mixed Analytics.
If using Mixed Analytics, enter the token into their encoding tool using the format
username:token
, replacingusername
with the username used to create the Jenkins token and replacingtoken
with the value of your Jenkins API token.When using an authentication tool such as Mixed Analytics to generate the authentication header, do not include the equal signs that are appended to the header. For example, if the tool returns
xxxxxxxxxx6789==
as the encoded header, you only need to save the valuexxxxxxxxxx6789
for the next step.
Step 1: Create a secret in Cortex
Navigate to the Secrets page and click Add secret.
In the modal, configure the secret:
Name: Enter a descriptive name, such as
Jenkins
.Identifier: Enter a unique identifier for the secret.
Secret value: Enter the base64-encoded authentication header you generated in the previous step.
Click Add secret.
Step 2: Create a workflow
In the main nav of Cortex, click Workflows.
Follow the steps of the Workflows documentation to start creating a Workflow from scratch and configure its settings.
Give the Workflow a descriptive name such as "Kick off Jenkins pipeline."
In the Response template field you can pass a blank response body or use Mustache templating to create messages depending on what the user enters in each field.
Step 3: Add blocks to the workflow
You can add a block to run a build with parameters, or you can add a block to run a build without parameters. See the Jenkins documentation for more information on submitting parameterized jobs.
Click + to view the block library.
Click Jenkins.
To choose a a build without parameters, select Run a build.
To choose a build with parameters, select Run a build with parameters.
Click Insert at the bottom of the library.
In the side panel, configure the block.
Block name: Enter a name for the block (e.g.,
Run a build in Jenkins
).Slug: Enter a unique slug for the block.
Jenkins URL: Enter the base URL of your Jenkins server (e.g.,
https://jenkins.example.com
).Job name: Enter the name of the Jenkins job to run.
Authentication token: Enter the secret you created in Cortex in the previous steps.
Parameters: For a build with parameters, you also need to configure valid JSON for the run job parameters.
At the bottom of the side panel, click Save.
Last updated
Was this helpful?