mvn-release does not fail early (e.g. GIT_PRIVATE_KEY not set)
Describe the bug
The mvn-release job does not fail early if GIT_PRIVATE_KEY is not set.
Expected behavior
If the configuration is not correct the job should log an error directly fail, so the problem becomes clearly visible.
Actual behavior
An error is logged, but the pipeline continuous and fails later with an unclear error from maven.
Logs and/or screenshots
Running with gitlab-runner 17.9.0 (c4cbe9dd)
  on gitlab-runner-2.xxx.xxx 7ZVzTsw7, system ID: s_de5097fda0bc
Preparing the "docker" executor
00:08
Using Docker executor with image repository.xxx.xxx:8445/xxx/maven:jdk-21 ...
Authenticating with credentials from $DOCKER_AUTH_CONFIG
Pulling docker image repository.xxx.xxx:8445/xxx/maven:jdk-21 ...
Using docker image sha256:e52a82c56b0a4b6ab805761c7284e840d66b5d0b753217be4bfb6420487c7744 for repository.xxx.xxx:8445/xxx/maven:jdk-21 with digest repository.xxx.xxx:8445/xxx/maven@sha256:6c3b9241d671167971a3628bd7e462ac5310a364a126a637b3c6eeb93d9cd13b ...
Preparing environment
00:02
Running on runner-7zvztsw7-project-1254-concurrent-0 via gitlab-runner-2.xxx.xxx...
Getting source from Git repository
00:01
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in /builds/bibliotheken/testlib/.git/
Checking out 031575d3 as detached HEAD (ref is master)...
Removing .m2/
Removing target/
Skipping Git submodules setup
Restoring cache
00:01
Checking cache for master-maven-protected...
No URL provided, cache will not be downloaded from shared cache server. Instead a local version of cache will be extracted. 
Successfully extracted cache
Downloading artifacts
00:01
Downloading artifacts for mvn-build (314390)...
Downloading artifacts from coordinator... ok        host=git.xxx.xxx id=314390 responseStatus=200 OK token=64_mLjgCn
Executing "step_script" stage of the job script
00:06
Using docker image sha256:e52a82c56b0a4b6ab805761c7284e840d66b5d0b753217be4bfb6420487c7744 for repository.xxx.xxx:8445/xxx/maven:jdk-21 with digest repository.xxx.xxx:8445/xxx/maven@sha256:6c3b9241d671167971a3628bd7e462ac5310a364a126a637b3c6eeb93d9cd13b ...
$ # BEGSCRIPT # collapsed multi-line command
$ install_ca_certs "${CUSTOM_CA_CERTS:-$DEFAULT_CA_CERTS}"
$ eval_java_proxy_args
[INFO] Using Java proxy options (from env):    
$ cd ${MAVEN_PROJECT_DIR}
$ eval_mvn_settings_opt
$ git checkout -B "$CI_COMMIT_REF_NAME"
Switched to and reset branch 'master'
$ configure_scm_auth
[INFO] Preparing Git repository for release...
[ERROR] --- project scm.developerConnection is using SSH protocol but no SSH key configured.
[ERROR] --- Please either specify the $GIT_PRIVATE_KEY variable or change to https protocol with username/password credentials.
$ configure_commit_signing
[INFO] Preparing Git for commit signing...
[INFO] --- no signing key is configured; commits will not be signed.
$ maybe_set_version_from_git
$ if [ "${SEMREL_INFO_ON}" ] && [ "${MVN_SEMREL_RELEASE_DISABLED}" != "true" ] # collapsed multi-line command
$ mvn ${TRACE:+-X} $MAVEN_CLI_OPTS $mvn_settings_opt $java_proxy_args ${scm_auth_args} ${semrel_args} ${MAVEN_RELEASE_VERSION:+-DreleaseVersion="$MAVEN_RELEASE_VERSION"} ${MAVEN_RELEASE_SCM_COMMENT_PREFIX:+-DscmCommentPrefix="$MAVEN_RELEASE_SCM_COMMENT_PREFIX"} ${MAVEN_RELEASE_SCM_RELEASE_COMMENT:+-DscmReleaseCommitComment="$MAVEN_RELEASE_SCM_RELEASE_COMMENT"} ${MAVEN_RELEASE_SCM_DEV_COMMENT:+-DscmDevelopmentCommitComment="$MAVEN_RELEASE_SCM_DEV_COMMENT"} ${MAVEN_RELEASE_ARGS}
Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)
Maven home: /usr/share/maven
Java version: 21.0.2, vendor: Eclipse Adoptium, runtime: /opt/java/openjdk
Default locale: de_DE, platform encoding: UTF-8
OS name: "linux", version: "6.8.0-49-generic", arch: "amd64", family: "unix"
878 [INFO] Error stacktraces are turned on.
915 [INFO] Scanning for projects...
1143 [INFO] 
1143 [INFO] ------------------------< de.xxx.test:testlib >-------------------------
1143 [INFO] Building testlib 7.4.5-SNAPSHOT
1143 [INFO]   from pom.xml
1143 [INFO] --------------------------------[ jar ]---------------------------------
1165 [INFO] 
1166 [INFO] --- release:3.0.1:prepare (default-cli) @ testlib ---
1597 [INFO] starting prepare goal, composed of 17 phases: check-poms, scm-check-modifications, check-dependency-snapshots, create-backup-poms, map-release-versions, input-variables, map-development-versions, rewrite-poms-for-release, generate-release-poms, run-preparation-goals, scm-commit-release, scm-tag, rewrite-poms-for-development, remove-release-poms, run-completion-goals, scm-commit-development, end-release
1598 [INFO] 1/17 prepare:check-poms
1611 [INFO] 2/17 prepare:scm-check-modifications
1611 [INFO] Verifying that there are no local modifications...
1611 [INFO]   ignoring changes on: **/pom.xml.releaseBackup, **/pom.xml.next, **/pom.xml.tag, **/pom.xml.branch, **/release.properties, **/pom.xml.backup
1617 [INFO] Executing: /bin/sh -c cd '/builds/bibliotheken/testlib' && 'git' 'rev-parse' '--show-prefix'
1617 [INFO] Working directory: /builds/bibliotheken/testlib
1633 [INFO] Executing: /bin/sh -c cd '/builds/bibliotheken/testlib' && 'git' 'status' '--porcelain' '.'
1634 [INFO] Working directory: /builds/bibliotheken/testlib
1640 [WARNING] Ignoring unrecognized line: ?? .m2/
1641 [WARNING] Ignoring unrecognized line: ?? release.properties
1643 [INFO] 3/17 prepare:check-dependency-snapshots
1643 [INFO] Checking dependencies and plugins for snapshots ...
1644 [INFO] 4/17 prepare:create-backup-poms
1644 [INFO] Creating pom.xml backup with .releaseBackup suffix
1648 [INFO] 5/17 prepare:map-release-versions
1650 [INFO] 6/17 prepare:input-variables
1653 [INFO] 7/17 prepare:map-development-versions
1653 [INFO] 8/17 prepare:rewrite-poms-for-release
1654 [INFO] Transforming pom.xml testlib 'testlib'...
1725 [INFO] 9/17 prepare:generate-release-poms
1725 [INFO] Not generating release POMs
1726 [INFO] 10/17 prepare:run-preparation-goals
1726 [INFO] Executing goals 'clean verify'...
2825 [INFO] 925 [INFO] Scanning for projects...
2896 [INFO] 999 [INFO] 
2896 [INFO] 999 [INFO] ------------------------< de.xxx.test:testlib >-------------------------
2896 [INFO] 999 [INFO] Building testlib 7.4.5
2896 [INFO] 999 [INFO]   from pom.xml
2898 [INFO] 999 [INFO] --------------------------------[ jar ]---------------------------------
3017 [INFO] 1119 [INFO] 
3017 [INFO] 1119 [INFO] --- clean:3.2.0:clean (default-clean) @ testlib ---
3076 [INFO] 1179 [INFO] Deleting /builds/bibliotheken/testlib/target
3080 [INFO] 1183 [INFO] 
3080 [INFO] 1183 [INFO] --- git-commit-id:2.2.5:revision (get-the-git-infos) @ testlib ---
3795 [INFO] 1898 [INFO] 
3795 [INFO] 1898 [INFO] --- resources:3.3.1:resources (default-resources) @ testlib ---
3864 [INFO] 1967 [INFO] skip non existing resourceDirectory /builds/bibliotheken/testlib/src/main/resources
3865 [INFO] 1968 [INFO] 
3865 [INFO] 1968 [INFO] --- compiler:3.11.0:compile (default-compile) @ testlib ---
3956 [INFO] 2059 [INFO] Changes detected - recompiling the module! :source
3958 [INFO] 2061 [INFO] Compiling 1 source file with javac [debug target 21] to target/classes
4257 [INFO] 2359 [INFO] 
4257 [INFO] 2359 [INFO] --- resources:3.3.1:testResources (default-testResources) @ testlib ---
4260 [INFO] 2363 [INFO] Not copying test resources
4260 [INFO] 2363 [INFO] 
4260 [INFO] 2363 [INFO] --- compiler:3.11.0:testCompile (default-testCompile) @ testlib ---
4263 [INFO] 2366 [INFO] Not compiling test sources
4265 [INFO] 2366 [INFO] 
4265 [INFO] 2366 [INFO] --- surefire:3.2.2:test (default-test) @ testlib ---
4404 [INFO] 2506 [INFO] Tests are skipped.
4404 [INFO] 2507 [INFO] 
4404 [INFO] 2507 [INFO] --- jar:3.3.0:jar (default-jar) @ testlib ---
4541 [INFO] 2644 [INFO] Building jar: /builds/bibliotheken/testlib/target/testlib-7.4.5.jar
4588 [INFO] 2691 [INFO] ------------------------------------------------------------------------
4588 [INFO] 2691 [INFO] BUILD SUCCESS
4588 [INFO] 2691 [INFO] ------------------------------------------------------------------------
4590 [INFO] 2693 [INFO] Total time:  1.784 s
4590 [INFO] 2693 [INFO] Finished at: 2025-10-29T07:36:42+01:00
4590 [INFO] 2693 [INFO] ------------------------------------------------------------------------
4649 [INFO] 11/17 prepare:scm-commit-release
4649 [INFO] Checking in modified POMs...
4653 [INFO] Executing: /bin/sh -c cd '/builds/bibliotheken/testlib' && 'git' 'add' '--' 'pom.xml'
4653 [INFO] Working directory: /builds/bibliotheken/testlib
4660 [INFO] Executing: /bin/sh -c cd '/builds/bibliotheken/testlib' && 'git' 'rev-parse' '--show-prefix'
4660 [INFO] Working directory: /builds/bibliotheken/testlib
4664 [INFO] Executing: /bin/sh -c cd '/builds/bibliotheken/testlib' && 'git' 'status' '--porcelain' '.'
4664 [INFO] Working directory: /builds/bibliotheken/testlib
4670 [WARNING] Ignoring unrecognized line: ?? .m2/
4670 [WARNING] Ignoring unrecognized line: ?? pom.xml.releaseBackup
4670 [WARNING] Ignoring unrecognized line: ?? release.properties
4670 [INFO] Executing: /bin/sh -c cd '/builds/bibliotheken/testlib' && 'git' 'commit' '--verbose' '-F' '/tmp/maven-scm-1464695848.commit'
4670 [INFO] Working directory: /builds/bibliotheken/testlib
4681 [INFO] Executing: /bin/sh -c cd '/builds/bibliotheken/testlib' && 'git' 'symbolic-ref' 'HEAD'
4681 [INFO] Working directory: /builds/bibliotheken/testlib
4684 [INFO] Executing: /bin/sh -c cd '/builds/bibliotheken/testlib' && 'git' 'push' 'ssh:********@git.xxx.xxx/bibliotheken/testlib.git' 'refs/heads/master:refs/heads/master'
4685 [INFO] Working directory: /builds/bibliotheken/testlib
4715 [INFO] ------------------------------------------------------------------------
4715 [INFO] BUILD FAILURE
4715 [INFO] ------------------------------------------------------------------------
4716 [INFO] Total time:  3.820 s
4716 [INFO] Finished at: 2025-10-29T07:36:42+01:00
4716 [INFO] ------------------------------------------------------------------------
4717 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:3.0.1:prepare (default-cli) on project testlib: Unable to commit files
4717 [ERROR] Provider message:
4717 [ERROR] The git-push command failed.
4717 [ERROR] Command output:
4717 [ERROR] Host key verification failed.
4717 [ERROR] fatal: Could not read from remote repository.
4717 [ERROR] 
4717 [ERROR] Please make sure you have the correct access rights
4717 [ERROR] and the repository exists.
4717 [ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-release-plugin:3.0.1:prepare (default-cli) on project testlib: Unable to commit files
Provider message:
The git-push command failed.
Command output:
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:333)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
Caused by: org.apache.maven.plugin.MojoFailureException: Unable to commit files
Provider message:
The git-push command failed.
Command output:
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
    at org.apache.maven.plugins.release.PrepareReleaseMojo.prepareRelease (PrepareReleaseMojo.java:434)
    at org.apache.maven.plugins.release.PrepareReleaseMojo.execute (PrepareReleaseMojo.java:367)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
Caused by: org.apache.maven.shared.release.scm.ReleaseScmCommandException: Unable to commit files
Provider message:
The git-push command failed.
Command output:
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
    at org.apache.maven.shared.release.phase.AbstractScmCommitPhase.checkin (AbstractScmCommitPhase.java:190)
    at org.apache.maven.shared.release.phase.AbstractScmCommitPhase.performCheckins (AbstractScmCommitPhase.java:171)
    at org.apache.maven.shared.release.phase.AbstractScmCommitPreparationPhase.runLogic (AbstractScmCommitPreparationPhase.java:75)
    at org.apache.maven.shared.release.phase.AbstractScmCommitPhase.execute (AbstractScmCommitPhase.java:80)
    at org.apache.maven.shared.release.DefaultReleaseManager.prepare (DefaultReleaseManager.java:193)
    at org.apache.maven.shared.release.DefaultReleaseManager.prepare (DefaultReleaseManager.java:110)
    at org.apache.maven.plugins.release.PrepareReleaseMojo.prepareRelease (PrepareReleaseMojo.java:430)
    at org.apache.maven.plugins.release.PrepareReleaseMojo.execute (PrepareReleaseMojo.java:367)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
4720 [ERROR] 
4720 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
4721 [ERROR] 
4721 [ERROR] For more information about the errors and possible solutions, please read the following articles:
4721 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Cleaning up project directory and file based variables
ERROR: Job failed: exit code 1Context & Configuration
Sorry internal.
The issue was reproduced using:
- Version of the template: 5.2.0
- GitLab server(s): Self-managed v18.3
- GitLab runner(s): 17.9.0 with docker executor
Here is the .gitlab-ci.yml file:
include:
  - component: git.hkm.de/to-be-continuous/maven/gitlab-ci-maven@5.2.0
    inputs:
      deploy-enabled: true