Cloud customer?
Start for Free>
Upgrade in MyJFrog >
What's New in Cloud >





Overview

TheMvnBuildnative step performs a Maven project build在Git存储库文件。或者,也可lso publish build information to Artifactory.

If your maven project is already using theMaven Artifactory plugin, seeSetting Up Maven Builds for Pipelinesfor information about configuring your Maven settings for use in JFrog Pipelines.

Using this step automatically selects Java as the language and bootstraps the runtime environment in the node appropriately.

YAML Schema

MvnBuild
pipelines: - name:  steps: - name:  type: MvnBuild configuration: #inherits all the tags from bash; //www.si-fil.com/confluence/display/JFROG/Bash mvnCommand:  # optional sourceLocation:  # optional resolverSnapshotRepo:  # optional resolverReleaseRepo:  # optional deployerSnapshotRepo:  # optional deployerReleaseRepo:  # optional forceXrayScan:  # optional failOnScan:  # default true autoPublishBuildInfo:  # optional configFileLocation:  # optional configFileName:  # optional integrations: - name:  # required inputResources: - name:  # required - name:  # optional outputResources: - name:  # if autoPublishBuildInfo is true execution: onStart: - echo "Preparing for work..." onSuccess: - echo "Job well done!" onFailure: - echo "uh oh, something went wrong" onComplete: #always - echo "Cleaning up some stuff"
Page Contents

Tags

name

Analphanumericstring (underscores are permitted) that identifies the step.

type

Must beMvnBuildfor this step type.

configuration

Specifies all configuration selections for the step's execution environment.This step inherits theBash/PowerShellstep configuration tags, including these pertinenttags:

Tag

Description of usage

Required/Optional

integrations Must specify anArtifactory Integration Required
inputResources

Must specifyaGitReporesource. The mvn commandperforms the build on files in the Git repository atsourceLocation.

May also optionally specify aFileSpecresource that specifies what files to copy tosourceLocationto build.

Required
outputResources

Must specify aBuildInforesource ifautoPublishBuildInfois set totrue.IfJFROG_CLI_BUILD_NAMEorJFROG_CLI_BUILD_NUMBERis set as an environment variable for the pipeline or the step, that name and/or number will be used for the output BuildInfo. Otherwise, the defaultbuildNameandbuildNumberare$pipeline_nameand$run_number.

May be required


In addition, these tags can be defined to support the step's native operation:

来自本地所有步骤Bashstep. This means that all steps share the same base set of tags from Bash, while native steps have their own additional tags as well that support the step's particular function. So it's important to be familiar with theBashstep definition, since it's the core of the definition of all other steps.

Tag

Description of usage

Required/Optional
mvnCommand

Specifies a command line string of options to use with Maven.

Default isclean install.

Optional
sourceLocation

Specifies the location of the source files. By default this is set to the root directory of the GitRepo resource. Defaults to the root of the GitRepo.

Required if the source files are not in the root directory.

May be required
resolverSnapshotRepo

Artifactory repository to resolve snapshot dependencies. If set,resolverReleaseRepois also required.

Do not use withconfigFileNameandconfigFileLocation.

Optional
resolverReleaseRepo

Artifactory repository to resolve release dependencies. If set,resolverSnapshotRepois also required.

Do not use withconfigFileNameandconfigFileLocation.

Optional
deployerSnapshotRepo

Snapshot artifacts created by the MvnBuild are uploaded to this Artifactory repository. If set,deployerReleaseRepois also required.

Do not use withconfigFileNameandconfigFileLocation.

Optional
deployerReleaseRepo

Release artifacts created by the MvnBuild are uploaded to this Artifactory repository. If set, deployerSnapshotRepois also required.

Do not use withconfigFileNameandconfigFileLocation.

Optional
forceXrayScan

When set totrue, forces an Xray scan after publishing to Artifactory.Default isfalse.

Optional
failOnScan

When set totrue, andwhen the XrayPolicy RuleFail Buildcheckbox is checked, a failed Xray scan will result in a failure of the step.Default istrue.

Optional
autoPublishBuildInfo

When set totrue, publishes build info to Artifactory. Requires a BuildInfo resources in the outputResources list.Default isfalse.

Optional
configFileName

Specifies the name of the JFrog CLI mvn-config file. TheserverIDin the configuration file should match the Artifactory integration name.If set,configFileLocationis also required.


This option should be used only if you have committed this configuration file to your source

Optional
configFileLocation

Specifies the directory containing the JFrog CLI mvn-config file, relative to thesourceLocation. If set,configFileNameis also required.

This option should be used only if you have committed this configuration file to your source

Optional


execution

Declares collections of shell command sequences to perform for pre- and post-execution phases:
Tag Description of usage Required/Optional
onStart Commands to execute in advance of the native operation Optional
onSuccess Commands to execute on successful completion Optional
onFailure Commands to execute on failed completion Optional
onComplete Commands to execute on any completion Optional


The actions performed for theonExecutephase are inherent to this step type and may not be overridden.


Examples

The following examples show a few ways in which a MvnBuild step can be configured.

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 theinputResourcesarray, and performs anmvn 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 thatexample 2does.

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

How it Works

When you use theMvnBuildnative step in a pipeline, it performs the following actions in the background:

MvnBuildCommands
jfrog rt config # configures JFrog CLI with the integration listed in the yaml jfrog rt mvn-config # if configFileName and configFileLocation are not set in yaml jfrog rt mvn $mvnCommand # the main maven build command add_run_variables # saves some information in run state for future steps to reference jfrog rt build-collect-env # collects build environment, preparing for build publish jfrog rt build-publish # only if autoPublishBuildInfo is true write_output # updates the buildinfo resource, if present jfrog rt build-scan # if forceXrayScan is true add_run_files # adds BuildInfo to run state
  • No labels
Copyright © 2022 JFrog Ltd.