github.com/jaylevin/jenkins-library@v1.230.4/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 default: true 78 - name: verify 79 type: bool 80 description: Instead of installing the artifact only the verify lifecycle phase is executed. 81 scope: 82 - PARAMETERS 83 default: false 84 85 # Global maven settings, should be added to all maven steps 86 - name: projectSettingsFile 87 type: string 88 description: Path to the mvn settings file that should be used as project settings file. 89 scope: 90 - GENERAL 91 - STEPS 92 - STAGES 93 - PARAMETERS 94 aliases: 95 - name: maven/projectSettingsFile 96 - name: globalSettingsFile 97 type: string 98 description: Path to the mvn settings file that should be used as global settings file. 99 scope: 100 - GENERAL 101 - STEPS 102 - STAGES 103 - PARAMETERS 104 aliases: 105 - name: maven/globalSettingsFile 106 resourceRef: 107 - name: commonPipelineEnvironment 108 param: custom/mavenGlobalSettingsFile 109 - name: m2Path 110 type: string 111 description: Path to the location of the local repository that should be used. 112 scope: 113 - GENERAL 114 - STEPS 115 - STAGES 116 - PARAMETERS 117 aliases: 118 - name: maven/m2Path 119 - name: logSuccessfulMavenTransfers 120 type: bool 121 description: Configures maven to log successful downloads. This is set to `false` by default to reduce the noise in build logs. 122 scope: 123 - GENERAL 124 - STEPS 125 - STAGES 126 - PARAMETERS 127 default: false 128 aliases: 129 - name: maven/logSuccessfulMavenTransfers 130 - name: createBOM 131 type: bool 132 description: Creates the bill of materials (BOM) using CycloneDX Maven plugin. 133 scope: 134 - GENERAL 135 - STEPS 136 - STAGES 137 - PARAMETERS 138 default: false 139 aliases: 140 - name: maven/createBOM 141 - name: altDeploymentRepositoryPassword 142 type: string 143 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 144 scope: 145 - GENERAL 146 - PARAMETERS 147 - STAGES 148 - STEPS 149 secret: true 150 resourceRef: 151 - name: commonPipelineEnvironment 152 param: custom/mavenRepositoryPassword 153 - name: commonPipelineEnvironment 154 param: custom/repositoryPassword 155 - name: altDeploymentRepositoryPasswordId 156 type: secret 157 - type: vaultSecretFile 158 name: altDeploymentRepositoryPasswordFileVaultSecretName 159 default: alt-deployment-repository-passowrd 160 - name: altDeploymentRepositoryUser 161 type: string 162 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 163 scope: 164 - GENERAL 165 - PARAMETERS 166 - STAGES 167 - STEPS 168 resourceRef: 169 - name: commonPipelineEnvironment 170 param: custom/mavenRepositoryUsername 171 - name: commonPipelineEnvironment 172 param: custom/repositoryUsername 173 - name: altDeploymentRepositoryUrl 174 type: string 175 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 176 scope: 177 - GENERAL 178 - PARAMETERS 179 - STAGES 180 - STEPS 181 resourceRef: 182 - name: commonPipelineEnvironment 183 param: custom/mavenRepositoryURL 184 - name: commonPipelineEnvironment 185 param: custom/repositoryUrl 186 - name: altDeploymentRepositoryID 187 type: string 188 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 189 scope: 190 - GENERAL 191 - PARAMETERS 192 - STAGES 193 - STEPS 194 resourceRef: 195 - name: commonPipelineEnvironment 196 param: custom/repositoryId 197 - name: customTlsCertificateLinks 198 type: "[]string" 199 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." 200 scope: 201 - PARAMETERS 202 - STAGES 203 - STEPS 204 - name: publish 205 type: bool 206 description: Configures maven to run the deploy plugin to publish artifacts to a repository. 207 scope: 208 - STEPS 209 - STAGES 210 - PARAMETERS 211 default: false 212 aliases: 213 - name: maven/publish 214 - name: javaCaCertFilePath 215 type: string 216 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 217 scope: 218 - STEPS 219 - STAGES 220 - PARAMETERS 221 aliases: 222 - name: maven/javaCaCertFilePath 223 - name: buildSettingsInfo 224 type: string 225 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. 226 scope: 227 - STEPS 228 - STAGES 229 - PARAMETERS 230 resourceRef: 231 - name: commonPipelineEnvironment 232 param: custom/buildSettingsInfo 233 outputs: 234 resources: 235 - name: commonPipelineEnvironment 236 type: piperEnvironment 237 params: 238 - name: custom/buildSettingsInfo 239 - name: reports 240 type: reports 241 params: 242 - filePattern: "**/bom.xml" 243 type: sbom 244 - filePattern: "**/TEST-*.xml" 245 type: junit 246 - filePattern: "**/jacoco.xml" 247 type: jacoco-coverage 248 containers: 249 - name: mvn 250 image: maven:3.6-jdk-8