---
name: codeengine-toolchain-ce
title: Integrating Code Engine workloads with Continuous Delivery
description: You can automate the build and deployment of your IBM Cloud&reg; Code Engine workloads by creating a toolchain with Continuous Delivery. You can create a toolchain that pulls your source code from a repository and then builds and deploys your app or job. Whenever you update the source code in the repository, the toolchain automatically pulls your updated code and then builds and re-deploys your app or job.
last-updated: 2024-10-09
---

> ## Documentation Index
> The table of contents for this documentation set is at https://cloud.ibm.com/docs/codeengine?format=markdown
> The index for all IBM Cloud docs is at: https://cloud.ibm.com/docs/llms.txt
> Use these files to discover more information as needed.

# Integrating Code Engine workloads with Continuous Delivery
{: #toolchain-ce}

You can automate the build and deployment of your IBM Cloud&reg; Code Engine workloads by creating a toolchain with Continuous Delivery. You can create a toolchain that pulls your source code from a repository and then builds and deploys your app or job. Whenever you update the source code in the repository, the toolchain automatically pulls your updated code and then builds and re-deploys your app or job. 
{: shortdesc}
  
## Before you begin
{: #toolchain-begin}
  
Before you get started with toolchains, 

- Create or identify a [Code Engine project](https://cloud.ibm.com/docs/codeengine?topic=codeengine-manage-project&format=markdown#create-a-project). You can create these resources by using either the console or the CLI. For more information, see [Code Engine projects](https://cloud.ibm.com/docs/codeengine?topic=codeengine-manage-project&format=markdown#create-a-project).

- Create or identify an instance of the [Continuous Delivery](https://cloud.ibm.com/docs/ContinuousDelivery?topic=ContinuousDelivery-getting-started&format=markdown) service.

- Create or identify an IBM Cloud Container Registry namespace. For more information about creating a namespace, see [IBM Cloud Container Registry](https://cloud.ibm.com/docs/Registry?topic=Registry-getting-started&format=markdown#getting-started) service.


## Configuring access for your toolchain
{: #permissions-toolchain}

If you want to build and deploy an app or job with a toolchain, set the following permissions in IAM.
  
IBM Cloud Container Registry
- Reader: To pull the image from Container registry.
- Writer: To push the created image to the target namespace.
- Manager: To create the specified namespace if it does not exist.
- Administrator: To create a service ID, policies, and an API key needed to set up a Code Engine registry secret to use for the app or job.
  
Code Engine
- Editor: To access a Code Engine project or to create one, if it does not exist.
- Writer: To manage apps, jobs, and secrets within the Code Engine project.
  
Resource Group:
- Viewer: To view the resource group that the Code Engine project is located in.
  
If you want to your app to bind another IBM Cloud service, you must set the following additional permissions.
  
All Identity and Access enabled services
- Administrator: To create a service ID, policies, and API key to set up a Code Engine service access secret, which is used to maintain service credentials to connect individual services to a Code Engine app or job.
  
## Creating a toolchain
{: #create-toolchain}  
  
You can create a toolchain from the [Toolchain page](https://cloud.ibm.com/devops/toolchains){: external} by selecting **Create toolchain** and then choosing the Code Engine template. Want to try a tutorial? See [Develop and deploy an app by using Code Engine](https://cloud.ibm.com/docs/ContinuousDelivery?topic=ContinuousDelivery-tutorial-cd-code-engine&format=markdown).

## Code Engine options in your toolchain
{: #toolchain-options}
  
You can set the following options for your Code Engine toolchain by editing your `ci-pipeline Configuration` and selecting **Environment properties**.

| Option | Description |
| --------- | ------------------- |
| `apikey` | The IBM Cloud API key that is used for this toolchain.  |
| `app-concurrency` | The maximum number of requests that can be processed concurrently per instance. The default value is `100`.  |
| `app-deployment-timeout` | The amount of time, in seconds, that can pass before the build must succeed or fail. |
| `app-health-endpoint` | The app health endpoint; for example, `/health`. |
| `app-max-scale` | The maximum number of instances that can be used for this application. If you set this value to `0`, the application scales as needed. The application scaling is limited only by the instances per the resource quota for the project of your application. See [Limits and quotas for Code Engine](https://cloud.ibm.com/docs/codeengine?topic=codeengine-limits&format=markdown). The default value is `10`.  |
| `app-min-scale` | The minimum number of instances that can be used for this application. This option is useful to ensure that no instances are running when not needed. This value is optional. The default value is `0`.  |
| `app-name` | The name of the application. Use a name that is unique within the project.  |
| `app-port` | The port where the application listens for incoming connections. The format is `[NAME:]PORT`, where `[NAME:]` is optional. If `[NAME:]` is specified, valid values are `h2c` or `http1`. By default, Code Engine assumes apps listen for incoming connections on port 8080. |
| `app-visibility` | The visibility for the application. Valid values are `public`, `private`, and `project`. Setting a visibility of `public` means that your app can receive requests from the public internet or from components within the Code Engine project. See [Options for visibility for a Code Engine application](https://cloud.ibm.com/docs/codeengine?topic=codeengine-application-workloads&format=markdown#optionsvisibility). |
| `branch` | The branch in the repository that contains the buildpacks file or the Dockerfile. The default value is `main`.  |
| `build-size` | The size for the build, which determines the amount of resources used. Valid values are `small`, `medium`, `large`, `xlarge`, and `xxlarge`. For details, see [Determining the size of the build](https://cloud.ibm.com/docs/codeengine?topic=codeengine-plan-build&format=markdown#build-size). |
| `build-strategy` | The strategy to use for building the image. Valid values are `dockerfile` and `buildpacks`. |
| `build-timeout` | The amount of time, in seconds, that can pass before the build run must succeed or fail. The default is `1200` seconds. |
| `build-use-native-docker` | Optional property to opt-in for using native Docker build capabilities instead of the Code Engine build to containerize the source. You can select this value only if the `build-strategy` is set to `dockerfile`. Valid values are `true` and `false`. |
| `code-engine-project` | The project that contains this application.  |
| `cpu` | The amount of CPU set for the instance of the application. For valid values, see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo&format=markdown). The default value is `1`. |
| `deployment-type` | Specifies the type of deployment. Valid values are `application` and `job`.  |
| `ephemeral-storage` | The amount of ephemeral storage to set for the instance of the application. Use `M` for megabytes or `G` for gigabytes. |
| `git-token` | The access token for the Git repository.  |
| `image-name` | The name of the image that is used for this application. The format is `REGISTRY/NAMESPACE/REPOSITORY:TAG` where `REGISTRY` and `TAG` are optional. If `REGISTRY` is not specified, the default is `docker.io`. If `TAG` is not specified, the default is `latest`. |
| `memory` | The amount of memory set for the instance of the application. Use M for megabytes or G for gigabytes. For valid values, see [Supported memory and CPU combinations](https://cloud.ibm.com/docs/codeengine?topic=codeengine-mem-cpu-combo&format=markdown). The default value is `4G`.  |
| `path-to-context` |  The directory in the repository that contains the buildpacks file or the Dockerfile. |
| `path-to-dockerfile` |  The path to the Dockerfile. Specify this option only if the name is other than `Dockerfile`. |
| `pipeline-debug` | The pipeline debug mode. Value can be `0` or `1`. Default to `0`.  |
| `region` | The region where the Code Engine project is located.  |
| `registry-namespace` |  The Container registry namespace that stores the built image. |
| `registry-region` | The Container registry region.  |
| `resource-group` | The resource group that contains the Code Engine project. |
| `service-bindings` | The service binding that binds an IBM Cloud service instance to an application. This value is in the format `"{\"<SERVICE_INSTANCE_NAME>\": \"<BINDING_PREFIX>\"}"`. For example, `"{\"object-store-rg-e\": \"CLOUD_OBJECT_STORAGE\"}`. This value must be in base64.  |
{: caption="Code Engine options in toolchain" caption-side="bottom"}

For more options, see the **Environment properties** for your pipeline in your toolchain settings.
{: note}


## Troubleshooting toolchain issues
{: #ts-toolchain}

Troubleshoot your Code Engine toolchain with the following topics.
  
- [Debugging your Code Engine toolchain](https://cloud.ibm.com/docs/codeengine?topic=codeengine-troubleshoot-toolchain-ce&format=markdown).
- [Troubleshooting for toolchains](https://cloud.ibm.com/docs/ContinuousDelivery?topic=ContinuousDelivery-troubleshoot-toolchains&format=markdown).