How do I integrate Automation Pipelines with Jenkins
Automation Pipelines
with JenkinsAutomation Pipelines
provides a Jenkins plug-in, which triggers Jenkins jobs that build and test your source
code. The Jenkins plug-in runs test cases, and can use custom scripts. - Set up a Jenkins server that runs version 1.561 or later.
- Verify that you are a member of a project inAutomation Pipelines. If you are not a member, ask aAutomation Pipelinesadministrator to add you as a member of a project. See How do I add a project in Automation Pipelines.
- Verify that a job exists on the Jenkins server so that your pipeline task can run it.
To run a
Jenkins job in your pipeline, you use a Jenkins server, and add the Jenkins endpoint
in
Automation Pipelines
. Then, you
create a pipeline and add a Jenkins task to it. When you use the Jenkins task and a Jenkins
endpoint in
Automation Pipelines
, you can
create a pipeline that supports multi-branch jobs in Jenkins. The multi-branch job
includes individual jobs in each branch of a Git repository. When you create
pipelines in Automation Pipelines
that
support multi-branch jobs:- The Jenkins task can run Jenkins jobs that reside in multiple folders on the Jenkins server.
- You can override the folder path in the Jenkins task configuration so that it uses a different folder path, which overrides the default path defined in the Jenkins endpoint inAutomation Pipelines.
- Multi-branch pipelines inAutomation Pipelinesdetect Jenkins job files of type.groovyin a Git repository or a GitHub repository, and start creating jobs for each branch that it scans in the repository.
- You can override the default path defined in the Jenkins endpoint with a path provided in the Jenkins task configuration, and run a job and pipeline that is associated with any branch inside a main Jenkins job.
- Add and validate a Jenkins endpoint.
- Click.
- Select a project, and for the type of endpoint selectJenkins. Then, enter a name and a description.
- If this endpoint is a business-critical component in your infrastructure, enableMark as restricted.
- Enter the URL for the Jenkins server.
- Enter the user name and password to log in to the Jenkins server. Then, enter the remaining information.Remaining information for the Jenkins endpointEndpoint entryDescriptionFolder PathPath for the folder that groups your jobs. Jenkins can run all jobs in the folder. You can create sub folders. For example:
- folder_1can includejob_1
- folder_1can includefolder_2, which can includejob_2
When you create an endpoint forfolder_1, the folder path isjob/folder_1, and the endpoint only listsjob_1.To obtain the list of jobs in the child folder namedfolder_2, you must create another endpoint that uses the folder path as/job/folder_1/job/folder_2/.Folder Path for multi-branch Jenkins jobsTo support multi-branch Jenkins jobs, in the Jenkins task, you enter the full path that includes the Jenkins server URL and the complete job path. When you include a folder path in the Jenkins task, that path overrides the path that appears in the Jenkins endpoint. With the custom folder path in the Jenkins task,Automation Pipelinesonly displays jobs that are present in that folder.- For example:https://server.yourcompany.com/job/project
- If the pipeline must also trigger the main Jenkins job, use:https://server.yourcompany.com/job/project/job/main
URLHost URL of the Jenkins server. Enter the URL in the form ofprotocol://host:port. For example:http://192.10.121.13:8080Polling IntervalInterval duration forAutomation Pipelinesto poll the Jenkins server for updates.Request Retry CountNumber of times to retry the scheduled build request for the Jenkins server.Retry Wait TimeNumber of seconds to wait before retrying the build request for the Jenkins server. - ClickValidate, and verify that the endpoint connects toAutomation Pipelines. If it does not connect, correct any errors, then clickSave.
- To build your code, create a pipeline, and add a task that uses your Jenkins endpoint.
- Click.
- Click the default stage.
- In the Task area, enter a name for the task.
- Select the task type asJenkins.
- Select the Jenkins endpoint that you created.
- From the drop-down menu, select a job from the Jenkins server that your pipeline will run.
- Enter the parameters for the job.
- Enter the authentication token for the Jenkins job.
- Enable and run your pipeline, and view the pipeline execution.
- Look at the execution details and status on the pipeline dashboard.You can identify any failures, and why it failed. You can also see trends about the pipeline execution durations, completions, and failures.
Congratulations! You integrated
Automation Pipelines
with Jenkins by adding an endpoint, creating a pipeline,
and configuring a Jenkins task that builds your code. Example YAML for a Jenkins build
task
For the type of Jenkins build task used in
this example, the YAML resembles the following code, with notifications turned on:
test: type: Jenkins endpoints: jenkinsServer: jenkins input: job: Add two numbers parameters: Num1: '23' Num2: '23'
Review the other sections to learn more. See
Connecting Automation Pipelines to endpoints.