Customizing the build pipeline
To meet your specific needs, customize the way that Konflux builds components. You can customize in two ways:
-
Change the parameters of the build pipeline of a component.
-
Extend the pipeline with your own tasks (or deleting existing tasks).
For example, you can change for how long Konflux saves the container images of component, by changing the value of the image-expires-after
parameter. Or you can ensure that the container images it builds for a component are compliant with regulations for your industry, by adding a compliance check as a task to its build pipeline.
To customize a build pipeline, you must first upgrade it.
To customize the build pipeline in any way, start by completing the following steps:
-
In your preferred IDE, navigate to the
.tekton
directory in the repository of your component. -
Open both
.yaml
files in the repository.
Changing parameters
-
In each
.yaml
file in the.tekton
directory, customize the parameters of the build pipeline by changing the pipelineparams
:-
Pipeline params have the paths
.spec.params
and.pipelineSpec.params
-
Change the default
value
of existing parameters. For example, you can set the value ofimage-expires-after
to2w
, instead of5d
-
Add parameters. New parameters must include a
name
andvalue
.
-
-
Commit your changes to the repository of the component.
Extending the build pipeline with your own tasks
-
In each
.yaml
file in the.tekton
directory, add a new task undertasks
.Example task:
name: example-task params: - name: example-param value: “Example” runAfter: - build-container #You can be more specific by choosing another task taskRef: params: - name: name value: example-task # metadata.name field of the Task - name: bundle value: quay.io/tekton-bundle-catalog/example-task-bundle:1.0 # For more details on tekton bundles, refer https://tekton.dev/docs/pipelines/pipelines/#tekton-bundles - name: kind value: task resolver: bundles when: - input: $(params.skip-checks) #This references the pipeline parameters operator: in values: - "false"
An example of a custom task added to the pipeline that sends a slack notification when the
Pipelinerun
fails:name: slack-webhook-notification params: - name: message value: PipelineRun $(context.pipelineRun.name) failed - name: secret-name value: my-secret # name of secret in the your namespace which contains slack web-hook URL under key specified in 'key-name' parameter below - name: key-name value: dev-team taskRef: params: - name: bundle value: quay.io/redhat-appstudio-tekton-catalog/task-slack-webhook-notification:0.1 - name: name value: slack-webhook-notification - name: kind value: Task resolver: bundles when: - input: $(tasks.status) operator: in values: ["Failed"]
-
Commit your changes to the repository of the component.
|
Exchanging the build pipeline build task with higher memory limits
The buildah
task, which builds components from a Dockerfile, has a memory limit of 4 GB. To build components with memory requirements greater than 4 GB, use the following tasks:
To exchange the build task with a memory limit of 6 GB, complete the following steps. For a memory limit of 8 or 10 GB, replace the references to 6 GB with the appropriate values.
-
Go to the GitHub repo of your component.
-
In each .yaml file in the .tekton directory, under tasks, locate the task named build-container:
-
Under
.taskRef.params
, setname
tobuildah-6gb
. -
Under
.taskRef.params
, setbundle
toquay.io/redhat-appstudio-tekton-catalog/task-buildah-6gb:0.1
.
-
Bring your own Quay repository to the build pipeline
By default, all pipelines push the images to the quay.io/redhat-user-workloads
repository. It is not mandatory to use this Quay repo, so if you want to use your own Quay repo to control user permissions, you can do this by updating the output-image
parameter in the pipelines.
-
You need a secret to push images to your Quay repo.
-
Follow Quay’s documentation to create a robot account for your repository.
-
Give push access to your repository to the robot account.
-
Retrieve the
.dockercfg
from the "Docker Configuration" menu on your robot account credentials page. -
Follow the steps to create a secret for your build as an "Image Pull Secret".
-
You need to delete the For example, this is how you get the file from Quay:
And this is how you should upload it to Konflux:
|
-
Go to the GitHub repo of your component.
-
In each .yaml file within the .tekton directory, under
params
, locate the parameter namedoutput-image
:-
Change it to reflect your new repository. For example:
quay.io/my-new-quay-repo/my-app:on-pr-{{revision}}
for thepull-request
pipeline, andquay.io/my-new-quay-repo/my-app:{{revision}}
for thepush
pipeline. This distinction helps identify which images originate from a Pull Request and which do not.
-
Verification
When you commit changes to these .yaml
files in your repository, Konflux automatically triggers a new build. Wait for Konflux to complete the new build, then verify your changes have been made by following these steps:
-
Navigate to Activity > Pipeline runs.
-
Select the most recent build pipeline run.
-
In the Details tab, confirm that there are new tasks that you added in the pipeline visualization.
-
In the Logs tab, confirm the following:
-
Any new tasks are in the navigation bar.
-
If you changed a parameter’s value, and that value gets printed, the new value is in the log.
-
Troubleshooting
If you experience any issues with your customized pipeline, try the following solutions:
-
If you believe that your desired parameter values are not being passed into the pipeline, make sure that your assignment of that value doesn’t get overwritten later in the
.yaml
file. -
If your new task is not appearing in the pipeline run, ensure the following:
-
You added it to the correct place in the
.yaml
files, so that it has the path.spec.params
or.pipelineSpec.params
. -
You specified a valid
runAfter
field, and that the task in that field completed successfully.
-
-
For problems with both parameters and tasks, make sure you committed your changes to the
.tekton
directory in the repository that Konflux references for the component. -
If your build pipeline can no longer successfully run, your best option is to simply rebuild the
.tekton
directory:-
Delete the
.tekton
directory in the repository of the component. -
In the Konflux console, on the Overview tab for the relevant application, scroll down and select Manage build pipelines.
-
Select the three dots next to the relevant component and select Roll back to default pipeline.
-
Complete the steps for upgrading the build pipeline of that component again.
-
Additional resources
-
Visit the Tekton documentation that explains how to use
taskSpec
in a task declaration.