github.com/jaylevin/jenkins-library@v1.230.4/resources/metadata/kanikoExecute.yaml (about)

     1  metadata:
     2    name: kanikoExecute
     3    description: Executes a [Kaniko](https://github.com/GoogleContainerTools/kaniko) build for creating a Docker container.
     4    longDescription: |
     5      Executes a [Kaniko](https://github.com/GoogleContainerTools/kaniko) build for creating a Docker container.
     6  
     7      ### Building multiple container images
     8  
     9      The step allows you to build multiple container images with one run.
    10      This is suitable in case you need to create multiple images for one microservice, e.g. for testing.
    11  
    12      All images will get the same "root" name and the same versioning.<br />
    13      **Thus, this is not suitable to be used for a monorepo approach!** For monorepos you need to use a build tool natively capable to take care for monorepos
    14      or implement a custom logic and for example execute this `kanikoExecute` step multiple times in your custom pipeline.
    15  
    16      You can activate multiple builds using the parameter [containerMultiImageBuild](#containermultiimagebuild)
    17  
    18      Behavior can be adapted using:
    19  
    20      * [containerMultiImageBuildExcludes](#containermultiimagebuildexcludes) for defining excludes
    21      * [containerMultiImageBuildTrimDir](#containermultiimagebuildtrimdir) for removing parent directory part from image name
    22  
    23      Examples:
    24  
    25      #### Multiple containers in sub directories
    26  
    27      Configuration as follows:
    28  
    29      ```
    30      general:
    31        containerImageName: myImage
    32      steps:
    33        kanikoExecute:
    34          containerMultiImageBuild: true
    35      ```
    36  
    37      Following Dockerfiles are available in the repository:
    38  
    39      * sub1/Dockerfile
    40      * sub2/Dockerfile
    41  
    42      Following final image names will be built:
    43  
    44      * `myImage-sub1`
    45      * `myImage-sub2`
    46  
    47      #### Multiple containers in sub directories while trimming a directory part
    48  
    49      Configuration as follows:
    50  
    51      ```
    52      general:
    53        containerImageName: myImage
    54      steps:
    55        kanikoExecute:
    56          containerMultiImageBuild: true
    57          containerMultiImageBuildTrimDir: .ci
    58      ```
    59  
    60      Following Dockerfiles are available in the repository:
    61  
    62      * .ci/sub1/Dockerfile
    63      * .ci/sub2/Dockerfile
    64  
    65      Following final image names will be built:
    66  
    67      * `myImage-sub1`
    68      * `myImage-sub2`
    69  
    70  spec:
    71    inputs:
    72      secrets:
    73        - name: dockerConfigJsonCredentialsId
    74          description: Jenkins 'Secret file' credentials ID containing Docker config.json (with registry credential(s)). You can create it like explained in the [protocodeExecuteScan Prerequisites section](https://www.project-piper.io/steps/protecodeExecuteScan/#prerequisites).
    75          type: jenkins
    76      params:
    77        - name: buildOptions
    78          type: "[]string"
    79          description: Defines a list of build options for the [kaniko](https://github.com/GoogleContainerTools/kaniko) build.
    80          scope:
    81            - PARAMETERS
    82            - STAGES
    83            - STEPS
    84          default:
    85            - --skip-tls-verify-pull
    86            # fixing Kaniko issue https://github.com/GoogleContainerTools/kaniko/issues/1586
    87            # as per comment https://github.com/GoogleContainerTools/kaniko/issues/1586#issuecomment-945718536
    88            - --ignore-path=/workspace
    89            - --ignore-path=/busybox
    90        - name: buildSettingsInfo
    91          type: string
    92          description: Build settings info is typically filled by the step automatically to create information about the build settings that were used during the mta build. This information is typically used for compliance related processes.
    93          scope:
    94            - STEPS
    95            - STAGES
    96            - PARAMETERS
    97          resourceRef:
    98            - name: commonPipelineEnvironment
    99              param: custom/buildSettingsInfo
   100        - name: containerBuildOptions
   101          type: string
   102          description: Deprected, please use buildOptions. Defines the build options for the [kaniko](https://github.com/GoogleContainerTools/kaniko) build.
   103          scope:
   104            - PARAMETERS
   105            - STAGES
   106            - STEPS
   107        - name: containerImage
   108          aliases:
   109            - name: containerImageNameAndTag
   110              deprecated: true
   111          type: string
   112          description: Defines the full name of the Docker image to be created including registry, image name and tag like `my.docker.registry/path/myImageName:myTag`. If left empty, image will not be pushed.
   113          scope:
   114            - PARAMETERS
   115            - STAGES
   116            - STEPS
   117        - name: containerImageName
   118          aliases:
   119            - name: dockerImageName
   120          type: string
   121          description: Name of the container which will be built - will be used instead of parameter `containerImage`
   122          scope:
   123            - GENERAL
   124            - PARAMETERS
   125            - STAGES
   126            - STEPS
   127        - name: containerImageTag
   128          aliases:
   129            - name: artifactVersion
   130          type: string
   131          description: Tag of the container which will be built - will be used instead of parameter `containerImage`
   132          scope:
   133            - GENERAL
   134            - PARAMETERS
   135            - STAGES
   136            - STEPS
   137          resourceRef:
   138            - name: commonPipelineEnvironment
   139              param: artifactVersion
   140        - name: containerMultiImageBuild
   141          type: bool
   142          description: Defines if multiple containers should be build. Dockerfiles are used using the pattern **/Dockerfile*. Excludes can be defined via [`containerMultiImageBuildExcludes`](#containermultiimagebuildexscludes).
   143          scope:
   144            - GENERAL
   145            - PARAMETERS
   146            - STAGES
   147            - STEPS
   148        - name: containerMultiImageBuildExcludes
   149          type: '[]string'
   150          description: Defines a list of Dockerfile paths to exclude from the build when using [`containerMultiImageBuild`](#containermultiimagebuild).
   151          scope:
   152            - GENERAL
   153            - PARAMETERS
   154            - STAGES
   155            - STEPS
   156        - name: containerMultiImageBuildTrimDir
   157          type: 'string'
   158          description: Defines a trailing directory part which should not be considered in the final image name.
   159          scope:
   160            - PARAMETERS
   161            - STAGES
   162            - STEPS
   163        - name: containerPreparationCommand
   164          type: string
   165          description: Defines the command to prepare the Kaniko container. By default the contained credentials are removed in order to allow anonymous access to container registries.
   166          scope:
   167            - PARAMETERS
   168            - STAGES
   169            - STEPS
   170          default: rm -f /kaniko/.docker/config.json
   171        - name: containerRegistryUrl
   172          aliases:
   173            - name: dockerRegistryUrl
   174          type: string
   175          description: http(s) url of the Container registry where the image should be pushed to - will be used instead of parameter `containerImage`
   176          scope:
   177            - GENERAL
   178            - PARAMETERS
   179            - STAGES
   180            - STEPS
   181          resourceRef:
   182            - name: commonPipelineEnvironment
   183              param: container/registryUrl
   184        - name: customTlsCertificateLinks
   185          type: "[]string"
   186          description: List containing download links of custom TLS certificates. This is required to ensure trusted connections to registries with custom certificates.
   187          scope:
   188            - PARAMETERS
   189            - STAGES
   190            - STEPS
   191        - name: dockerConfigJSON
   192          type: string
   193          description: Path to the file `.docker/config.json` - this is typically provided by your CI/CD system. You can find more details about the Docker credentials in the [Docker documentation](https://docs.docker.com/engine/reference/commandline/login/).
   194          scope:
   195            - PARAMETERS
   196            - STAGES
   197            - STEPS
   198          secret: true
   199          resourceRef:
   200            - name: commonPipelineEnvironment
   201              param: custom/dockerConfigJSON
   202            - name: dockerConfigJsonCredentialsId
   203              type: secret
   204            - type: vaultSecretFile
   205              name: dockerConfigFileVaultSecretName
   206              default: docker-config
   207        - name: dockerfilePath
   208          aliases:
   209            - name: dockerfile
   210          type: string
   211          description: Defines the location of the Dockerfile relative to the Jenkins workspace.
   212          scope:
   213            - PARAMETERS
   214            - STAGES
   215            - STEPS
   216          default: Dockerfile
   217        - name: targetArchitectures
   218          type: "[]string"
   219          description: Defines the target architectures for which the build should run using OS and architecture separated by a comma. (EXPERIMENTAL)
   220          default: []
   221          scope:
   222            - GENERAL
   223            - STEPS
   224            - STAGES
   225            - PARAMETERS
   226        - name: readImageDigest
   227          type: bool
   228          default: false
   229          scope:
   230            - STEPS
   231            - STAGES
   232            - PARAMETERS
   233    outputs:
   234      resources:
   235        - name: commonPipelineEnvironment
   236          type: piperEnvironment
   237          params:
   238            - name: container/registryUrl
   239            - name: container/imageNameTag
   240            - name: container/imageDigest
   241            - name: container/imageNames
   242              type: "[]string"
   243            - name: container/imageNameTags
   244              type: "[]string"
   245            - name: container/imageDigests
   246              type: "[]string"
   247            - name: custom/buildSettingsInfo
   248    containers:
   249      - image: gcr.io/kaniko-project/executor:debug
   250        command:
   251          - /busybox/tail -f /dev/null
   252        shell: /busybox/sh
   253        options:
   254          - name: -u
   255            value: "0"
   256          - name: --entrypoint
   257            value: ""
   258        env:
   259          - name: container
   260            value: docker