github.com/jaylevin/jenkins-library@v1.230.4/documentation/docs/steps/cnbBuild.md (about) 1 # ${docGenStepName} 2 3 ## ${docGenDescription} 4 5 see [Examples](#examples) 6 7 ## Prerequisites 8 9 When pushing to a container registry, you need to maintain the respective credentials in your Jenkins credentials store: 10 11 `cnbBuild` expects a Docker `config.json` file containing the credential information for registries. 12 You can create it like explained in the [protocodeExecuteScan Prerequisites section](https://www.project-piper.io/steps/protecodeExecuteScan/#prerequisites). 13 14 Please copy this file and upload it to your Jenkins for example<br /> 15 via _Jenkins_ -> _Credentials_ -> _System_ -> _Global credentials (unrestricted)_ -> _Add Credentials_ -> 16 17 * Kind: _Secret file_ 18 * File: upload your `config.json` file 19 * ID: specify id which you then use for the configuration of `dockerConfigJsonCredentialsId` (see below) 20 21 ## ${docGenParameters} 22 23 ### Additional hints 24 25 To run the `cnbBuild` with a different builder, you can specify the `dockerImage` parameter. 26 Without specifying it, the step will run with the `paketobuildpacks/builder:base` builder. 27 28 #### Default Excludes 29 30 When building images, these files/folders are excluded from the build by default: 31 32 * Piper binary: `piper` 33 * Piper configuration folder: `.pipeline` 34 * Git folder: `.git` 35 36 This behavior can be overwritten by using the respective sections in [`project.toml`](https://buildpacks.io/docs/reference/config/project-descriptor/). Keep in mind that by doing so, no default excludes will be applied by the `cnbBuild` step at all. 37 38 ## ${docGenConfiguration} 39 40 ## ${docJenkinsPluginDependencies} 41 42 ## Examples 43 44 ### Example 1: simple usage 45 46 ```groovy 47 cnbBuild( 48 script: script, 49 dockerConfigJsonCredentialsId: 'DOCKER_REGISTRY_CREDS', 50 containerImageName: 'images/example', 51 containerImageTag: 'v0.0.1', 52 containerRegistryUrl: 'gcr.io' 53 ) 54 ``` 55 56 ### Example 2: User provided builder 57 58 ```groovy 59 cnbBuild( 60 script: script, 61 dockerConfigJsonCredentialsId: 'DOCKER_REGISTRY_CREDS', 62 dockerImage: 'paketobuildpacks/builder:base', 63 containerImageName: 'images/example', 64 containerImageTag: 'v0.0.1', 65 containerRegistryUrl: 'gcr.io' 66 ) 67 ``` 68 69 ### Example 3: User provided buildpacks 70 71 ```groovy 72 cnbBuild( 73 script: script, 74 dockerConfigJsonCredentialsId: 'DOCKER_REGISTRY_CREDS', 75 containerImageName: 'images/example', 76 containerImageTag: 'v0.0.1', 77 containerRegistryUrl: 'gcr.io', 78 buildpacks: ['gcr.io/paketo-buildpacks/nodejs', 'paketo-community/build-plan'] 79 ) 80 ``` 81 82 ### Example 4: Build environment variables 83 84 ```groovy 85 cnbBuild( 86 script: script, 87 dockerConfigJsonCredentialsId: 'DOCKER_REGISTRY_CREDS', 88 containerImageName: 'images/example', 89 containerImageTag: 'v0.0.1', 90 containerRegistryUrl: 'gcr.io', 91 buildEnvVars: [ 92 "FOO": "BAR" 93 ] 94 ) 95 ```