> For the complete documentation index, see [llms.txt](https://docs.veedna.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.veedna.com/gold-open-source-gos/gold-packages/integrating-lineaje-gos-artifactory-proxy-into-your-ci-cd-pipeline/maven-integration.md).

# Maven Integration

Maven resolves dependencies using repositories configured in `settings.xml`, `pom.xml`, or both. To route Maven traffic through the Lineaje Proxy, configure Maven to use the Proxy’s Maven endpoint and authenticate with your Lineaje username and Personal Access Token (PAT).

## Getting Started

{% stepper %}
{% step %}

### Create a Lineaje Personal Access Token (PAT)

Follow the below instructions.

{% content-ref url="/pages/C95d39E9JtH0LtbtfHfT" %}
[Authentication](/gold-open-source-gos/gold-packages/integrating-lineaje-gos-artifactory-proxy-into-your-ci-cd-pipeline/authentication.md)
{% endcontent-ref %}
{% endstep %}

{% step %}

### Store the Lineaje PAT in a secure location

For example, add your SBOM360 email and Lineaje PAT as an environmental variable:

{% code overflow="wrap" %}

```bash
export ARTIFACTORY_CREDS_USR="your-email@example.com"
export ARTIFACTORY_CREDS_PSW="by9...dPQ=="
```

{% endcode %}

For CICD pipelines, like GitHub Actions, this token can be stored as a repository-level secret or an organization-level secret. A sample GitHub Action is added below for your reference.
{% endstep %}

{% step %}

### Configure Maven `settings.xml`

Create or update the Maven settings file.

{% code overflow="wrap" %}

```xml
<settings>
  <servers>
    <server>
      <id>lineaje-fortknox-artifactory</id>
      <username>${env.ARTIFACTORY_CREDS_USR}</username>
      <password>${env.ARTIFACTORY_CREDS_PSW}</password>
    </server>
  </servers>

  <mirrors>
    <mirror>
      <id>lineaje-fortknox-artifactory</id>
      <name>Lineaje FortKnox Maven Proxy</name>
      <url>https://observe.fortknox.v2.prod.veedna.com/artifactory/gos-all-proxy-maven</url>
      <mirrorOf>*</mirrorOf>
    </mirror>
  </mirrors>

  <profiles>
    <profile>
      <id>lineaje-fortknox</id>
      <repositories>
        <repository>
          <id>lineaje-fortknox-artifactory</id>
          <name>Lineaje FortKnox Maven Proxy</name>
          <url>https://observe.fortknox.v2.prod.veedna.com/artifactory/gos-all-proxy-maven</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>

      <pluginRepositories>
        <pluginRepository>
          <id>lineaje-fortknox-artifactory</id>
          <name>Lineaje FortKnox Maven Plugin Proxy</name>
          <url>https://observe.fortknox.v2.prod.veedna.com/artifactory/gos-all-proxy-maven</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>

  <activeProfiles>
    <activeProfile>lineaje-fortknox</activeProfile>
  </activeProfiles>
</settings>
```

{% endcode %}

You can choose between observe mode or enforce mode. More details are here:&#x20;

{% content-ref url="/pages/05R19ZwuZtHVy9iEqChD" %}
[Modes of Operation](/gold-open-source-gos/gold-packages/what-is-lineaje-gold-open-source-gos-artifactory-proxy/modes-of-operation.md)
{% endcontent-ref %}

{% hint style="warning" %}
Never commit a `settings.xml`, script, or pipeline file that contains a real token or password.
{% endhint %}
{% endstep %}

{% step %}

### Run Maven install

Now Maven is configured to connect with Lineaje GOS Artifactory and download secure Java dependencies through the Lineaje Proxy.

```bash
mvn clean install
```

{% endstep %}
{% endstepper %}

## Sample Configurations

### GitHub Actions

This guide explains how to configure a GitHub Actions workflow to install Maven dependencies from Lineaje GOS Artifactory and run unit tests.

#### 1. Create GitHub Secrets

Create repository-level or organization-level secrets to store the Lineaje credentials.

1. Open your GitHub repository.
2. Go to **Settings**.
3. Open **Secrets and variables**.
4. Select **Actions**.
5. Click **New repository secret**.
6. Create the following secret:

```
ARTIFACTORY_CREDS_USR
```

Set the value to your Lineaje username or SBOM360 email.

7. Create another secret:

```
ARTIFACTORY_CREDS_PSW
```

Set the value to your Lineaje PAT.

#### 2. Add the GitHub Actions Workflow

1. Create the following workflow file in your repository:

```
.github/workflows/maven-tests-gos-artifactory.yml
```

2. Add the below content:

```yaml
name: Maven Run Tests with GOS Artifactory

on:
  pull_request:
    branches: [main]
  workflow_dispatch:
    inputs:
      mode:
        description: "FortKnox mode"
        required: false
        default: "observe"
        type: choice
        options:
          - observe
          - enforce

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set FortKnox mode
        run: |
          MODE="${{ github.event.inputs.mode || 'observe' }}"
          echo "FORTKNOX_MODE=$MODE" >> "$GITHUB_ENV"
          echo "Using FortKnox mode: $MODE"

      - name: Set up Java
        uses: actions/setup-java@v4
        with:
          distribution: 'temurin'
          java-version: '17'

      - name: Configure Maven
        env:
          ARTIFACTORY_CREDS_USR: ${{ secrets.ARTIFACTORY_CREDS_USR }}
          ARTIFACTORY_CREDS_PSW: ${{ secrets.ARTIFACTORY_CREDS_PSW }}
        run: |
          mkdir -p ~/.m2
          cat > ~/.m2/settings.xml <<EOF
          <settings>
            <servers>
              <server>
                <id>lineaje-fortknox-artifactory</id>
                <username>${ARTIFACTORY_CREDS_USR}</username>
                <password>${ARTIFACTORY_CREDS_PSW}</password>
              </server>
            </servers>

            <mirrors>
              <mirror>
                <id>lineaje-fortknox-artifactory</id>
                <name>Lineaje FortKnox Maven Proxy</name>
                <url>https://${FORTKNOX_MODE}.fortknox.v2.prod.veedna.com/artifactory/gos-all-proxy-maven</url>
                <mirrorOf>*</mirrorOf>
              </mirror>
            </mirrors>

            <profiles>
              <profile>
                <id>lineaje-fortknox</id>
                <repositories>
                  <repository>
                    <id>lineaje-fortknox-artifactory</id>
                    <name>Lineaje FortKnox Maven Proxy</name>
                    <url>https://${FORTKNOX_MODE}.fortknox.v2.prod.veedna.com/artifactory/gos-all-proxy-maven</url>
                    <releases>
                      <enabled>true</enabled>
                    </releases>
                    <snapshots>
                      <enabled>true</enabled>
                    </snapshots>
                  </repository>
                </repositories>

                <pluginRepositories>
                  <pluginRepository>
                    <id>lineaje-fortknox-artifactory</id>
                    <name>Lineaje FortKnox Maven Plugin Proxy</name>
                    <url>https://${FORTKNOX_MODE}.fortknox.v2.prod.veedna.com/artifactory/gos-all-proxy-maven</url>
                    <releases>
                      <enabled>true</enabled>
                    </releases>
                    <snapshots>
                      <enabled>true</enabled>
                    </snapshots>
                  </pluginRepository>
                </pluginRepositories>
              </profile>
            </profiles>

            <activeProfiles>
              <activeProfile>lineaje-fortknox</activeProfile>
            </activeProfiles>
          </settings>
          EOF

      - name: Install dependencies and run tests
        run: mvn clean test -X
```

### Jenkins

This guide explains how to configure Jenkins to install Maven dependencies using FortKnox Artifactory as the Maven repository.

#### 1. Configure Java and Maven in Jenkins

1. Ensure Java and Maven are available on the Jenkins agent.
2. Validate Java and Maven by running:

```bash
java -version
mvn -version
```

3. If Java or Maven is not installed, install the required versions or configure the Jenkins agent image to include Java and Maven.

#### 2. Add Artifactory Credentials in Jenkins

1. Go to **Manage Jenkins**.
2. Open **Credentials**.
3. Select the appropriate credentials scope, usually:

```
Jenkins → Global credentials
```

4. Click **Add Credentials**.
5. Select credential type:

```
Username with password
```

6. Enter your SBOM360 email as the username and the Lineaje PAT as the password.
7. Set the credential ID, for example:

```
fortknox-artifactory-creds
```

8. Save the credential.

This credential ID will be used in the Jenkinsfile:

```groovy
ARTIFACTORY_CREDS = credentials('fortknox-artifactory-creds')
```

#### 3. Add the Jenkinsfile

1. Add the following `Jenkinsfile` to the root of the repository.
2. Replace the credential ID if needed.

```groovy
pipeline {
    agent any

    parameters {
        choice(
            name: 'FORTKNOX_MODE',
            choices: ['observe', 'enforce'],
            description: 'FortKnox mode'
        )
    }

    environment {
        // Jenkins credential should be "Username with password"
        // Username should contain the SBOM360 email
        // Password should contain the Lineaje PAT
        ARTIFACTORY_CREDS = credentials('fortknox-artifactory-creds')
    }

    stages {
        stage('Build') {
            steps {
                script {
                    sh 'java -version'
                    sh 'mvn -version'

                    sh '''
                        mkdir -p ~/.m2

                        cat > ~/.m2/settings.xml <<EOF
<settings>
  <servers>
    <server>
      <id>lineaje-fortknox-artifactory</id>
      <username>${ARTIFACTORY_CREDS_USR}</username>
      <password>${ARTIFACTORY_CREDS_PSW}</password>
    </server>
  </servers>

  <mirrors>
    <mirror>
      <id>lineaje-fortknox-artifactory</id>
      <name>Lineaje FortKnox Maven Proxy</name>
      <url>https://${FORTKNOX_MODE}.fortknox.v2.prod.veedna.com/artifactory/gos-all-proxy-maven</url>
      <mirrorOf>*</mirrorOf>
    </mirror>
  </mirrors>

  <profiles>
    <profile>
      <id>lineaje-fortknox</id>
      <repositories>
        <repository>
          <id>lineaje-fortknox-artifactory</id>
          <name>Lineaje FortKnox Maven Proxy</name>
          <url>https://${FORTKNOX_MODE}.fortknox.v2.prod.veedna.com/artifactory/gos-all-proxy-maven</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>

      <pluginRepositories>
        <pluginRepository>
          <id>lineaje-fortknox-artifactory</id>
          <name>Lineaje FortKnox Maven Plugin Proxy</name>
          <url>https://${FORTKNOX_MODE}.fortknox.v2.prod.veedna.com/artifactory/gos-all-proxy-maven</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>

  <activeProfiles>
    <activeProfile>lineaje-fortknox</activeProfile>
  </activeProfiles>
</settings>
EOF
                    '''

                    sh 'mvn clean test -X'
                }
            }
        }
    }
}
```

#### 4. Validate the Jenkins Pipeline

1. Open the Jenkins job.
2. Run **Build with Parameters**.
3. Select the FortKnox mode:
   1. `observe`
   2. `enforce`
4. Start the build.
5. Confirm that the pipeline completes the following steps:
   1. Prints the Java version.
   2. Prints the Maven version.
   3. Configures Maven `settings.xml`.
   4. Installs dependencies from Lineaje GOS Artifactory.
   5. Runs unit tests.

***

## Verifying Proxy Routing

Use Maven debug mode to confirm that dependencies are resolving through the Lineaje Proxy.

```bash
mvn clean test -X
```

In the logs, confirm that the Proxy URL appears.

Expected example:

```
Downloading from lineaje-fortknox-artifactory: https://observe.fortknox.v2.prod.veedna.com/artifactory/gos-all-proxy-maven/...
```

You may also see artifact download URLs similar to:

```
https://observe.fortknox.v2.prod.veedna.com/artifactory/gos-all-proxy-maven/org/apache/commons/commons-lang3/...
```

To detect policy violations, search the build logs for the relevant Lineaje policy violation message. To learn more, see **Detecting Policy Violations in Build Logs**.

***

## Common Issues

### Authentication failure or HTTP 401 during Maven build

Check the following:

1. The username is your SBOM360 email.
2. The password is the Lineaje PAT.
3. The PAT has permission to access the GOS Artifactory Maven repository.
4. The repository URL is correct.
5. The selected mode is valid: `observe` or `enforce`.

### Server ID does not match mirror or repository ID

Maven only attaches stored credentials to a repository or mirror when the IDs match exactly.

For example, this will fail:

```xml
<servers>
  <server>
    <id>lineaje-artifactory</id>
    <username>...</username>
    <password>...</password>
  </server>
</servers>

<mirrors>
  <mirror>
    <id>lineaje-fortknox-artifactory</id>
    <url>https://enforce.fortknox.v2.prod.veedna.com/artifactory/gos-all-proxy-maven</url>
    <mirrorOf>*</mirrorOf>
  </mirror>
</mirrors>
```

In this case, the `<server><id>` is `lineaje-artifactory`, but the `<mirror><id>` is `lineaje-fortknox-artifactory`. Because the IDs do not match, Maven sends requests without credentials, which causes a 401 authentication error.

Use the same ID everywhere:

```xml
<servers>
  <server>
    <id>lineaje-fortknox-artifactory</id>
    <username>${env.ARTIFACTORY_CREDS_USR}</username>
    <password>${env.ARTIFACTORY_CREDS_PSW}</password>
  </server>
</servers>

<mirrors>
  <mirror>
    <id>lineaje-fortknox-artifactory</id>
    <url>https://enforce.fortknox.v2.prod.veedna.com/artifactory/gos-all-proxy-maven</url>
    <mirrorOf>*</mirrorOf>
  </mirror>
</mirrors>
```

The same rule applies to `<repository><id>` and `<pluginRepository><id>`.

### Dependencies do not resolve through Lineaje Proxy

Confirm that Maven is using the expected settings file.

Run:

```bash
mvn help:effective-settings
```

Or run with debug logging:

```bash
mvn clean test -X
```

The output should show the Lineaje Proxy Maven endpoint.

### Maven Central is still being used directly

Check that your mirror is configured with:

```xml
<mirrorOf>*</mirrorOf>
```

This tells Maven to route all repository traffic through the Lineaje Proxy.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.veedna.com/gold-open-source-gos/gold-packages/integrating-lineaje-gos-artifactory-proxy-into-your-ci-cd-pipeline/maven-integration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
