Chapter 7. Configuring custom Maven mirrors


OpenShift Serverless Logic uses Maven Central by default to resolve Maven artifacts during workflow builds. The provided builder and development images include all required Java libraries to run workflows, but in certain scenarios, such as when you add a custom Quarkus extension, you must download the additional dependencies from Maven Central.

In environments with restricted or firewalled network access, direct access to Maven Central might not be available. In such cases, you can configure the workflow containers to use a custom Maven mirror, such as an internal company registry or repository manager.

You can configure a custom Maven mirror at different levels as follows:

  • Per workflow build by updating the SonataFlowBuild custom resource.
  • At the platform level by updating the SonataFlowPlatform custom resource.
  • For development mode deployments by editing the SonataFlow custom resource.
  • When building custom images externally with the builder image

7.1. Adding a Maven mirror when building workflows

You can configure a Maven mirror by setting the MAVEN_MIRROR_URL environment variable in the SonataFlowBuild or SonataFlowPlatform custom resources (CR).

Note

The recommended approach is to update the SonataFlowPlatform CR. This ensures the mirror configuration is propagated automatically to all workflow builds within the platform scope.

Prerequisites

  • You have OpenShift Serverless Logic Operator installed on your cluster.
  • You have created your OpenShift Serverless Logic project.
  • You have access to a OpenShift Serverless Logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
  • You have access to a custom Maven mirror or internal repository.

Procedure

  1. Edit the SonataFlowPlatform CR to configure a Maven mirror for all workflow builds in a namespace, as shown in the following example:

    Example of Maven mirror configuration in a SonataFlowPlatform CR

    apiVersion: sonataflow.org/v1alpha08
    kind: SonataFlowPlatform
    metadata:
      name: my-platform
    spec:
      build:
        template:
          envs:
            - name: MAVEN_MIRROR_URL
              value: http://my.company.registry.local
    Copy to Clipboard Toggle word wrap

    This configuration applies to all workflow builds in the same namespace that use the preview profile. When a workflow builder instance runs, it updates the internal Maven settings file to use the specified mirror as the default for external locations such as Maven Central.

  2. Optional: If you need a specific configuration for a single workflow build, create the SonataFlowBuild CR before creating the corresponding SonataFlow CR. The SonataFlowBuild and SonataFlow CRs must have the same name.

    Example of Maven mirror configuration in a SonataFlowBuild CR

    apiVersion: sonataflow.org/v1alpha08
    kind: SonataFlowBuild
    metadata:
      name: my-workflow 
    1
    
      annotations:
        sonataflow.org/restartBuild: "true" 
    2
    
    spec:
      # suppressed for brevity
      envs:
        - name: MAVEN_MIRROR_URL 
    3
    
          value: http://my.company.registry.local
    Copy to Clipboard Toggle word wrap

    1
    The SonataFlowBuild CR must have the same name as the corresponding SonataFlow CR.
    2
    The sonataflow.org/restartBuild: "true" annotation forces the existing build to restart with the new configuration.
    3
    The MAVEN_MIRROR_URL environment variable specifies the custom Maven mirror.
    Note

    You can use the SonataFlowBuild CR configuration only when you require workflow-specific behavior, for example, debugging. For general use, configure the SonataFlowPlatform CR instead.

You can configure a Maven mirror for workflows that run in dev mode by adding the MAVEN_MIRROR_URL environment variable to the SonataFlow custom resource (CR).

Prerequisites

  • You have created your OpenShift Serverless Logic project.
  • You have access to a OpenShift Serverless Logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
  • You have a workflow deployed in dev profile.
  • You have access to a custom Maven mirror or internal repository.

Procedure

  • Edit the SonataFlow CR to include the Maven mirror configuration as shown in the following example:

    Example of Maven mirror configuration on SonataFlow CR

    apiVersion: sonataflow.org/v1alpha08
    kind: SonataFlow
    metadata:
      name: greeting
      annotations:
        sonataflow.org/description: Greeting example on k8s!
        sonataflow.org/version: 0.0.1
        sonataflow.org/profile: dev
    spec:
      podTemplate:
        container:
          env:
            - name: MAVEN_MIRROR_URL 
    1
    
              value: http://my.company.registry.local
      flow: #suppressed for brevity
    Copy to Clipboard Toggle word wrap

    1
    The MAVEN_MIRROR_URL variable specifies the custom Maven mirror.
Note

Only workflows deployed with the dev profile can use Maven mirrors. Other deployment models run compiled code only, so they do not need to connect to a Maven registry.

7.3. Configuring a Maven mirror on a custom image

You can configure a Maven mirror for workflows that run in dev mode by adding the MAVEN_MIRROR_URL environment variable to the SonataFlow custom resource (CR).

Prerequisites

  • You have created your OpenShift Serverless Logic project.
  • You have access to a OpenShift Serverless Logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
  • You have access to a dockerfile or container build context that uses the SonataFlow Builder image.
  • You have access to a custom Maven mirror or internal repository.

Procedure

  1. Set the Maven mirror as an environment variable in the Dockerfile as shown in the following example:

    Example of custom container file with Maven mirror set as an environment variable

    FROM docker.io/apache/incubator-kie-sonataflow-builder:main AS builder
    
    # Content suppressed for brevity
    
    # The Maven mirror URL set as an env var during the build process
    ENV MAVEN_MIRROR_URL=http://my.company.registry.local
    Copy to Clipboard Toggle word wrap

    The ENV directive ensures that all builds with this Dockerfile automatically use the specified Maven mirror.

  2. Set the Maven mirror as a build-time argument in the Dockerfile as shown in the following example:

    Example of custom container file with Maven mirror set as an argument

    FROM docker.io/apache/incubator-kie-sonataflow-builder:main AS builder
    
    # Content suppressed for brevity
    
    # The Maven mirror URL passed as a build argument during the build process
    ARG MAVEN_MIRROR_URL
    Copy to Clipboard Toggle word wrap

    The ARG directive allows you to pass the Maven mirror value dynamically at build time.

Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat