镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

gpg: signing failed: Inappropriate ioctl for device #83

Description

@hengboy

I encountered a problem like the title.

name: Deploy the SNAPSHOT version to Maven Center

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
  push:
    branches: [ develop ]
  pull_request:
    branches: [ develop ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checkout source code
      - name: Checkout source code
        uses: actions/checkout@v2
      - name: Configure GPG Key
        run: |
          mkdir -p ~/.gnupg/
          printf "$MAVEN_GPG_PRIVATE_KEY" | base64 --decode > ~/.gnupg/private.key
          gpg --batch --import ~/.gnupg/private.key
        env:
          MAVEN_GPG_PRIVATE_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
      # Install Java 1.8
      - name: Install Java
        uses: actions/setup-java@master
        with:
          java-version: 1.8
          server-id: hengyu
          server-username: MAVEN_USERNAME # env variable for username in deploy
          server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy
          #gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
          #gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
      - name: Build with Maven
        run: mvn -B package --file pom.xml
      # Publish to Apache Maven Central
      - name: Publish to Apache Maven Central
        run: mvn deploy
        env:
          MAVEN_USERNAME: ${{ secrets.MAVEN_CENTER_USER_NAME }}
          MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTER_PASSWORD }}
          #MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

plugin config in pom.xml

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-gpg-plugin</artifactId>
    <version>${maven.gpg.plugin.version}</version>
    <executions>
        <execution>
            <id>sign-artifacts</id>
            <phase>verify</phase>
            <goals>
                <goal>sign</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Activity

  1. hengboy commented on Jul 24, 2020

    @hengboy
    Author

    If remove Configure GPG Key step,logs:

    creating settings.xml with server-id: hengyu; environment variables: username=$MAVEN_USERNAME, password=$MAVEN_CENTRAL_TOKEN, and gpg-passphrase=$MAVEN_GPG_PASSPHRASE
    writing /home/runner/.m2/settings.xml
    importing private key
    ##[error]The process '/usr/bin/gpg' failed with exit code 2
    
  2. bissim commented on Aug 14, 2020

    @bissim

    Hello @hengboy ,
    As stated in #43 and #91, all you have to do to solve the ioctl issue is to add this configuration to Maven GPG plugin in your POM.
    Also, you don't need your 'Configure GPG Key' step since this action now deals with it.

  3. bjansen commented on Feb 2, 2021

    @bjansen

    Link is broken, FTR here's the piece of configuration to add to the Maven GPG plugin:

                <configuration>
                  <!-- Prevent gpg from using pinentry programs -->
                  <gpgArguments>
                    <arg>--pinentry-mode</arg>
                    <arg>loopback</arg>
                  </gpgArguments>
                </configuration>
    
  4. dmitry-shibanov commented on Feb 15, 2021

    @dmitry-shibanov
    Contributor

    Hello, everyone. I'm closing this issue, because documentation was updated in terms of this pull request. If you have any concerns feel free to reopen the issue.
    Thanks @bissim @bjansen for help with providing solution and related links.

  5. Stromner commented on Mar 6, 2021

    @Stromner

    My noggin can't get this to work for one of my project, I have added the config above and my gpg plugin in the pom looks like this:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <executions>
                    <execution>
                        <id>sign-artifacts</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <gpgArguments>
                        <arg>--pinentry-mode</arg>
                        <arg>loopback</arg>
                    </gpgArguments>
                </configuration>
            </plugin>
    

    And my gpg workflow step like this:

    steps:    
    - uses: actions/checkout@v2
    - name: Set up Repository
      uses: actions/setup-java@v1
      with:
        java-version: 15
        server-id: ossrh
        server-username: MAVEN_USERNAME
        server-password: MAVEN_PASSWORD
        gpg-private-key: GPG_PRIVATE_KEY
        gpg-passphrase: GPG_PASSPHRASE
      env:
        MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
        MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
        GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
        GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
    

    GPG_PRIVATE_KEY I exported with gpg --armor --export-secret-keys
    All I ever get is "Error: The process '/usr/bin/gpg' failed with exit code 2" no matter how I twist and turn this

  6. bessonm commented on Apr 22, 2021

    @bessonm

    @Stromner

    Did you try not using an env variable for the GPG_PRIVATE_KEY ?
    Like so :

    - uses: actions/checkout@v2
    - name: Set up Repository
      uses: actions/setup-java@v1
      with:
        java-version: 15
        server-id: ossrh
        server-username: MAVEN_USERNAME
        server-password: MAVEN_PASSWORD
        gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
        gpg-passphrase: GPG_PASSPHRASE
      env:
        MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
        MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
        GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
    
  7. Stromner commented on Apr 22, 2021

    @Stromner

    Ah thanks! That did the work :)

  8. added a commit that references this issue on May 12, 2021
  9. rahman6848 commented on Mar 25, 2022

    @rahman6848

    @Stromner

    Did you try not using an env variable for the GPG_PRIVATE_KEY ? Like so :

    - uses: actions/checkout@v2
    - name: Set up Repository
      uses: actions/setup-java@v1
      with:
        java-version: 15
        server-id: ossrh
        server-username: MAVEN_USERNAME
        server-password: MAVEN_PASSWORD
        gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
        gpg-passphrase: GPG_PASSPHRASE
      env:
        MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
        MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
        GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
    

    This is working
    Thanks @bessonm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions