github.com/ouraigua/jenkins-library@v0.0.0-20231028010029-fbeaf2f3aa9b/resources/metadata/mavenBuild.yaml (about)

     1  metadata:
     2    name: mavenBuild
     3    aliases:
     4      - name: mavenExecute
     5        deprecated: false
     6    description: This step will install the maven project into the local maven repository.
     7    longDescription: |
     8      This step will install the maven project into the local maven repository.
     9      It will also prepare jacoco to record the code coverage and
    10      supports ci friendly versioning by flattening the pom before installing.
    11  
    12      ### build with depedencies from a private repository
    13      if your build has dependencies from a private repository you can include a project settings xml into the source code repository as below (replace the `<url>`
    14      tag with a valid private repo url).
    15      ```xml
    16      <?xml version="1.0" encoding="UTF-8"?>
    17      <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
    18      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">
    19        <servers>
    20          <server>
    21              <id>private.repo.id</id>
    22              <username>${env.PIPER_VAULTCREDENTIAL_USERNAME}</username>
    23              <password>${env.PIPER_VAULTCREDENTIAL_PASSWORD}</password>
    24          </server>
    25        </servers>
    26      </settings>
    27      ```
    28      `PIPER_VAULTCREDENTIAL_USERNAME` and `PIPER_VAULTCREDENTIAL_PASSWORD` are the username and password for the private repository and are exposed as environment variables that must be present
    29      in the environment where the Piper step runs or alternatively can be created using :
    30      [vault general purpose credentials](../infrastructure/vault.md#using-vault-for-general-purpose-and-test-credentials)
    31  
    32      include the below `<repositories>` tag in your `pom.xml` to reference the `<server>` and make sure the values in the `<id>` tags match
    33      ```xml
    34      <repositories>
    35          <repository>
    36            <id>private.repo.id</id>
    37            <url>https://private.repo.com/</url>
    38          </repository>
    39      </repositories>
    40      ```
    41  
    42      Ensure the following configuration in the Piper `config.yaml` to ensure the above settings xml is included and all steps can consume this parameter:
    43  
    44      ```yaml
    45      general:
    46        projectSettingsFile: <path to the above settings.xml>
    47      ```
    48  spec:
    49    inputs:
    50      secrets:
    51        - name: altDeploymentRepositoryPasswordId
    52          description: Jenkins credentials ID containing the artifact deployment repository password.
    53          type: jenkins
    54      params:
    55        - name: pomPath
    56          type: string
    57          description: Path to the pom file which should be installed including all children.
    58          scope:
    59            - PARAMETERS
    60            - STAGES
    61            - STEPS
    62          mandatory: false
    63          default: pom.xml
    64        - name: profiles
    65          type: "[]string"
    66          description: Defines list of maven build profiles to be used.
    67          scope:
    68            - PARAMETERS
    69            - GENERAL
    70            - STAGES
    71            - STEPS
    72        - name: flatten
    73          type: bool
    74          description: Defines if the pom files should be flattened to support ci friendly maven versioning.
    75          scope:
    76            - PARAMETERS
    77            - STEPS
    78          default: true
    79        - name: verify
    80          type: bool
    81          description: Instead of installing the artifact only the verify lifecycle phase is executed.
    82          scope:
    83            - PARAMETERS
    84          default: false
    85  
    86        # Global maven settings, should be added to all maven steps
    87        - name: projectSettingsFile
    88          type: string
    89          description: Path to the mvn settings file that should be used as project settings file.
    90          scope:
    91            - GENERAL
    92            - STEPS
    93            - STAGES
    94            - PARAMETERS
    95          aliases:
    96            - name: maven/projectSettingsFile
    97        - name: globalSettingsFile
    98          type: string
    99          description: Path to the mvn settings file that should be used as global settings file.
   100          scope:
   101            - GENERAL
   102            - STEPS
   103            - STAGES
   104            - PARAMETERS
   105          aliases:
   106            - name: maven/globalSettingsFile
   107          resourceRef:
   108            - name: commonPipelineEnvironment
   109              param: custom/mavenGlobalSettingsFile
   110        - name: m2Path
   111          type: string
   112          description: Path to the location of the local repository that should be used.
   113          scope:
   114            - GENERAL
   115            - STEPS
   116            - STAGES
   117            - PARAMETERS
   118          aliases:
   119            - name: maven/m2Path
   120        - name: logSuccessfulMavenTransfers
   121          type: bool
   122          description: Configures maven to log successful downloads. This is set to `false` by default to reduce the noise in build logs.
   123          scope:
   124            - GENERAL
   125            - STEPS
   126            - STAGES
   127            - PARAMETERS
   128          default: false
   129          aliases:
   130            - name: maven/logSuccessfulMavenTransfers
   131        - name: createBOM
   132          type: bool
   133          description: Creates the bill of materials (BOM) using CycloneDX Maven plugin.
   134          scope:
   135            - GENERAL
   136            - STEPS
   137            - STAGES
   138            - PARAMETERS
   139          default: false
   140          aliases:
   141            - name: maven/createBOM
   142        - name: altDeploymentRepositoryPassword
   143          type: string
   144          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
   145          scope:
   146            - GENERAL
   147            - PARAMETERS
   148            - STAGES
   149            - STEPS
   150          secret: true
   151          resourceRef:
   152            - name: commonPipelineEnvironment
   153              param: custom/mavenRepositoryPassword
   154            - name: commonPipelineEnvironment
   155              param: custom/repositoryPassword
   156            - name: altDeploymentRepositoryPasswordId
   157              type: secret
   158            - type: vaultSecretFile
   159              name: altDeploymentRepositoryPasswordFileVaultSecretName
   160              default: alt-deployment-repository-passowrd
   161        - name: altDeploymentRepositoryUser
   162          type: string
   163          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
   164          scope:
   165            - GENERAL
   166            - PARAMETERS
   167            - STAGES
   168            - STEPS
   169          resourceRef:
   170            - name: commonPipelineEnvironment
   171              param: custom/mavenRepositoryUsername
   172            - name: commonPipelineEnvironment
   173              param: custom/repositoryUsername
   174        - name: altDeploymentRepositoryUrl
   175          type: string
   176          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
   177          scope:
   178            - GENERAL
   179            - PARAMETERS
   180            - STAGES
   181            - STEPS
   182          resourceRef:
   183            - name: commonPipelineEnvironment
   184              param: custom/mavenRepositoryURL
   185            - name: commonPipelineEnvironment
   186              param: custom/repositoryUrl
   187        - name: altDeploymentRepositoryID
   188          type: string
   189          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
   190          scope:
   191            - GENERAL
   192            - PARAMETERS
   193            - STAGES
   194            - STEPS
   195          resourceRef:
   196            - name: commonPipelineEnvironment
   197              param: custom/repositoryId
   198        - name: customTlsCertificateLinks
   199          type: "[]string"
   200          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."
   201          scope:
   202            - PARAMETERS
   203            - STAGES
   204            - STEPS
   205        - name: publish
   206          type: bool
   207          description: Configures maven to run the deploy plugin to publish artifacts to a repository.
   208          scope:
   209            - STEPS
   210            - STAGES
   211            - PARAMETERS
   212          default: false
   213          aliases:
   214            - name: maven/publish
   215        - name: javaCaCertFilePath
   216          type: string
   217          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
   218          scope:
   219            - STEPS
   220            - STAGES
   221            - PARAMETERS
   222          aliases:
   223            - name: maven/javaCaCertFilePath
   224        - name: buildSettingsInfo
   225          type: string
   226          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.
   227          scope:
   228            - STEPS
   229            - STAGES
   230            - PARAMETERS
   231          resourceRef:
   232            - name: commonPipelineEnvironment
   233              param: custom/buildSettingsInfo
   234      resources:
   235        - type: stash
   236    outputs:
   237      resources:
   238        - name: commonPipelineEnvironment
   239          type: piperEnvironment
   240          params:
   241            - name: custom/buildSettingsInfo
   242        - name: reports
   243          type: reports
   244          params:
   245            - filePattern: "**/bom-maven.xml"
   246              type: sbom
   247            - filePattern: "**/TEST-*.xml"
   248              type: junit
   249            - filePattern: "**/jacoco.xml"
   250              type: jacoco-coverage
   251    containers:
   252      - name: mvn
   253        image: maven:3.6-jdk-8