> 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/artifact-registry/use-artifact-registry/platform-integrations/ci-ar-integrations.md). Agents can also search and read this documentation through its [MCP server](https://developer.harness.io/~gitbook/mcp).

# Artifact Registry and Continuous Integrations

Deep dive into the native integrations between the Artifact Registry and the Continuous Integration module.

Learn how to use Artifact Registry with the Continuous Integration (CI) module and with external CI tools such as Jenkins and GitHub Actions.

### Use Artifact Registry with Jenkins <a href="#use-artifact-registry-with-jenkins" id="use-artifact-registry-with-jenkins"></a>

If your builds run in Jenkins, use the [Harness](https://plugins.jenkins.io/harness/) plugin to install and authenticate the Harness CLI (`hc`), then run any `hc` command in your pipeline, such as `hc artifact push` to push artifacts.

For a pipeline example, go to [Use Artifact Registry with Jenkins](https://developer.harness.io/artifact-registry/use-artifact-registry/artifact-registry-cli/manage-artifacts-registries.md#use-artifact-registry-with-jenkins). To install and configure the plugin, go to [Harness](https://plugins.jenkins.io/harness/).

### Use Artifact Registry with GitHub Actions <a href="#use-artifact-registry-with-github-actions" id="use-artifact-registry-with-github-actions"></a>

If your builds run in GitHub Actions, use the [Setup Harness CLI](https://github.com/marketplace/actions/setup-harness-cli) action to install and authenticate the Harness CLI (`hc`), then push artifacts with `hc artifact push`.

For a workflow example, go to [Use Artifact Registry with GitHub Actions](https://developer.harness.io/artifact-registry/use-artifact-registry/artifact-registry-cli/manage-artifacts-registries.md#use-artifact-registry-with-github-actions). To configure the action, go to [Setup Harness CLI](https://github.com/marketplace/actions/setup-harness-cli).

### Build and push to Docker with Artifact Registry <a href="#build-and-push-to-docker-with-artifact-registry" id="build-and-push-to-docker-with-artifact-registry"></a>

Harness CI offers a [Build and push to Docker](https://developer.harness.io/continuous-integration/use-harness-ci/use-harness-ci/build-and-upload-artifacts/build-and-push/build-and-push-to-docker-registry) step that allows you to build and push a docker image to any registry. Usually, this requires a connector to the registry you want, but with AR you can connect to a registry directly, within the platform, without any complicated setup.

{% tabs %}
{% tab title="Interactive guide" %}
{% embed url="<https://app.tango.us/app/embed/7892f010-0f5b-4acd-8ad3-9de5426ba386>" %}
Build and Push Docker Images with Harness Artifact Registry
{% endembed %}
{% endtab %}

{% tab title="Step-by-step" %}
To do so, perform the following steps:

1. Navigate to your pipeline, and enter your `Build` stage.
2. Create a new `Build and Push an image to Docker Registry` step.
3. `Harness Artifact Registry` is the default registry type. Ensure that it is selected, and move to the next step.
4. Select your registry under `Registry`. Clicking the field will show a list of available registries.
5. Once your registry is selected, a list of images will populate under `Image Name`. Choose one, or type the name of a new image that you are building the first time.
6. Enter any image tags you wish under `Tags`.
7. Click `Apply Changes` at the top right, and you are done! No connectors needed.
   {% endtab %}
   {% endtabs %}

### Upload artifacts to Harness Artifact Registry <a href="#upload-artifacts-to-harness-artifact-registry" id="upload-artifacts-to-harness-artifact-registry"></a>

Harness CI provides a native **Upload Artifacts to Harness Artifact Registry** step that simplifies the process of publishing artifacts directly to your Harness Artifact Registry. This dedicated step supports multiple package types and eliminates the need for complex scripting or external connectors.

<figure><img src="https://4191040053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGmEmgYs6IUcqNiV0OEgB%2Fuploads%2Fgit-blob-b38004895334faf94a12a9f20415b13b737e44a1%2Fci-upload-artifact.png?alt=media" alt="CI Upload Artifact"><figcaption><p>CI Upload Artifact</p></figcaption></figure>

The Upload Artifacts step allows you to configure artifact uploads through a simple interface. You can specify the package type, target registry, and source path for your artifacts. The source path points to a file from a previous step in your pipeline, such as a Run step that builds, creates, or downloads a package.

For a Maven package, **Source Path** is one `.jar` or `.war` file. Open **Optional Configuration** and set **POM\_FILE\_PATH** to the POM for that file. The upload reads `groupId`, `artifactId`, and `version` from that POM, and it fails when the setting is empty.

{% hint style="info" %}
**Source path configuration**

Enter the **Source Path** of the file to upload. The path must exist when the upload step runs. You can use an expression to reference an output from an earlier step.

* **Maven:** The full path of one `.jar` or `.war` file, for example `/harness/target/my-app-1.0.0.jar`. In a multi-module build, include the module directory, for example `/harness/greeter-app/target/greeter-app-1.0.0.jar`.
* **npm:** A package tarball, for example `/harness/example.tar.gz`.
* **Python:** A wheel or a directory of wheels, for example `/harness/build/`.

**Package-specific requirements:**

* **Maven:** Under **Optional Configuration**, set **POM\_FILE\_PATH** to a `.xml` or `.pom` file that contains `groupId`, `artifactId`, and `version`. Those coordinates must match the file in **Source Path**. Publish a release version. A version that ends in `-SNAPSHOT` is rejected.
* **Generic packages:** Set an explicit package name and version.
* **Go packages:** Set an explicit version.

When the build uses the flatten Maven plugin, set **POM\_FILE\_PATH** to the generated `.flattened-pom.xml`. The plugin writes that file in the same directory as the module `pom.xml`, for example `/harness/greeter-app/.flattened-pom.xml`. A fat JAR can contain `META-INF/maven` metadata for its dependencies. The upload selects the artifact whose coordinates match **POM\_FILE\_PATH**.
{% endhint %}

<details>

<summary>The upload step cannot find the Maven POM</summary>

The Maven upload reads coordinates from the file in **POM\_FILE\_PATH**. Enter the full path of the POM the build wrote.

When the build uses the flatten Maven plugin, list the module directory and use the path of `.flattened-pom.xml`. That file sits beside the module `pom.xml`. Use that path in **POM\_FILE\_PATH**.

The `groupId`, `artifactId`, and `version` in the POM must match the `.jar` or `.war` in **Source Path**.

</details>

{% hint style="info" %}
The Upload Artifacts step uses Harness CLI internally to upload artifacts to Harness Artifact Registry, ensuring consistent behavior and authentication across all package types.
{% endhint %}

<details>

<summary>Example YAML</summary>

```yaml
pipeline:
  name: Upload Conda Package to Artifact Registry
  identifier: conda_upload_pipeline
  projectIdentifier: default_project
  orgIdentifier: default
  stages:
    - stage:
        name: Build and Upload
        identifier: build_upload_stage
        type: CI
        spec:
          cloneCodebase: true
          execution:
            steps:
              - step:
                  type: Run
                  name: Download Conda Package
                  identifier: download_conda_package
                  spec:
                    shell: Sh
                    command: |-
                      #!/bin/sh
                      set -e

                      # Configuration
                      PACKAGE_NAME="docutils-stubs"
                      CHANNEL="conda-forge"

                      echo "Fetching metadata for ${PACKAGE_NAME} from ${CHANNEL}"

                      # Fetch package metadata
                      JSON_DATA=$(curl -s "https://api.anaconda.org/package/${CHANNEL}/${PACKAGE_NAME}/files")

                      # Extract the first download URL
                      LATEST_URL=$(echo "${JSON_DATA}" \
                        | grep -o '"download_url": "[^"]*"' \
                        | head -n 1 \
                        | cut -d'"' -f4)

                      # Validate URL
                      if [ -z "${LATEST_URL}" ]; then
                        echo "Failed to retrieve download URL"
                        exit 1
                      fi

                      # Normalise protocol if required
                      case "${LATEST_URL}" in
                        //* ) LATEST_URL="https:${LATEST_URL}" ;;
                      esac

                      FILE_NAME=$(basename "${LATEST_URL}")

                      echo "Downloading ${FILE_NAME}"

                      # Download artifact
                      curl -L "${LATEST_URL}" -o "${FILE_NAME}"

                      # Resolve absolute path
                      FILE_PATH="$(pwd)/${FILE_NAME}"

                      echo "Resolved artifact path: ${FILE_PATH}"

                      # Write output using Harness supported contract
                      echo "FILE_PATH=${FILE_PATH}" >> "${DRONE_OUTPUT}"
              
              - step:
                  type: HarUpload
                  name: Upload to Artifact Registry
                  identifier: upload_to_registry
                  spec:
                    registryRef: my_conda_registry
                    packageType: CONDA
                    sourcePath: <+steps.download_conda_package.output.outputVariables.FILE_PATH>
          platform:
            os: Linux
            arch: Arm64
          runtime:
            type: Cloud
            spec: {}
```

</details>

**Key Points:**

1. **Step 1 (Run):** Downloads a Conda package from conda-forge and outputs the file path using `DRONE_OUTPUT`
2. **Step 2 (HarUpload):** References the output variable from Step 1 using `<+steps.download_conda_package.output.outputVariables.FILE_PATH>` and uploads to the specified registry
3. **Package Type:** Set to `CONDA` to ensure proper indexing in Artifact Registry
4. **Source Path:** Dynamically references the downloaded artifact location from the previous step

### Add a run or plugin step to your CI pipeline <a href="#add-a-run-or-plugin-step-to-your-ci-pipeline" id="add-a-run-or-plugin-step-to-your-ci-pipeline"></a>

Seamlessly reference artifacts stored in Harness Artifact Registry within your CI Run and Plugin steps. This functionality eliminates the need for an external connector, providing a streamlined and user-friendly experience, while enabling efficient and simplified workflows.

{% tabs %}
{% tab title="Interactive guide" %}
{% embed url="<https://app.tango.us/app/embed/0e1d0ea7-149b-4ad2-be28-6e63f4114a5f>" %}
Add a run step against a registered artifact in your CI pipeline.
{% endembed %}
{% endtab %}

{% tab title="Step-by-step" %}
To do so, perform the following steps:

1. Navigate to your pipeline, and enter your `Build` stage.
2. Create a new `Run` step.
3. `Harness Artifact Registry` is the default registry type. Ensure that it is selected, and move to the next step.
4. Select your registry under `Registry`. Clicking the field will show a list of available registries.
5. Enter your artifact's `imageName:version`.
6. Add your run command, for example `echo "Run step completed"`.
7. Click `Apply Changes`.

To verify the Run or Plugin step executes as expected, run the pipeline.
{% endtab %}
{% endtabs %}

<details>

<summary>Does the Upload Artifacts to Harness Artifact Registry step require a feature flag?</summary>

No. The Upload Artifacts to Harness Artifact Registry step is available in CI pipelines, and you do not need to enable a feature flag to use it. The identity that runs the pipeline needs write access to the target registry.

</details>

## Next steps

* [Use Artifact Registry with Jenkins](https://developer.harness.io/artifact-registry/use-artifact-registry/artifact-registry-cli/manage-artifacts-registries.md#use-artifact-registry-with-jenkins)
* [Harness Jenkins plugin](https://plugins.jenkins.io/harness/) Jenkins plugin
* [Use Artifact Registry with GitHub Actions](https://developer.harness.io/artifact-registry/use-artifact-registry/artifact-registry-cli/manage-artifacts-registries.md#use-artifact-registry-with-github-actions)
* [Setup Harness CLI](https://github.com/marketplace/actions/setup-harness-cli)
* [CD integration with Artifact Registry](https://developer.harness.io/artifact-registry/use-artifact-registry/platform-integrations/cd-ar-integrations.md)
* [Security integrations](https://developer.harness.io/artifact-registry/use-artifact-registry/platform-integrations/security-integrations.md)
* [Build and push to Docker Registry](https://developer.harness.io/continuous-integration/use-harness-ci/use-harness-ci/build-and-upload-artifacts/build-and-push/build-and-push-to-docker-registry)

{% @harness-feedback/feedback %}
