🐸
JFrog Applications
  • JFrog Applications
  • JFrog Applications
    • JFrog CLI
      • Download and Install
      • Authentication
      • Shell Auto Completion
      • Usage
      • Configurations
        • JFrog Platform Configuration
        • Proxy Support
      • CLI AI Assistant
        • AI Assistant Addendum
      • Binaries Management with JFrog Artifactory
        • Environment Variables
        • Authentication
        • Verifying Artifactory's Accessibility
        • Generic Files
        • Using File Specs
        • Using Placeholders
        • Build Integration
        • Package Managers Integration
        • Storing Symlinks in Artifactory
        • cURL Integration
        • Managing Configuration Entities
        • Release Lifecycle Management
        • Transferring Files Between Artifactory Servers
        • Cleaning Up Unreferenced Files from a Git LFS Repository
        • Evidence Service
      • CLI for JFrog Security
        • Download Updates for Xray's Database
        • How Tos
          • Scan your code dependencies
          • Scan your Binaries
          • Enrich your SBOM JSONs & XMLs
          • JFrog Curation
          • Scan Published Builds
          • Count Contributing Developers
      • CLI for JFrog Distribution
      • CLI for JFrog Cloud Transfer
      • CLI Command Summaries
      • JFrog CLI Plugins
        • JFrog CLI Plugins Developer Guide
    • IDE
      • Visual Studio Code
        • VS Code Prerequsites Per Language
        • Supported Technologies
        • Install the JFrog VS Code Extension
          • Connect VS Code to the JFrog Platform
        • Manage VS Code IDE
        • Quick Start
        • How Tos
          • Analyze your Results
            • Resolve Issues
            • Ignore Findings
      • JetBrains IDEs
        • Supported Technologies
        • Install the JFrog IDEA Plugin
        • Connect the JFrog Plugin to the JFrog Platform
        • Using the JFrog Plugin in the JetBrains IDEs
        • Plugin Configuration
        • Apply Xray Policies and Watches
        • Troubleshooting
      • Eclipse
        • Supported Technologies
        • Install and Setup of the JFrog Eclipse IDE Plugin
        • Scan Gradle Projects with the JFrog Eclipse IDE Plugin
        • Use the JFrog Eclipse IDE Plugin
      • Visual Studio
        • Supported Technologies
        • Install and Setup the JFrog Visual Studio Extension
        • Use the JFrog Visual Studio Extension
    • JFrog Frogbot
      • Supported Technologies
      • Setup
        • Frogbot Configuration
        • Setup Frogbot Using GitHub Actions
          • OIDC Authentication
          • Scan Git Repository Full Template
          • Scan Pull Request Full Template
        • Setup Frogbot Using Jenkins
        • Setup Frogbot Using JFrog Pipelines
        • Setup Frogbot Using GitLab CI
          • GitLab Full Template
        • Setup Frogbot Using Azure Pipelines
      • Scan Execution
        • Scan Git Repositories
          • View Security Alerts on GitHub
        • Scan Pull Requests
          • Scan GitHub Pull Request
          • Scan GitLab Pull Request
          • Scan Azure Repos Pull Request
          • Scan Bitbucket Server Pull Request
          • Pull Request Scan Results
      • Frogbot Badge
  • CI & SDKs
    • CI Integrations
      • Maven Artifactory Plugin
      • GitLab Templates for JFrog
      • Jenkins JFrog Plugin
      • Bamboo JFrog Plugin
      • GitHub Actions
      • Artifactory Gradle Plugin
    • SDKs
      • Artifactory Java Client
      • JFrog Go Client
  • JFrog Security Features
    • SCA
    • Contextual Analysis
    • Infrastructure as Code (IaC)
    • Secrets
    • SAST
      • Integrations
      • Ignore Findings
Powered by GitBook

© 2024 JFrog Ltd All Rights Reserved

On this page
  • Overview
  • Using Maven Artifactory plugin
  • 💻 Contributions
Edit on GitHub
Export as PDF
  1. CI & SDKs
  2. CI Integrations

Maven Artifactory Plugin

PreviousCI IntegrationsNextGitLab Templates for JFrog

Last updated 1 year ago

Overview

The Maven Artifactory integrates in your build to allow you to do the following:

  1. Resolve artifacts from Artifactory.

  2. Capture the full build information and publish it to Artifactory.

  3. Deploy all build Artifacts to Artifactory.

Using Maven Artifactory plugin

The Maven Artifactory Plugin coordinates are org.jfrog.buildinfo:artifactory-maven-plugin:x.x.x. It can be viewed on .

Basic Configuration

A typical build plugin configuration would be as follows:


<build>
  <plugins>
    <plugin>
      <groupId>org.jfrog.buildinfo</groupId>
      <artifactId>artifactory-maven-plugin</artifactId>
      <version>3.6.1</version>
      <executions>
        <execution>
          <id>build-info</id>
          <goals>
            <goal>publish</goal>
          </goals>
          <configuration>
            <deployProperties>
              <gradle>awesome</gradle>
              <review.team>qa</review.team>
            </deployProperties>
            <publisher>
              <contextUrl>https://acme.jfrog.io</contextUrl>
              <username>deployer</username>
              <password>dontellanyone</password>
              <repoKey>libs-release-local</repoKey>
              <snapshotRepoKey>libs-snapshot-local</snapshotRepoKey>
            </publisher>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

The plugin's invocation phase is validate by default, and we recommend you don't change it so the plugin is called as early as possible in the lifecycle of your Maven build.

Full Configuration

The example above configures the Artifactory publisher, to deploy build artifacts either to the releases or the snapshots repository of Artifactory when mvn deploy is executed.

However, the Maven Artifactory Plugin provides many other configurations:


<configuration>
  <artifactory>
    <includeEnvVars>true</includeEnvVars>
    <envVarsExcludePatterns>*password*,*secret*,*key*,*token*,*passphrase*</envVarsExcludePatterns>
    <envVarsIncludePatterns>*os*</envVarsIncludePatterns>
    <timeoutSec>60</timeoutSec>
  </artifactory>
  <buildInfo>
    <agentName>..</agentName>
    <agentVersion>..</agentVersion>
    <buildName>plugin-demo</buildName>
    <buildNumber>${buildnumber}</buildNumber>
    <buildUrl>https://build-url.org</buildUrl>
    <!-- If you'd like to associate the published build-info with a JFrog Project, add the project key here -->
    <project>..</project>

    <buildNumbersNotToDelete></buildNumbersNotToDelete>
    <buildRetentionMaxDays>N</buildRetentionMaxDays>
    <buildRetentionCount>N</buildRetentionCount>
    <buildUrl>..</buildUrl>
    <principal>..</principal>
  </buildInfo>
  <deployProperties>
    <maven>awesome</maven>
  </deployProperties>
  <publisher>
    <contextUrl>http://localhost:8081/artifactory</contextUrl>
    <username>${username}</username>
    <password>${password}</password>
    <excludePatterns>*-tests.jar</excludePatterns>
    <repoKey>libs-release-local</repoKey>
    <snapshotRepoKey>libs-snapshot-local</snapshotRepoKey>

    <publishArtifacts>true/false</publishArtifacts>
    <publishBuildInfo>true/false</publishBuildInfo>
    <excludePatterns>..</excludePatterns>
    <includePatterns>..</includePatterns>
    <filterExcludedArtifactsFromBuild>true/false</filterExcludedArtifactsFromBuild>
    <!-- If true build information published to Artifactory will include implicit project as well as build-time dependencies -->
    <recordAllDependencies>true/false</recordAllDependencies>
    <!-- Minimum file size in KB for which the plugin performs checksum deploy optimization. Default: 10. Set to 0 to disable uploading files with checksum that already exists in Artifactory. -->
    <minChecksumDeploySizeKb>10</minChecksumDeploySizeKb>
  </publisher>
  <proxy>
    <host>proxy.jfrog.io</host>
    <port>8888</port>
    <username>proxyUser</username>
    <password>proxyPassword</password>
  </proxy>
</configuration>

Configuration Details

Configuration
Description

<deployProperties>

Specifies properties you can attach to published artifacts. For example: prop-value.

<artifactory>

Specifies whether environment variables are published as part of BuildInfo metadata and which include or exclude patterns are applied when variables are collected

<publisher>

Defines an Artifactory repository where build artifacts should be published using a combination of a <contextUrl> and <repoKey>/<snapshotRepoKey>. Build artifacts are deployed if the deploy goal is executed and only after all modules are built.

<buildInfo>

Updates BuildInfo metadata published together with build artifacts. You can configure whether or not BuildInfo metadata is published using the configuration.

<proxy>

Specifies HTTP/S proxy.

Reading Environment Variables and System Properties

Every build server provides its own set of environment variables. You can utilize these variables when configuring the plugin as shown in the following example:


<configuration>
  <publisher>
    <contextUrl>{{ARTIFACTORY_CONTEXT_URL|"https://acme.jfrog.io"}}</contextUrl>
  </publisher>
  <buildInfo>
    <buildNumber>{{DRONE_BUILD_NUMBER|TRAVIS_BUILD_NUMBER|CI_BUILD_NUMBER|BUILD_NUMBER|"333"}}</buildNumber>
    <buildUrl>{{DRONE_BUILD_URL|CI_BUILD_URL|BUILD_URL}}</buildUrl>
  </buildInfo>
</configuration>

Any plugin configuration value can contain several {{ .. }} expressions. Each expression can contain a single or multiple environment variables or system properties to be used. The expression syntax allows you to provide enough variables to accommodate any build server requirements according to the following rules:

  • Each expression can contain several variables, separated by a ' | ' character to be used with a configuration value.

  • The last value in a list is the default that will be used if none of the previous variables is available as an environment variable or a system property.

For example, for the expression {{V1|V2|"defaultValue"}} the plugin will attempt to locate environment variable V1 , then system property V1, then environment variable or system property V2 , and if none of these is available, "defaultValue" will be used.

If the last value is not a string (as denoted by the quotation marks) and the variable cannot be resolved, null will be used (For example, for expression {{V1|V2}} where neither V1 nor V2 can be resolved).

Example

💻 Contributions

We welcome pull requests from the community. To help us improve this project, please read our Contribution guide.

The following project provides a working example of using the plugin: .

releases.jfrog.io
Maven Artifactory Plugin Example