2

I'm trying to deploy my local artifact into the nexus staging repository but the task is failing with the below error.

gpg: no default secret key: No secret key
gpg: signing failed: No secret key
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.886 s
[INFO] Finished at: 2021-06-14T14:12:29+05:30
[INFO] -----------------------------------------

Steps I followed.

  1. I have installed the gpg using brew.
  2. gpg version is
      gpg (GnuPG) 2.3.1
      libgcrypt 1.9.3
    
  3. I have added the setting.xml to .m2 directory path - ~/.m2/settings.xml
  4. Here is the my settings.xml file
<settings>
<servers>
 <server>
   <id>ossrh</id>
   <username>$name</username>
   <password>$password</password>
 </server>
</servers>
<profiles>
 <profile>
   <id>ossrh</id>
   <activation>
     <activeByDefault>true</activeByDefault>
   </activation>
   <properties>
     <gpg.executable>gpg</gpg.executable>
     <gpg.passphrase>$passphrase</gpg.passphrase>
   </properties>
 </profile>
</profiles>
</settings>

  1. I have imported the .asc file using gpg --import file.asc

  2. when I run gpg --list-keys command, I'm able to see the pub, uid & sub key values.

  3. My current mvn version is Apache Maven 3.6.3

  4. I have updated my project module pom.xml with the below values

            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <version>1.6.7</version>
                <extensions>true</extensions>
                <configuration>
                    <serverId>ossrh</serverId>
                    <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>1.5</version>
                <executions>
                    <execution>
                        <id>sign-artifacts</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                        <configuration>
                            <!-- This is necessary for gpg to not try to use the pinentry programs -->
                            <gpgArguments>
                                <arg>--pinentry-mode</arg>
                                <arg>loopback</arg>
                            </gpgArguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>


Can you please someone help what's wrong with my configuration? Why I am getting the no default secret key: No secret key error?

I have referred this issue but still no luck

How to deal with Gnupg error: gpg: no default secret key: No secret key gpg: [stdin]: clearsign failed: No secret key?

1 Answers1

2

When I try to list the secrets it was not showing my secrets gpg --list-secret.

Actually, When I try to list keys using gpg --list-keys it was showing the values. I have assumed the ASC file is imported fine without any issue. But actually, it's not imported the ASC file properly, I missed one step entering the password while importing the ASC file. I got to know by executing gpg --list-secret command.

When you execute the gpg --list-secret & gpg --list-keys command it should show values then only the ASC file is imported correctly.