1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/resources/metadata/mavenBuild.yaml

241 lines
9.5 KiB
YAML
Raw Normal View History

2020-02-28 14:09:46 +02:00
metadata:
2020-03-13 14:32:37 +02:00
name: mavenBuild
aliases:
- name: mavenExecute
deprecated: false
2020-03-13 14:32:37 +02:00
description: This step will install the maven project into the local maven repository.
2020-02-28 14:09:46 +02:00
longDescription: |
2020-03-13 14:32:37 +02:00
This step will install the maven project into the local maven repository.
It will also prepare jacoco to record the code coverage and
supports ci friendly versioning by flattening the pom before installing.
### build with depedencies from a private repository
if your build has depdencies from a private repository you can include a project settings xml into the source code respository as below (replace the `<url>`
tag with a valid private repo url).
```xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>private.repo.id</id>
<username>${env.PIPER_CREDENTIAL_USERNAME}</username>
<password>${env.PIPER_CREDENTIAL_PASSWORD}</password>
</server>
</servers>
<repositories>
<repository>
<id>private.repo.id</id>
<url>https://private.repo.com/</url>
</repository>
</repositories>
</settings>
```
`PIPER_CREDENTIAL_USERNAME` and `PIPER_CREDENTIAL_PASSWORD` are the username and password for the private repository and are exposed as environment variables that must be present
in the environment where the Piper step runs or alternatively can be created using :
[vault general purpose credentials](../infrastructure/vault.md#using-vault-for-general-purpose-and-test-credentials)
Ensure the following configuration in the Piper config yaml to ensure the above settings xml is included during mavenBuild:
```yaml
mavenBuild:
projectSettingsFile: <path to the above settings.xml>
```
2020-02-28 14:09:46 +02:00
spec:
inputs:
secrets:
- name: altDeploymentRepositoryPasswordId
description: Jenkins credentials ID containing the artifact deployment repository password.
type: jenkins
2020-02-28 14:09:46 +02:00
params:
- name: pomPath
type: string
2020-03-13 14:32:37 +02:00
description: Path to the pom file which should be installed including all children.
2020-02-28 14:09:46 +02:00
scope:
- PARAMETERS
- STAGES
2020-02-28 14:09:46 +02:00
- STEPS
mandatory: false
2020-03-13 14:32:37 +02:00
default: pom.xml
- name: profiles
type: "[]string"
description: Defines list of maven build profiles to be used.
scope:
- PARAMETERS
- GENERAL
- STAGES
- STEPS
2020-03-13 14:32:37 +02:00
- name: flatten
type: bool
description: Defines if the pom files should be flattened to support ci friendly maven versioning.
scope:
- PARAMETERS
default: true
- name: verify
type: bool
description: Instead of installing the artifact only the verify lifecycle phase is executed.
scope:
- PARAMETERS
default: false
2020-03-17 13:09:08 +02:00
# Global maven settings, should be added to all maven steps
2020-02-28 14:09:46 +02:00
- name: projectSettingsFile
type: string
description: Path to the mvn settings file that should be used as project settings file.
scope:
2020-03-17 13:09:08 +02:00
- GENERAL
2020-02-28 14:09:46 +02:00
- STEPS
2020-03-17 13:09:08 +02:00
- STAGES
- PARAMETERS
aliases:
- name: maven/projectSettingsFile
2020-02-28 14:09:46 +02:00
- name: globalSettingsFile
type: string
description: Path to the mvn settings file that should be used as global settings file.
scope:
2020-03-17 13:09:08 +02:00
- GENERAL
2020-02-28 14:09:46 +02:00
- STEPS
2020-03-17 13:09:08 +02:00
- STAGES
- PARAMETERS
aliases:
- name: maven/globalSettingsFile
resourceRef:
- name: commonPipelineEnvironment
param: custom/mavenGlobalSettingsFile
2020-02-28 14:09:46 +02:00
- name: m2Path
type: string
description: Path to the location of the local repository that should be used.
scope:
2020-03-17 13:09:08 +02:00
- GENERAL
2020-02-28 14:09:46 +02:00
- STEPS
2020-03-17 13:09:08 +02:00
- STAGES
- PARAMETERS
aliases:
- name: maven/m2Path
2020-02-28 14:09:46 +02:00
- name: logSuccessfulMavenTransfers
type: bool
description: Configures maven to log successful downloads. This is set to `false` by default to reduce the noise in build logs.
scope:
2020-03-17 13:09:08 +02:00
- GENERAL
- STEPS
- STAGES
2020-02-28 14:09:46 +02:00
- PARAMETERS
default: false
2020-03-17 13:09:08 +02:00
aliases:
- name: maven/logSuccessfulMavenTransfers
- name: createBOM
type: bool
description: Creates the bill of materials (BOM) using CycloneDX Maven plugin.
scope:
- GENERAL
- STEPS
- STAGES
- PARAMETERS
default: false
aliases:
- name: maven/createBOM
- name: altDeploymentRepositoryPassword
type: string
description: Password for the alternative deployment repository to which the project artifacts should be deployed ( other than those specified in <distributionManagement> ). This password will be updated in settings.xml . When no settings.xml is provided a new one is created corresponding with <servers> tag
scope:
- GENERAL
- PARAMETERS
- STAGES
- STEPS
secret: true
resourceRef:
- name: commonPipelineEnvironment
param: custom/repositoryPassword
- name: altDeploymentRepositoryPasswordId
type: secret
- type: vaultSecretFile
name: altDeploymentRepositoryPasswordFileVaultSecretName
default: alt-deployment-repository-passowrd
- name: altDeploymentRepositoryUser
type: string
description: User for the alternative deployment repository to which the project artifacts should be deployed ( other than those specified in <distributionManagement> ). This user will be updated in settings.xml . When no settings.xml is provided a new one is created corresponding with <servers> tag
scope:
- GENERAL
- PARAMETERS
- STAGES
- STEPS
resourceRef:
- name: commonPipelineEnvironment
param: custom/repositoryUsername
- name: altDeploymentRepositoryUrl
type: string
description: Url for the alternative deployment repository to which the project artifacts should be deployed ( other than those specified in <distributionManagement> ). This Url will be updated in settings.xml . When no settings.xml is provided a new one is created corresponding with <servers> tag
scope:
- GENERAL
- PARAMETERS
- STAGES
- STEPS
resourceRef:
- name: commonPipelineEnvironment
param: custom/repositoryUrl
- name: altDeploymentRepositoryID
type: string
description: Id for the alternative deployment repository to which the project artifacts should be deployed ( other than those specified in <distributionManagement> ). This id will be updated in settings.xml and will be used as a flag with DaltDeploymentRepository along with mavenAltDeploymentRepositoryUrl during maven deploy . When no settings.xml is provided a new one is created corresponding with <servers> tag
scope:
- GENERAL
- PARAMETERS
- STAGES
- STEPS
resourceRef:
- name: commonPipelineEnvironment
param: custom/repositoryId
- name: customTlsCertificateLinks
type: "[]string"
description: "List of download links to custom TLS certificates. This is required to ensure trusted connections to instances with repositories (like nexus) when publish flag is set to true."
scope:
- PARAMETERS
- STAGES
- STEPS
- name: publish
type: bool
description: Configures maven to run the deploy plugin to publish artifacts to a repository.
scope:
- STEPS
- STAGES
- PARAMETERS
default: false
aliases:
- name: maven/publish
- name: javaCaCertFilePath
type: string
description: path to the cacerts file used by Java. When maven publish is set to True and customTlsCertificateLinks (to deploy the artifact to a repository with a self signed cert) are provided to trust the self signed certs, Piper will extend the existing Java cacerts to include the new self signed certs. if not provided Piper will search for the cacerts in $JAVA_HOME/jre/lib/security/cacerts
scope:
- STEPS
- STAGES
- PARAMETERS
aliases:
- name: maven/javaCaCertFilePath
- name: buildSettingsInfo
type: string
description: build settings info is typically filled by the step automatically to create information about the build settings that were used during the maven build . This information is typically used for compliance related processes.
scope:
- STEPS
- STAGES
- PARAMETERS
resourceRef:
- name: commonPipelineEnvironment
param: custom/buildSettingsInfo
outputs:
resources:
- name: commonPipelineEnvironment
type: piperEnvironment
params:
- name: custom/buildSettingsInfo
- name: reports
type: reports
params:
- filePattern: "**/bom.xml"
type: sbom
- filePattern: "**/TEST-*.xml"
type: junit
- filePattern: "**/jacoco.xml"
type: jacoco-coverage
2020-03-17 13:09:08 +02:00
containers:
- name: mvn
image: maven:3.6-jdk-8