IBM Developer

Tutorial

Build a multi-architecture CI/CD pipeline for AI agents

Learn how to containerize, test, scan, and deploy AI agents across x86 and IBM Z using MCP, Docker, IBM DevSecOps, and IBM Cloud Container Registry

By Keerthi Bikkasani

AI agents often need access to tools and services to complete user requests. Moving an AI agent from development to production requires additional controls for containerization, automated testing, security, compliance, and support for different hardware architectures.

A multi-architecture continuous integration and continuous delivery (CI/CD) pipeline provides a consistent way to build and validate AI agent applications for x86 and IBM Z environments. IBM Cloud Continuous Delivery provides the DevSecOps pipeline for building, testing, scanning, and publishing the container images.

In this tutorial, you build a CI/CD pipeline for an agentic AI application that uses the Model Context Protocol (MCP) for tool orchestration. The pipeline builds Docker images for amd64 and s390x architectures, runs integration tests against live containers to validate AI agent tool selection, and pushes validated images to IBM Cloud Container Registry (ICR). The pipeline also includes secrets detection, vulnerability scanning, compliance checks, and artifact signing.

The pipeline supports two deployment variants. The MCP variant uses Meta Llama 3.3 70B for general-purpose tool orchestration. The Spyre variant uses IBM Granite 3.3 8B for IBM Z hardware acceleration. The tutorial focuses on the MCP variant and explains the Spyre-specific configuration where required.

In this tutorial, you learn how to:

  • Configure IBM Secure Pipeline Services for an agentic AI application.
  • Build Docker images for amd64 and s390x architectures.
  • Run automated integration tests to validate AI agent tool selection.
  • Push validated container images to IBM Cloud Container Registry.
  • Integrate security and compliance checks into the CI/CD pipeline.

Architecture of the multi-architecture CI/CD pipeline

The architecture uses IBM Secure Pipeline Services (SPS) to build, test, scan, and publish the AI agent container images. The following diagram shows how the pipeline processes amd64 and s390x builds in parallel and publishes the validated images to IBM Cloud Container Registry (ICR).

Block diagram of the solution: a developer pushes code to the application repository, which triggers the IBM Secure Pipeline Services pipeline; two parallel paths (x86 and IBM Z) each build, test, push, and scan an image; validated images are stored in IBM Cloud Container Registry, and test results are committed back to the repository

The pipeline starts when you push code to the application repository or when a scheduled pipeline run begins. IBM Secure Pipeline Services runs separate pipeline paths for amd64 and s390x architectures.

For each architecture, the pipeline builds an architecture-specific container image and runs integration tests against the MCP client and MCP server containers. The integration tests send sample questions to the AI agent and record the tool that the AI agent selects for each question.

The amd64 path pushes the validated image to IBM Cloud Container Registry and runs a Twistlock vulnerability scan. The s390x path also pushes the validated image to IBM Cloud Container Registry, with scan evidence saved for the image digest. Code checks run in parallel with the architecture-specific tasks.

After both architecture paths complete, the pipeline commits the test results to the SPS branch and notifies the team. A successful pipeline run produces validated container images for amd64 and s390x architectures, test results for each architecture, and security scan results.

Prerequisites

Before you begin, ensure that you have the following:

Step 1. Configure IBM Secure Pipeline Services

In this step, you add the pipeline configuration and required shell scripts to the application repository. You also create an IBM DevSecOps toolchain that uses the pipeline configuration to build and test the application.

  1. At the root of the application repository, create and configure the .pipeline-config.yaml file. For more information, see Configure the .pipeline-config.yaml file. IBM Secure Pipeline Services (SPS) uses this file to configure the pipeline. The .pipeline-config.yaml file defines a task for each architecture:

    • code-build builds the amd64 image.
    • code-build-s390x builds the s390x image.

    Each task runs the following four scripts as part of a single build-artifact step:

    • build-artifact-setup.sh
    • build-artifact-execute.sh
    • build-artifact-test.sh
    • build-artifact-push.sh

    Running the four scripts in the same build-artifact step keeps shell variables such as GLOBAL_IMAGE_NAME and TAG_TIMESTAMP available throughout the build process. Create the four shell scripts at the root of the application repository. The remaining steps in this tutorial add the required logic to each script:

    • Step 2 configures the build environment.
    • Step 3 builds the container image and selects the model.
    • Step 4 runs the integration tests.
    • Step 5 tags and pushes the container image.
  2. Commit the pipeline files and push the changes to your GitHub branch.

  3. In IBM Cloud, create a DevSecOps toolchain. Configure the Continuous Integration pipeline to use the application repository and the .pipeline-config.yaml file. For detailed instructions, see Creating a DevSecOps toolchain.

    You configure the pipeline properties, including the IMAGE_NAME property that selects the MCP or Spyre variant, in Step 2.

  4. Push a new commit or click Run pipeline in the DevSecOps toolchain to start the pipeline. The following screen capture shows an example of a successful pipeline run. Compare the pipeline stages and status with your pipeline run to verify the configuration.

    Screen capture of a successful SPS pipeline run in the toolchain UI, showing the code-checks, code-build-amd64, and code-build-s390x tasks all completed with green check marks

Configure the .pipeline-config.yaml file

The .pipeline-config.yaml file defines the tasks that IBM Secure Pipeline Services (SPS) runs. The main tasks are code-build for amd64 and code-build-s390x for s390x. For more information, see the .pipeline-config.yaml schema reference for the full list of supported fields, task overrides, and when conditions.

The code-build-s390x task uses from: code-build to inherit the configuration from the amd64 task. The s390x task overrides the configuration required for the s390x architecture. This approach keeps the four build scripts in a single build-artifact step.

version: '2'

# These four flags are appropriate for development pipelines while you
# iterate on the build. Remove all four before promoting to production.
environment:
  DEVSECOPS_SKIP_EVIDENCE_PUBLISH: "true"
  DEVSECOPS_SKIP_EVALUATION: "true"
  DEVSECOPS_SKIP_COMPLIANCE: "true"
  DEVSECOPS_SKIP_SIGNING: "true"

tasks:
  code-build:
    displayName: code-build-amd64
    runtimeClassName: x86-xxlarge
    include:
      - dind
    steps:
      - name: build-artifact
        include:
          - docker-socket
        image: icr.io/continuous-delivery/base-images/base:v1.23.0
        onError: stopAndFail
        script: |
          #!/usr/bin/env bash
          export BLD_ARCH="amd64"
          export BUILD_BRANCH="$(get_env BUILD_BRANCH)"
          source build-artifact-setup.sh
          source build-artifact-execute.sh
          source build-artifact-test.sh
          source build-artifact-push.sh

      - name: scan-artifact
        include:
          - docker-socket
        script: |
          #!/usr/bin/env bash
          ${COMMONS_PATH}/scan-artifact/scan.sh

  code-build-s390x:
    from: code-build
    displayName: code-build-s390x
    steps:
      - name: build-artifact
        image: icr.io/continuous-delivery/pipeline/pipeline-base-ubi:3.66
        script: |
          #!/usr/bin/env bash
          export BLD_ARCH="s390x"
          export BUILD_BRANCH="$(get_env BUILD_BRANCH)"
          source build-artifact-setup.sh
          source build-artifact-execute.sh
          source build-artifact-test.sh
          source build-artifact-push.sh

      - name: scan-artifact
        when: 'false'

The complete .pipeline-config.yaml file also defines a code-checks task. The code-checks task runs detect-secrets.sh and the IBM compliance checks described in Step 6. For information about the complete configuration, including the deploy-checks and finally blocks, see the .pipeline-config.yaml schema reference.

Note: Use the DEVSECOPS_SKIP_* flags only while you configure and test the pipeline. Remove all four flags before you promote the toolchain to production.

Step 2. Configure the build environment

In this step, you configure the credentials and pipeline properties required by the build process. The build-artifact-setup.sh script uses these values to prepare the environment for each amd64 and s390x build.

The build-artifact-setup.sh script performs the following tasks:

  1. Reads the required pipeline properties with get_env and exports each value with a GLOBAL_ prefix. The prefix identifies values that come from the toolchain.
  2. Installs Python 3.12 and Poetry 2.2.1 if the build image does not include the required versions.
  3. Authenticates with IBM Cloud and IBM Cloud Container Registry (ICR) by using the IBM Cloud API key.
  4. Clones the application repository from the branch specified by BUILD_BRANCH.
  5. Checks for commits from the previous 24 hours. If the script finds a commit, the script sets COMMIT=true. A later build step uses this value to determine whether to build a new image or reuse the previous image.
  6. For s390x builds, installs the JFrog CLI. The build process uses the JFrog CLI to download precompiled vendor wheels from Artifactory.

Configure the required pipeline inputs as follows:

  1. In the DevSecOps toolchain, go to Pipeline properties and add the following properties:

    • ICR_REGION: The region for the ICR namespace, such as us-south.
    • ICR_NAMESPACE: The ICR namespace that you created in the prerequisites.
    • IMAGE_NAME: The container image name. Use an image name that contains spyre to build the Spyre variant.
    • IBMCLOUD_API_KEY: An IBM Cloud API key with permission to push images to ICR. Store the API key as a secret.
    • GITHUB_ID: The GitHub ID that the pipeline uses to commit test results.
    • BUILD_BRANCH: The Git branch that the pipeline builds.
  2. Upload the GitHub OAuth token as a secure file. The build-artifact-setup.sh script reads the token from /config/GITHUB_OAUTH2_TOKEN. For instructions, see Managing secrets in your toolchain.
  3. For s390x builds, upload the Artifactory password as /config/afpwd and add af_user as a pipeline property. The build process uses these credentials to download the required vendor wheels from Artifactory.

    The .pipeline-config.yaml file automatically runs build-artifact-setup.sh at the beginning of each build:

    source build-artifact-setup.sh
    

    The require_env helper reads each required pipeline property, verifies that the property has a value, and exports the value with a GLOBAL_ prefix:

    function require_env() {
      local var_name=$1
      local value=$(get_env "$var_name")
      if [[ -z "$value" ]]; then
        echo "ERROR: Missing required environment variable $var_name"
        exit 1
      fi
      export GLOBAL_${var_name}="$value"
    }
    
    require_env ICR_REGION
    require_env ICR_NAMESPACE
    require_env IMAGE_NAME
    require_env IBMCLOUD_API_KEY
    

    Note: The setup script explicitly installs poetry-plugin-export because the pipeline uses the Poetry export command. If you modify build-artifact-setup.sh, keep the poetry-plugin-export installation.

Step 3. Build Docker images for amd64 and s390x

In this step, you configure the pipeline to build Docker images for amd64 and s390x from the same application source. The build-artifact-execute.sh script selects the Dockerfile and large language model (LLM) based on the IMAGE_NAME and BLD_ARCH values.

  1. Verify the IMAGE_NAME pipeline property that you configured in Step 2.

    • An IMAGE_NAME value that contains spyre selects the Spyre variant with IBM Granite 3.3 8B.
    • Any other IMAGE_NAME value selects the MCP variant with Meta Llama 3.3 70B.
  2. Add Dockerfile.amd64 and Dockerfile.s390x to the application repository. The build-artifact-execute.sh script uses the appropriate Dockerfile for each architecture.

  3. Commit the files and push the changes to the GitHub branch. The pipeline runs build-artifact-execute.sh. The script performs the following tasks:

    • Selects the LLM based on IMAGE_NAME.
    • Exports the Python dependencies by using poetry export.
    • For s390x builds, downloads the required vendor wheels from Artifactory.
    • Updates the torch version in requirements.txt to the version required for s390x.
    • Builds the Docker image for the selected architecture.

The following code shows the model and architecture selection logic:

if [[ "${GLOBAL_IMAGE_NAME}" == *"spyre"* ]]; then
  export VERSION="spyre"
  export LLM_MODEL="ibm/granite-3-3-8b-instruct"
else
  export VERSION="mcp"
  export LLM_MODEL="meta-llama/llama-3-3-70b-instruct"
fi

if [[ "$GLOBAL_BLD_ARCH" == "amd64" ]]; then
  docker build -t "${GLOBAL_IMAGE_NAME}:amd64" -f Dockerfile.amd64 .
elif [[ "$GLOBAL_BLD_ARCH" == "s390x" ]]; then
  jf rt download "<your-artifactory-repo>/vendor_wheels/" --flat=false
  sed -i 's/^torch==[^ ;]*/torch==2.9.0a0+git0fabc3b/' requirements.txt
  docker build -t "${GLOBAL_IMAGE_NAME}:s390x" -f Dockerfile.s390x .
fi

After the build completes, verify that the pipeline created the Docker images for both architectures.

alt

Dockerfile for amd64

The amd64 image uses a single-stage build based on UBI 9 minimal. The Dockerfile installs Python 3.12 and the required dependencies, copies the application code, and starts the application with main.py. The application uses the SERVICE_MODE environment variable at runtime to run the MCP server, the agent client, or both.

# Simple x86 Dockerfile for AI Agent
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest

WORKDIR /app

# Install Python and basic tools
RUN microdnf install -y python3.12 python3.12-pip git \
 && ln -sf /usr/bin/python3.12 /usr/bin/python \
 && ln -sf /usr/bin/pip3.12 /usr/bin/pip \
 && microdnf clean all

# Copy requirements file
COPY requirements.txt /app/requirements.txt

# Install Python dependencies
# Use Docker secrets to avoid exposing GitHub token in image layers
RUN --mount=type=secret,id=github_token \
    if [ -f /run/secrets/github_token ]; then \
      GITHUB_TOKEN=$(cat /run/secrets/github_token) && \
      git config --global url."https://oauth2:${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"; \
    fi && \
    pip install --no-cache-dir -r /app/requirements.txt && \
    git config --global --unset-all url."https://oauth2:.*@github.com/".insteadOf || true

# Copy application code
COPY . /app

# Expose ports for agent and MCP server
EXPOSE 9001 9002

# Entry point
CMD ["python", "/app/main.py"]

Dockerfile for s390x

The s390x image uses a multi-stage build. The builder stage compiles dependencies that require build tools on s390x. The runtime stage copies the installed Python packages from the builder stage without including the build tools in the final image.

Side-by-side comparison of the amd64 single-stage Dockerfile and the s390x multi-stage Dockerfile, showing how the builder stage compiles dependencies and the runtime stage copies only the installed packages

# Simplified s390x Dockerfile for AI Agent on IBM Z
# Uses multi-stage build to compile dependencies

# ============================================
# Stage 1: Build dependencies
# ============================================
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest AS builder

WORKDIR /app

# Install build tools
RUN microdnf install -y \
    gcc gcc-c++ python3.12 python3.12-pip python3.12-devel \
    git curl-minimal \
 && ln -sf /usr/bin/python3.12 /usr/bin/python \
 && ln -sf /usr/bin/pip3.12 /usr/bin/pip

# Install Rust for Python packages that require Rust on s390x
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
ENV PATH="/root/.cargo/bin:$PATH"

# Copy and install dependencies
COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# ============================================
# Stage 2: Runtime image
# ============================================
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest

WORKDIR /app

# Install runtime dependencies
RUN microdnf install -y python3.12 python3.12-pip git \
 && ln -sf /usr/bin/python3.12 /usr/bin/python \
 && ln -sf /usr/bin/pip3.12 /usr/bin/pip \
 && microdnf clean all

# Copy installed packages from builder
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=builder /usr/local/lib64/python3.12/site-packages /usr/local/lib64/python3.12/site-packages

# Copy application code
COPY . /app

# Expose ports
EXPOSE 9001 9002

# Start application
CMD ["python", "/app/main.py"]

The main difference between the Dockerfiles is how each Dockerfile installs the Python dependencies. The amd64 Dockerfile installs the dependencies directly in the runtime image. The s390x Dockerfile uses a separate builder stage to prepare the dependencies before copying the installed packages into the runtime image.

Step 4. Test the AI agent in containers

In this step, you run automated integration tests to verify that the AI agent selects the expected tools for test questions. The build-artifact-test.sh script starts the MCP server and agent client in separate containers, runs the tests, saves the test results, and commits the results to the sps branch.

  1. In the application repository, create tests/questions/build-test.txt. Add one test question per line. For example:

    What are the open critical vulnerabilities in my application?
    Show me the compliance posture for the production environment.
    List all unresolved incidents from the last 7 days.
    
  2. Add batchtest-stream.py to the application repository. The test runner reads each question from build-test.txt, sends the question to the running AI agent on port 9001, and records the tool that the AI agent selects.

     #!/usr/bin/env python3
     import argparse
     import sys
     from pathlib import Path
     import requests
    
     AGENT_URL = "http://localhost:9001/invoke"
    
     parser = argparse.ArgumentParser(
         description="Run test questions through the agent and record tool selections."
     )
     parser.add_argument(
         "-f",
         "--questions-file",
         required=True,
         help="Path to the questions file, one question per line."
     )
     parser.add_argument(
         "-o",
         "--output-file",
         default="/app/toolSelection.txt",
         help="Where to write the results."
     )
     args = parser.parse_args()
    
     questions_path = Path(args.questions_file)
     if not questions_path.exists():
         print(f"Questions file not found: {questions_path}")
         sys.exit(1)
    
     out_path = Path(args.output_file)
    
     with out_path.open("w") as out:
         for line in questions_path.read_text().splitlines():
             question = line.strip()
             if not question or question.startswith("#"):
                 continue
    
             print(f"Testing: {question}")
             try:
                 resp = requests.post(
                     AGENT_URL,
                     json={"input": question},
                     timeout=300
                 )
                 resp.raise_for_status()
                 tool = resp.json().get("tool_selected") or "None"
             except (requests.RequestException, ValueError) as e:
                 tool = f"ERROR: {e}"
    
             out.write(f"Q: {question}\nTool selected: {tool}\n\n")
    
     print(f"\nDone. Results written to {out_path}")
    

    Update AGENT_URL, the request body, and the response field to match the AI agent API. For example, if the AI agent uses /api/v1/chat and returns the selected tool in selected_tool, update the test runner to use the following values:

    AGENT_URL = "http://localhost:9001/api/v1/chat"
    
    tool = resp.json().get("selected_tool") or "None"
    
  3. Commit the test files and push the changes to the develop branch. The pipeline starts the MCP server and agent client containers on the same Docker network.

    The build-artifact-test.sh script waits up to 60 seconds for the MCP server and up to 6000 seconds for the agent client. The longer s390x timeout allows the AI agent additional time to load the PyTorch model weights without GPU acceleration.

    After both containers are ready, the pipeline runs batchtest-stream.py against the agent client.

  4. After the pipeline completes, open the sps branch and review the results in:

    results/<branch-name>/toolSelection_<arch>.txt
    

    The pipeline also saves the results URL in RESULTS_FILE_URL so that the toolchain can include the URL in its message channel.

    A test result can look like this:

    Q: What are the open critical vulnerabilities in my application?
    Tool selected: get_vulnerabilities
    
    Q: What is the weather like today?
    Tool selected: None
    
    Q: List all unresolved incidents from the last 7 days.
    Tool selected: ERROR: HTTPConnectionPool(host='localhost', port=9001): Read timed out.
    
  5. Review the tool selection results for each architecture.

    • Tool selected: <tool_name> indicates that the AI agent selected a tool. Verify that the selected tool matches the expected tool for the question.
    • Tool selected: None indicates that the AI agent returned a response without selecting a tool. Review the system prompt and tool descriptions if the test question requires a tool.
    • Tool selected: ERROR indicates that the request failed. Review the container status, connection, and startup time before investigating tool selection.

    Sample tool selection results that show a selected tool, a None result, and a timeout error

    The sps branch maintains test results from pipeline runs. Use the commit history to compare how the AI agent selects tools across different builds and architectures.

    Git commit diff that shows the selected tool for one question changing from list_incidents to get_incident_summary between two pipeline runs

    Note: The 6000-second timeout provides additional startup time for s390x builds. After you measure the typical s390x startup time, reduce the timeout in build-artifact-test.sh to avoid long waits when a container fails to start.

Step 5. Push validated images to IBM Cloud Container Registry

In this step, the pipeline tags the validated Docker images and pushes the images to IBM Cloud Container Registry (ICR). The pipeline also registers image metadata so that the security scan in Step 6 can identify the images.

  1. Verify the ICR_REGION and ICR_NAMESPACE pipeline properties that you configured in Step 2.
  2. Push a commit to the GitHub branch to start the pipeline. The pipeline uses the COMMIT value that build-artifact-setup.sh set in Step 2 to determine whether to build and push a new image.

    • If COMMIT=true, the pipeline builds and pushes a new image. For develop and mcp-ga-develop branches, the pipeline uses the build timestamp as the image tag. For other branches, the pipeline uses the lowercase branch name as the image tag.

      Pipeline log that shows the image tagged and pushed to IBM Cloud Container Registry after commits are detected in the last 24 hours

    • If COMMIT=false, the pipeline retrieves the latest image for the architecture from ICR and reuses the image instead of building and pushing another image. This path can occur during a scheduled pipeline run when no recent commits exist.

      Pipeline log that shows the build skipped and the latest existing image retagged and reused because no commits are detected in the last 24 hours

  3. After the pipeline completes, verify the images in ICR. Run the following command:

    ibmcloud cr image-list --restrict <your-namespace>
    

    You can also open Container Registry > Images in the IBM Cloud console.

    Output of the ibmcloud cr image-list command that shows the amd64 and s390x images with no security issues

  4. The pipeline uses the SPS save_artifact function to register the image name, image type, and SHA-256 digest. The scan-artifact step in Step 6 uses this metadata to identify the image to scan.

    The following code shows the core image tagging, push, and artifact registration logic:

    IMAGE_PATH_ICR="icr.io/${GLOBAL_ICR_NAMESPACE}/${GLOBAL_IMAGE_NAME}"
    
    if [[ "${BUILD_BRANCH}" == "develop" || "${BUILD_BRANCH}" == "mcp-ga-develop" ]]; then
      IMAGE_TAG_TIMESTAMP="${IMAGE_PATH_ICR}:${TAG_TIMESTAMP}"
    else
      BUILD_BRANCH_LOWERCASE=$(echo "$BUILD_BRANCH" | tr '[:upper:]' '[:lower:]')
      IMAGE_TAG_TIMESTAMP="${IMAGE_PATH_ICR}:${BUILD_BRANCH_LOWERCASE}"
    fi
    
    if [ "${COMMIT}" = "true" ]; then
      docker tag "${GLOBAL_IMAGE_NAME}:${BLD_ARCH}" "${IMAGE_TAG_TIMESTAMP}"
      docker push "${IMAGE_TAG_TIMESTAMP}"
    fi
    
    # Register the image metadata for the scan-artifact step.
    save_artifact "${GLOBAL_IMAGE_NAME}" "name=${IMGINFO}"
    save_artifact "${GLOBAL_IMAGE_NAME}" "type=image"
    save_artifact "${GLOBAL_IMAGE_NAME}" "digest=${IMGSHA}"
    

    When COMMIT=false, the script uses ibmcloud cr image-list to find the latest image for the architecture in ICR and reuses the existing image.

Step 6. Configure and review security scans

In this step, you configure and review the security checks in the IBM DevSecOps pipeline. The pipeline checks the source code for secrets, protects credentials during Docker builds, scans container images for vulnerabilities, and runs compliance checks.

  1. Verify that detect-secrets.sh exists at the root of the application repository. Verify that the code-checks task in .pipeline-config.yaml runs detect-secrets.sh before the image build begins.

    The detect-secrets step in the .pipeline-config.yaml file, which runs the detect-secrets.sh script

  2. Protect credentials that the Docker build requires. Use RUN --mount=type=secret,id=<id> in the Dockerfile and pass the secret from the pipeline with --secret id=<id>,src=/config/<file>.

    The Dockerfiles from Step 3 use this approach for github_token.

  3. After the pipeline completes, open the pipeline run in the Pipelines view. Review the code-checks and code-build logs.

    • The detect-secrets step reports whether the source code contains potential secrets.
    • The scan-artifact step reports container image vulnerabilities and vulnerability severity counts.
  4. Before you promote the toolchain to production, remove DEVSECOPS_SKIP_COMPLIANCE: "true" and the other DEVSECOPS_SKIP_* settings from .pipeline-config.yaml. Removing these settings enables the configured DevSecOps checks for production.

    The pipeline includes the following security checks:

    Security checkPipeline stageTool or methodWhat the check does
    Secrets detectioncode-checks before the buildIBM detect-secretsDetects credentials or other potential secrets committed to the source code.
    Docker build secretscode-build during the buildDocker secret mountsProvides build credentials without storing the credentials in container image layers.
    Vulnerability scancode-build after the image pushTwistlock (Prisma Cloud)Detects known Common Vulnerabilities and Exposures (CVEs) in operating system packages and Python dependencies.
    Compliance checkscode-checksIBM DevSecOps commonsRuns configured license, Center for Internet Security (CIS) benchmark, and policy checks.
    • Secrets detection

      The code-checks task runs detect-secrets.sh before the image build. If the script detects a potential secret, the script stops the pipeline.

      #!/usr/bin/env bash
      # detect-secrets.sh
      
      detect-secrets scan --all-files --exclude-files '\.git/.*' > .secrets.baseline
      
      FINDINGS_COUNT=$(python3 -c "
      import json
      baseline = json.load(open('.secrets.baseline'))
      results = baseline.get('results', {})
      print(sum(len(v) for v in results.values()))
      ")
      
      if [[ "$FINDINGS_COUNT" -gt 0 ]]; then
        echo "ERROR: Potential secrets detected ($FINDINGS_COUNT finding(s))"
        detect-secrets audit .secrets.baseline
        exit 1
      fi
      
      echo "No secrets detected. Scan passed."
      
    • Docker build secrets

      Use Docker build secrets for credentials that the Docker build requires. Docker makes the secret available to the build command without copying the secret into the Dockerfile.

      For example:

      RUN --mount=type=secret,id=github_token \
          GITHUB_TOKEN=$(cat /run/secrets/github_token) \
          pip install --no-cache-dir -r requirements.txt
      
    • Container image vulnerability scan

      After the pipeline pushes an amd64 image to IBM Cloud Container Registry, the scan-artifact step runs the configured Twistlock (Prisma Cloud) vulnerability scan. The scan-artifact step uses the artifact metadata that the save_artifact function registered in Step 5.

      The scan-artifact log includes vulnerability counts by severity. For example:

      === Image scan results for icr.io/<your-namespace>/<your-image>@sha256:... (amd64) ===
      (C)ritical|(H)igh|(M)edium|(L)ow|(O)ther|(U)nspecified|(T)otal
      C:0|H:0|M:4|L:12|O:0|U:0|T:16
      

      The scan output also provides details about individual vulnerabilities. Review the findings and resolve or triage relevant vulnerabilities before promoting the image.

      The .pipeline-config.yaml file enables scan-artifact for amd64 and disables the step for s390x with when: 'false'. The pipeline saves the s390x image digest so that the s390x image can be scanned separately.

    • Compliance checks

      The compliance-checks step in the code-checks task runs the compliance checks configured for the IBM DevSecOps toolchain. Review the compliance results in the pipeline logs and resolve failed checks before promoting the application.

      Note: The development configuration uses DEVSECOPS_SKIP_* settings to skip selected DevSecOps functions. Remove the required DEVSECOPS_SKIP_* settings before you use the pipeline for production.

Summary

In this tutorial, you built a production-ready continuous integration and continuous delivery (CI/CD) pipeline for an agentic AI application. The pipeline includes:

  • Multi-architecture Docker builds for x86 (amd64) and IBM Z (s390x).
  • Model selection for MCP and Spyre deployment variants.
  • Automated integration tests that validate AI agent tool selection.
  • Versioned test results stored through Git commits.
  • Validated container images pushed to IBM Cloud Container Registry with artifact metadata.
  • Security and compliance checks integrated into the IBM DevSecOps pipeline.

The CI/CD pipeline provides a consistent process for building, testing, securing, and publishing agentic AI applications across multiple hardware architectures. The pipeline also provides the security, compliance, and validation controls required for production deployments.