Passing buildah arguments

Konflux buildah task accepts BUILD_ARGS parameter that allows passing build arguments to the underlying buildah command through --build-arg flag. To enable this, make the following changes to the PipelineRuns under the .tekton/ directory:

  1. Define a build-args Pipeline parameter (if not already present) in .spec.pipelineSpec.params to accept the passed-in build arguments.

    spec:
      # ...
      pipelineSpec:
        params:
        # ...
        - name: build-args
          type: array
          default: []
  2. Pass the argument to buildah task. Add BUILD_ARGS to build-container.params (if not already present):

    spec:
      # ...
      pipelineSpec:
        tasks:
        # ...
        - name: build-container
          params:
          # ...
          - name: BUILD_ARGS
            value: ["$(params.build-args[*])"]

    The value can also be in form tasks.<taskName>.results.<resultName>[*] if it is generated by another task dynamically.

    For example, you can do more creative things with the BUILD_ARGS parameter like this snippet of a pipeline that allows passing build-args through the pipeline parameter (as described above) but also incorporates build-args generated dynamically by other tasks:

    spec:
      # ...
      pipelineSpec:
        tasks:
        # ...
        - name: build-container
          params:
          # ...
          - name: BUILD_ARGS
            value:
            # pass the build args array from the pipeline param
            - $(params.build-args[*])
            # and a dynamically generated array of build args
            - $(tasks.my-build-arg-generator-task.results.BUILD_ARGS[*])
            # and a build arg with a static name and dynamic value
            - VERSION=$(tasks.my-get-version-task.results.VERSION)
    Ensure that the value of BUILD_ARGS has the correct syntax as described in Variable Substitutions Supported by Tasks and Pipelines.
  3. Pass the desired build arguments in the PipelineRun .spec.params:

    spec:
      params:
      # ...
      - name: build-args
        value: ["ARG1=val", "ARG2=val"]  # Add real argument name and value of each build argument