Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gpg: signing failed: Inappropriate ioctl for device #83

Closed
hengboy opened this issue Jul 23, 2020 · 8 comments
Closed

gpg: signing failed: Inappropriate ioctl for device #83

hengboy opened this issue Jul 23, 2020 · 8 comments
Assignees

Comments

@hengboy
Copy link

hengboy commented Jul 23, 2020

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>
@hengboy
Copy link
Author

hengboy commented Jul 24, 2020

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

@bissim
Copy link

bissim commented Aug 14, 2020

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.

@bjansen
Copy link

bjansen commented Feb 2, 2021

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>

@dmitry-shibanov
Copy link
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.

@Stromner
Copy link

Stromner commented Mar 6, 2021

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

@bessonm
Copy link

bessonm commented Apr 22, 2021

@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 }}

@Stromner
Copy link

Ah thanks! That did the work :)

@rahman6848
Copy link

@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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants