MvnBuild - Examples

JFrog Pipelines Documentation

Products
JFrog Pipelines
Content Type
User Guide
ft:sourceType
Paligo

The following examples show a few ways in which a MvnBuild step can be configured. For more information on MvnBuild Pipeline steps, see MvnBuild.

Full Pipeline Example

# This config file is templatized so that it can be easily customized. Values can be provided with a values.yml file.
template: true   # required for local templates
valuesFilePath: ./values.yml

resources:
  - name: mvn_repo
    type: GitRepo
    configuration:
      path: {{ .Values.repoPath }}
      gitProvider: {{ .Values.gitProvider }}

  - name: mvn_build_info
    type: BuildInfo
    configuration:
      sourceArtifactory: {{ .Values.artifactory }}

pipelines:
  - name: demo_maven
    steps:
      - name: mvn_build_step
        type: MvnBuild
        configuration:
          deployerSnapshotRepo: {{ .Values.deployerRepo }}
          deployerReleaseRepo: {{ .Values.deployerRepo }}
          inputResources:
            - name: mvn_repo
          integrations:
            - name: {{ .Values.artifactory }}

      - name: publish_build
        type: PublishBuildInfo
        configuration:
          forceXrayScan: false
          inputSteps:
            - name: mvn_build_step
          outputResources:
            - name: mvn_build_info

Basic Example using Default Values

The most basic form of MvnBuild. Uses all default values. This step navigates to the root of the repo specified in the inputResources array, and performs an mvn clean install. It does not publish a build or request an Xray scan.

MvnBuild

pipelines: 
  - name: MyMavenPipeline
    steps:
      - name: MavenWithArtifactory
        type: MvnBuild
        configuration:
          integrations:
            - name: art
          inputResources:
            - name: mvn_repo

Using Artifactory as Resolver and Deployer

This example uses Artifactory as a resolver and a deployer, so that your project's dependencies are pulled from the specified repo, and the resulting artifacts are pushed back up to Artifactory. It also publishes build info to Artifactory and requests an Xray scan.

MvnBuild

pipelines: 
  - name: MyMavenPipeline
    steps:
      - name: MavenWithAll
        type: MvnBuild
        configuration:
          integrations:
            - name: art
          inputResources:
            - name: mvn_repo
          outputResources:
            - name: mvn_build_info
          mvnCommand: clean install test
          sourceLocation: mvnproject
          resolverSnapshotRepo: snapshots-remote-maven
          resolverReleaseRepo: releases-remote-maven
          deployerSnapshotRepo: snapshots-local-maven
          deployerReleaseRepo: releases-local-maven
          forceXrayScan: true
          failOnScan: true
          autoPublishBuildInfo: true

Using a Config File

This example uses a committed config file to accomplish the same thing that example 2 does.

MvnBuild

pipelines: 
  - name: MyMavenPipeline
    steps:
      - name: MvnWithConfig
        type: MvnBuild
        configuration:
          integrations:
            - name: art
          inputResources:
            - name: mvn_repo
          outputResources:
            - name: mvn_build_info
          mvnCommand: clean install test
          sourceLocation: mvnproject
          configFileLocation: "."
          configFileName: mvn-art-config
          forceXrayScan: true
          failOnScan: true
          autoPublishBuildInfo: true