> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/harness-ai/use-harness-platform/connectors/artifact-repositories/add-a-jenkins-connector.md).

# Add a Jenkins connector

Documentation for the provisioning of Jenkins Registry connectors.

You can perform Continuous Integration (CI) in Harness using the CI module and [CI pipelines](https://github.com/harness/harness-developer-hub/tree/main/docs/delivery/continuous-integration/new-to-harness-ci/key-concepts.md). If you use Harness Continuous Delivery (CD) but not Harness CI, you can still perform CI using the **Jenkins** step in a CD stage.

You connect Harness to Jenkins using a Harness Jenkins connector. This connector allows you to run Jenkins jobs in [Jenkins steps](https://github.com/harness/harness-developer-hub/tree/main/docs/delivery/continuous-delivery/use-continuous-delivery/cd-building-blocks/cd-steps/builds/run-jenkins-jobs-in-cd-pipelines.md).

This topic shows you how to add a Jenkins connector to Harness.

***

## What you will learn from this topic

* How to check the [Jenkins permissions and authentication requirements](#before-you-begin) before you connect Harness to Jenkins.
* How to [add a Jenkins connector](#add-a-jenkins-connector) to a Harness project so you can run Jenkins jobs from a pipeline.

***

## Before you begin

* **Jenkins permissions**: The user account for this connection needs **Read** access at the **Overall** level and **Build** access at the **Job** level on the Jenkins server. For details on configuring these permissions, see [Jenkins Matrix-based security](https://wiki.jenkins.io/display/JENKINS/Matrix-based+security) from Jenkins.
* **Jenkins API token** (for token-based authentication): Go to `http://JENKINS_IP_ADDRESS/jobs/me/configure` on your Jenkins server to check or generate your API access token. The Harness Jenkins connector sends this token as part of the HTTP header.
* **Okta or two-factor authentication (2FA)**: If you use Okta or 2FA for connections to Jenkins, select **API Token** for **Authentication** when you configure the connector.

{% hint style="info" %}
**SAML authentication**

Harness supports SAML authentication for Jenkins connections.
{% endhint %}

***

## Add a Jenkins connector

You can add a Jenkins connector at the project, org, or account scope. This procedure covers the project scope, and the process is the same for org and account. You can also add a Jenkins connector directly when you configure the Jenkins step in a pipeline.

Follow the interactive guide below for a step-by-step walkthrough:

{% embed url="<https://app.arcade.software/share/le2HDcHZKjZI67MEIlcb>" %}
Add a Jenkins connector in Harness
{% endembed %}

Perform the following steps to add a Jenkins connector:

1. Open your Harness project.
2. In **Project Settings**, select **Connectors**.
3. Click **New Connector**, then click **Jenkins**.

### Overview

4. In **Name**, enter a name for the connector. Optionally, add a description and tags. Click **Continue**.

### Details

5. Enter the URL of the Jenkins master or controller:

   * If you use the Jenkins SaaS (cloud) edition, find the URL in your browser's address bar.
   * If you use the standalone edition of Jenkins, navigate to **System** in **Manage Jenkins**, and find the URL under **Jenkins Location**.

   ![Jenkins Location field in Manage Jenkins showing the Jenkins server URL](https://173309742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3F2TpHXhur2QtQnORSM9%2Fuploads%2Fgit-blob-c2ddc1c0a49342ce6bd38c722fda45666c8bf75f%2Fconnect-to-jenkins-10.png?alt=media)
6. In **Authentication**, select one of the following options to authenticate with the Jenkins server:

   * **Username** and **Password/API Token**: Enter the username for the account. Select or create a Harness Encrypted Text secret using your Jenkins API token or password. Go to [Before you begin](#before-you-begin) to generate or check this token.
   * **Bearer Token (HTTP Header)**: Select or create a Harness Encrypted Text secret using the OpenShift OAuth access token. This option applies only to Jenkins servers hosted or embedded in an OpenShift cluster that use this authentication method. Go to [Authentication](https://docs.openshift.com/container-platform/3.7/architecture/additional_concepts/authentication.html) from OpenShift to configure OAuth authentication for a Jenkins server hosted on OpenShift.

   Click **Continue**.

### Delegates Setup

7. In **Delegates Setup**, use any delegate or enter [tags](/harness-ai/use-harness-platform/delegates/delegate/manage-delegates/select-delegates-with-selectors.md) for the specific delegates that you want to allow to connect to this connector. Click **Save and Continue**.

### Connection Test

8. Click **Finish** after the connection test succeeds. The connector is listed in **Connectors**.

### Sample YAML

The following example shows a YAML for the Jenkins connector created in this guide.

<details>

<summary>YAML - Jenkins connector</summary>

```yaml
connector:
  name: your-jenkins-connector        # Display name for the connector in Harness
  identifier: yourjenkinsconnector    # Unique ID used in pipelines and API references
  description: ""                     # Optional: brief description of this connector
  accountIdentifier: youraccountidentifier  # Your Harness account ID
  orgIdentifier: default              # Org where this connector is created; use "default" for the default org
  projectIdentifier: yourprojecttidentifier # Project where this connector is created
  type: Jenkins
  spec:
    jenkinsUrl: yourjenkinsurl        # Base URL of your Jenkins master or controller
    auth:
      type: UsernamePassword          # Authentication method: UsernamePassword or BearerToken
      spec:
        username: username            # Jenkins username with Read (Overall) and Build (Job) permissions
        passwordRef: password         # Reference to a Harness Encrypted Text secret containing the API token or password
    delegateSelectors:
      - your-helm-delegate            # Tag of the delegate that runs operations for this connector
    ignoreTestConnection: false       # Set to true to skip the connection test and save the connector anyway
```

</details>

***

## Next steps

* [Run Jenkins jobs in CD pipelines](https://github.com/harness/harness-developer-hub/tree/main/docs/delivery/continuous-delivery/use-continuous-delivery/cd-building-blocks/cd-steps/builds/run-jenkins-jobs-in-cd-pipelines.md): Configure a Jenkins step to run Jenkins jobs in your pipeline.
