Resolving Maven 401 Unauthorized errors with private repositories in AEM as a Cloud Service

This article explains how to resolve 401 Unauthorized errors in Adobe Experience Manager as a Cloud Service (AEMaaCS) when integrating a private Maven repository with Cloud Manager. Maven builds fail during dependency resolution when repository credentials are not applied correctly because of configuration placement issues or incorrect environment variable settings. To resolve the issue, verify the .cloudmanager configuration, Maven settings, and pipeline variables to ensure successful authentication.

Description description

Environment

Adobe Experience Manager as a Cloud Service (AEMaaCS) (all versions)

Issue/Symptoms

  • Cloud Manager build logs show 401 Unauthorized errors when resolving dependencies from a private Maven repository.
  • Artifacts from the private repository cannot be downloaded during the build.
  • The Maven settings.xml and pipeline configuration files are not located at the repository root.
  • The pipeline environment variable for the repository token may be configured incorrectly or be truncated.

Root cause

Adobe Experience Manager (AEM) Cloud Manager reads the .cloudmanager folder only from the root of the repository. If configuration files, such assettings.xml and pipeline YAML files, are placed in a submodule or nested directory, Maven credentials are not applied, resulting in authentication failures.

Resolution resolution

Follow the steps below to resolve the issue:

  1. Ensure that the .cloudmanager folder, including maven/settings.xml and any pipeline YAML files, is located at the root of the main repository and not inside a submodule or nested directory.
  2. Commit and push the changes to the default branch of the repository.
  3. Regenerate the pipeline by closing and reopening the relevant pull request or by pushing a new commit. This forces Cloud Manager to pick up the updated configuration.
  4. In settings.xml, verify that the <server><id> value matches the <repository><id>value in pom.xml. For example, use a consistent identifier such as private-artifactory.
  5. Ensure that the pipeline environment variable containing the repository token, such as PRIVATE_REPO_TOKEN, is configured correctly and is accessible to the pipeline. If the token exceeds the character limit for secret variables, use a regular environment variable as a workaround and evaluate the associated security implications.
  6. To enable verbose Maven logging for troubleshooting, add the -X flag to the Maven build command in the pipeline configuration, for example in pr_pipelines.yml.
  7. Re-run the pipeline and monitor the build logs for authentication errors. If 401 Unauthorized errors continue, review the token value for truncation or unintended whitespace.
recommendation-more-help
experience-cloud-kcs-help-kbarticles