Я пытаюсь создать конвейер, который мог бы выполнять mvn clean deploy
с gpg:sign
на этапе verify
. Я использую Jenkins 2.222.1 и gpg 2.2.4 . Я создал пару ключей, и все вроде нормально. Тем не менее, во время сборки произошло нечто странное: Maven не может найти файл pom, который я хочу подписать, пока он находится в правильном репо. Я попытался переместить /.gnupg
в JENKINS_HOME
и сделать chmown
, создать файл конфигурации в Jenkins, добавить новые учетные данные с секретными файлами и секретным текстом, но ничего не работает ... Я часами искал, чтобы устраните следующую ошибку, и я не знаю, что делать дальше.
[INFO] --- maven-gpg-plugin:1.6:sign (sign-artifacts) @ organization ---
[DEBUG] Using mirror nexus (http://192.168.1.8:8081/repository/maven-public/) for snapshots (http://snapshots.maven.codehaus.org/maven2).
[DEBUG] Using mirror nexus (http://192.168.1.8:8081/repository/maven-public/) for central (http://repo1.maven.org/maven2).
[DEBUG] Using mirror nexus (http://192.168.1.8:8081/repository/maven-public/) for codehaus.snapshots (http://snapshots.repository.codehaus.org).
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=1599951, ConflictMarker.markTime=439251, ConflictMarker.nodeCount=40, ConflictIdSorter.graphTime=192838, ConflictIdSorter.topsortTime=47103, ConflictIdSorter.conflictIdCount=18, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=2611269, ConflictResolver.conflictItemCount=40, DefaultDependencyCollector.collectTime=176950559, DefaultDependencyCollector.transformTime=4939565}
[DEBUG] org.apache.maven.plugins:maven-gpg-plugin:jar:1.6:
[DEBUG] org.apache.maven:maven-plugin-api:jar:2.2.1:compile
[DEBUG] org.apache.maven:maven-project:jar:2.2.1:compile
[DEBUG] org.apache.maven:maven-settings:jar:2.2.1:compile
[DEBUG] org.apache.maven:maven-profile:jar:2.2.1:compile
[DEBUG] org.apache.maven:maven-artifact-manager:jar:2.2.1:compile
[DEBUG] backport-util-concurrent:backport-util-concurrent:jar:3.1:compile
[DEBUG] org.apache.maven:maven-plugin-registry:jar:2.2.1:compile
[DEBUG] org.codehaus.plexus:plexus-interpolation:jar:1.11:compile
[DEBUG] org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile
[DEBUG] junit:junit:jar:3.8.1:compile
[DEBUG] classworlds:classworlds:jar:1.1-alpha-2:compile
[DEBUG] org.apache.maven:maven-artifact:jar:2.2.1:compile
[DEBUG] org.apache.maven:maven-repository-metadata:jar:2.2.1:compile
[DEBUG] org.apache.maven:maven-model:jar:2.2.1:compile
[DEBUG] org.codehaus.plexus:plexus-utils:jar:3.0.20:compile
[DEBUG] org.sonatype.plexus:plexus-sec-dispatcher:jar:1.4:compile
[DEBUG] org.sonatype.plexus:plexus-cipher:jar:1.4:compile
[DEBUG] Created new class realm plugin>org.apache.maven.plugins:maven-gpg-plugin:1.6
[DEBUG] Importing foreign packages into class realm plugin>org.apache.maven.plugins:maven-gpg-plugin:1.6
[DEBUG] Imported: < maven.api
[DEBUG] Populating class realm plugin>org.apache.maven.plugins:maven-gpg-plugin:1.6
[DEBUG] Included: org.apache.maven.plugins:maven-gpg-plugin:jar:1.6
[DEBUG] Included: backport-util-concurrent:backport-util-concurrent:jar:3.1
[DEBUG] Included: org.codehaus.plexus:plexus-interpolation:jar:1.11
[DEBUG] Included: junit:junit:jar:3.8.1
[DEBUG] Included: org.codehaus.plexus:plexus-utils:jar:3.0.20
[DEBUG] Included: org.sonatype.plexus:plexus-sec-dispatcher:jar:1.4
[DEBUG] Included: org.sonatype.plexus:plexus-cipher:jar:1.4
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-gpg-plugin:1.6:sign from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-gpg-plugin:1.6, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@55054057]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-gpg-plugin:1.6:sign' with basic configurator -->
[DEBUG] (f) ascDirectory = /var/lib/jenkins/workspace/eature_cidemo-152-sign-artifacts/target/gpg
[DEBUG] (f) defaultKeyring = true
[DEBUG] (f) interactive = false
[DEBUG] (f) keyname = ****
[DEBUG] (f) passphrase = ****
[DEBUG] (f) passphraseServerId = gpg.passphrase
[DEBUG] (f) project = MavenProject: cidemo:organization:1.0.7-SNAPSHOT @ /var/lib/jenkins/workspace/eature_cidemo-152-sign-artifacts/pom.xml
[DEBUG] (f) settings = org.apache.maven.execution.SettingsAdapter@1bbae752
[DEBUG] (f) skip = false
[DEBUG] (f) useAgent = true
[DEBUG] -- end configuration --
[DEBUG] Generating signature for /var/lib/jenkins/workspace/eature_cidemo-152-sign-artifacts/target/organization-1.0.7-SNAPSHOT.pom
gpg: échec de la signature : Aucun fichier ou dossier de ce type
gpg: signing failed: Aucun fichier ou dossier de ce type
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.096 s
[INFO] Finished at: 2020-05-28T16:38:38+02:00
[INFO] ------------------------------------------------------------------------
[INFO] [jenkins-event-spy] Generated /var/lib/jenkins/workspace/eature_cidemo-152-sign-artifacts@tmp/withMaven63891365/maven-spy-20200528-163837-6913968946439688367226.log
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-gpg-plugin:1.6:sign (sign-artifacts) on project organization: Exit code: 2 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-gpg-plugin:1.6:sign (sign-artifacts) on project organization: Exit code: 2
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Exit code: 2
at org.apache.maven.plugin.gpg.GpgSigner.generateSignatureForFile (GpgSigner.java:167)
at org.apache.maven.plugin.gpg.AbstractGpgSigner.generateSignatureForArtifact (AbstractGpgSigner.java:205)
at org.apache.maven.plugin.gpg.GpgSignAttachedMojo.execute (GpgSignAttachedMojo.java:176)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Вот мой пом, даже если он очень простой:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<keyname>keyname</keyname>
<passphrase>passphrase</passphrase>
</configuration>
</execution>
</executions>
</plugin>
И мой Jenkinsfile:
pipeline {
agent {
label "master"
}
stages {
stage('Clean & Prepare Release') {
steps {
withMaven(maven: 'Maven 3.6.0', mavenSettingsConfig: 'jenkinsToNexus') {
sh """mvn -B -U -X -e clean deploy"""
}
}
}
}
}