github.com/jaylevin/jenkins-library@v1.230.4/resources/metadata/golangBuild.yaml (about) 1 metadata: 2 name: golangBuild 3 description: This step will execute a golang build. 4 longDescription: | 5 This step will build a golang project. 6 It will also execute golang-based tests using [gotestsum](https://github.com/gotestyourself/gotestsum) and with that allows for reporting test results and test coverage. 7 8 Besides execution of the default tests the step allows for running an additional integration test run using `-tags=integration` using pattern `./...` 9 10 If the build is successful the resulting artifact can be uploaded to e.g. a binary repository automatically. 11 spec: 12 inputs: 13 secrets: 14 - name: golangPrivateModulesGitTokenCredentialsId 15 description: Jenkins 'Username with password' credentials ID containing username/password for http access to your git repos where your go private modules are stored. 16 type: jenkins 17 params: 18 - name: buildFlags 19 type: "[]string" 20 description: Defines list of build flags to be used. 21 scope: 22 - PARAMETERS 23 - STAGES 24 - STEPS 25 - name: buildSettingsInfo 26 type: string 27 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. 28 scope: 29 - STEPS 30 - STAGES 31 - PARAMETERS 32 resourceRef: 33 - name: commonPipelineEnvironment 34 param: custom/buildSettingsInfo 35 - name: cgoEnabled 36 type: bool 37 description: "If active: enables the creation of Go packages that call C code." 38 scope: 39 - STEPS 40 - STAGES 41 - PARAMETERS 42 - name: coverageFormat 43 type: string 44 description: Defines the format of the coverage repository. 45 possibleValues: 46 - cobertura 47 - html 48 scope: 49 - STEPS 50 - STAGES 51 - PARAMETERS 52 default: html 53 - name: createBOM 54 type: bool 55 description: Creates the bill of materials (BOM) using CycloneDX plugin. It requires Go 1.17 or newer. 56 scope: 57 - GENERAL 58 - STEPS 59 - STAGES 60 - PARAMETERS 61 - name: customTlsCertificateLinks 62 type: "[]string" 63 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." 64 scope: 65 - GENERAL 66 - PARAMETERS 67 - STAGES 68 - STEPS 69 - name: excludeGeneratedFromCoverage 70 type: bool 71 description: "Defines if generated files should be excluded, according to [https://golang.org/s/generatedcode](https://golang.org/s/generatedcode)." 72 scope: 73 - PARAMETERS 74 - STAGES 75 - STEPS 76 default: true 77 - name: ldflagsTemplate 78 type: string 79 description: Defines the content of -ldflags option in a golang template format. 80 longDescription: | 81 The template allows using commonPipelineEnvironment parameters in the form `.CPE["<paramName>"]` 82 83 Examples 84 85 * `-X github.com/SAP/jenkins-library/pkg/log.Version={{index .CPE "artifactVersion"}}`. 86 * `-X github.com/SAP/jenkins-library/pkg/log.LibraryRepository={{index .CPE "custom/repositoryId"}}` 87 scope: 88 - PARAMETERS 89 - STAGES 90 - STEPS 91 - name: output 92 type: string 93 description: Defines the build result or output directory as per `go build` documentation. 94 scope: 95 - PARAMETERS 96 - STAGES 97 - STEPS 98 - name: packages 99 type: "[]string" 100 description: List of packages to be build as per `go build` documentation. 101 scope: 102 - PARAMETERS 103 - STAGES 104 - STEPS 105 - name: publish 106 type: bool 107 description: Configures the build to publish artifacts to a repository. 108 scope: 109 - STEPS 110 - STAGES 111 - PARAMETERS 112 - name: targetRepositoryPassword 113 description: "Password for the target repository where the compiled binaries shall be uploaded - typically provided by the CI/CD environment." 114 type: string 115 scope: 116 - PARAMETERS 117 - STAGES 118 - STEPS 119 secret: true 120 resourceRef: 121 - name: commonPipelineEnvironment 122 param: custom/rawRepositoryPassword 123 - name: commonPipelineEnvironment 124 param: custom/repositoryPassword 125 - name: targetRepositoryUser 126 description: "Username for the target repository where the compiled binaries shall be uploaded - typically provided by the CI/CD environment." 127 type: string 128 scope: 129 - PARAMETERS 130 - STAGES 131 - STEPS 132 secret: true 133 resourceRef: 134 - name: commonPipelineEnvironment 135 param: custom/rawRepositoryUsername 136 - name: commonPipelineEnvironment 137 param: custom/repositoryUsername 138 - name: targetRepositoryURL 139 description: "URL of the target repository where the compiled binaries shall be uploaded - typically provided by the CI/CD environment." 140 type: string 141 scope: 142 - PARAMETERS 143 - STAGES 144 - STEPS 145 resourceRef: 146 - name: commonPipelineEnvironment 147 param: custom/rawRepositoryURL 148 - name: commonPipelineEnvironment 149 param: custom/repositoryUrl 150 - name: reportCoverage 151 type: bool 152 description: Defines if a coverage report should be created. 153 default: true 154 scope: 155 - STEPS 156 - STAGES 157 - PARAMETERS 158 - name: runTests 159 type: bool 160 description: Activates execution of tests using [gotestsum](https://github.com/gotestyourself/gotestsum). 161 default: true 162 scope: 163 - STEPS 164 - STAGES 165 - PARAMETERS 166 - name: runIntegrationTests 167 type: bool 168 description: Activates execution of a second test run using tag `integration`. 169 scope: 170 - STEPS 171 - STAGES 172 - PARAMETERS 173 - name: targetArchitectures 174 type: "[]string" 175 description: Defines the target architectures for which the build should run using OS and architecture separated by a comma. 176 default: linux,amd64 177 scope: 178 - GENERAL 179 - STEPS 180 - STAGES 181 - PARAMETERS 182 mandatory: true 183 - name: testOptions 184 type: "[]string" 185 description: Options to pass to test as per `go test` documentation (comprises e.g. flags, packages). 186 scope: 187 - STEPS 188 - STAGES 189 - PARAMETERS 190 - name: testResultFormat 191 type: "string" 192 description: Defines the output format of the test results. 193 possibleValues: 194 - junit 195 - standard 196 default: junit 197 scope: 198 - STEPS 199 - STAGES 200 - PARAMETERS 201 - name: privateModules 202 type: "string" 203 description: Tells go which modules shall be considered to be private (by setting [GOPRIVATE](https://pkg.go.dev/cmd/go#hdr-Configuration_for_downloading_non_public_code)). 204 scope: 205 - STEPS 206 - STAGES 207 - PARAMETERS 208 alias: 209 - goprivate 210 - name: privateModulesGitToken 211 description: GitHub personal access token as per https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line. 212 scope: 213 - GENERAL 214 - PARAMETERS 215 - STAGES 216 - STEPS 217 type: string 218 secret: true 219 resourceRef: 220 - name: golangPrivateModulesGitTokenCredentialsId 221 type: secret 222 param: password 223 - type: vaultSecret 224 name: golangPrivateModulesGitTokenVaultSecret 225 default: golang 226 - name: artifactVersion 227 type: string 228 description: Version of the artifact to be built. 229 scope: 230 - GENERAL 231 - PARAMETERS 232 - STAGES 233 - STEPS 234 resourceRef: 235 - name: commonPipelineEnvironment 236 param: artifactVersion 237 outputs: 238 resources: 239 - name: commonPipelineEnvironment 240 type: piperEnvironment 241 params: 242 - name: custom/buildSettingsInfo 243 - name: custom/artifacts 244 type: "piperenv.Artifacts" 245 - name: reports 246 type: reports 247 params: 248 - filePattern: "**/bom.xml" 249 type: sbom 250 - filePattern: "**/TEST-*.xml" 251 type: junit 252 - filePattern: "**/cobertura-coverage.xml" 253 type: cobertura-coverage 254 containers: 255 - name: golang 256 image: golang:1 257 options: 258 - name: -u 259 value: "0"