Where to keep a GPG secret key for Jenkins running on Windows? - maven

I am attempting to release my artifacts to the OSS Sonatype Nexus Server using Jenkins. But I get the following error when the signing is attempted for the artifacts. I have generated my gpg keys and have it under C:/Users/Sara/AppData/Roaming/gnupg folder on my Windows machine. From another question Where to keep a GPG secret key for a Maven project in CI environment?, I could see the answer is for a Unix based environment. Can anybody shed light on where to place the secret keys for jenkins in a windows environment?
[INFO] --- maven-gpg-plugin:1.1:sign (sign-artifacts) # StudentEnrollmentWithREST ---
gpg: no default secret key: secret key not available
gpg: signing failed: secret key not available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:27.647s
[INFO] Finished at: Mon Jan 20 12:12:27 CST 2014
[INFO] Final Memory: 22M/53M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-gpg-plugin:1.1:sign (sign-artifacts) on project StudentEnrollmentWithREST: Exit code: 2 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:45.118s
[INFO] Finished at: Mon Jan 20 12:12:33 CST 2014
[INFO] Final Memory: 8M/19M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.1:prepare (default-cli) on project StudentEnrollmentWithREST: Maven execution failed, exit code: '1' -> [Help 1]
[JENKINS] Archiving C:\Program Files (x86)\Jenkins\workspace\Upload REST Release Artifacts\pom.xml to com.github.elizabetht/StudentEnrollmentWithREST/1.3-SNAPSHOT/StudentEnrollmentWithREST-1.3-SNAPSHOT.pom
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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
channel stopped
Skipping Cobertura coverage report as build was not UNSTABLE or better ...
Finished: FAILURE

According to the gpg:sign documentation.
The ${gpg.homedir} which defaults to ~/.gnupg or %APPDATA%/gnupg should be finding your keyring in the folder you have currently described.
The files named pubring.gpg and secring.gpg by default can also be configured.
Perhaps the issue is finding the right key, maven uses the 'default key' unless otherwise configured.
The first key in the keyring is the default.
Choosing a key - this might go in a project/parent or settings, or even on commandline
<properties>
<gpg.keyname>C78F3CC4</gpg.keyname>
</properties>
Some other configuration is more likely to be 'per host' , maybe a profile in your settings.xml
<profile>
<id>gpg-release</id>
<properties>
<gpg.passphrase>...</gpg.passphrase>
<gpg.useagent>true</gpg.useagent>
<!--
<gpg.defaultKeyring>false</gpg.defaultKeyring>
<gpg.homedir>/private/.../.gnupg</gpg.homedir>
<gpg.publicKeyring>/private/.../.gnupg/pubring.gpg</gpg.publicKeyring>
<gpg.secretKeyring>/private/.../.gnupg/secring.gpg</gpg.secretKeyring>
-->
</properties>
</profile>
If you use the command line with OSS Sonatype rather than in your settings xml, then it will need further gymnastics.
From OSS Sonatype documentation.
Because maven-release-plugin will start a new Maven instance, -Dgpg.passphrase=PASSPHRASE won't work in this case, instead, you should use
mvn release:perform -Darguments=-Dgpg.passphrase=PASSPHRASE
[and configure in the project pom usage of ${arguments}]

Adding the profile section as shown below in settings.xml worked
<profile>
<id>gpg-release</id>
<properties>
<gpg.passphrase>password</gpg.passphrase>
<gpg.useagent>true</gpg.useagent>
<gpg.defaultKeyring>false</gpg.defaultKeyring> <gpg.homedir>C:/Users/User/AppData/Roaming/gnupg</gpg.homedir> <gpg.publicKeyring>C:/Users/User/AppData/Roaming/gnupg/pubring.gpg</gpg.publicKe‌​yring> <gpg.secretKeyring>C:/Users/User/AppData/Roaming/gnupg/secring.gpg</gpg.secre‌​tKeyring> </properties>
</profile>

You can save your GPG key in Jenkins in the manage Jenkins/configure-system. There is an RPM signing key section where you can add your GPG keys. Before you should have added required plugin in Jenkins

Related

Error while storing artifacts to Nexus through Jenkins

I was trying to store artifacts to Nexus.
When trying using the Command line using mvn clean package deploy the Build Sucess and Artifacts are stored in the desired Nexus repository.
Now trying the same code With Jenkins with Goals and Option clean package deploy till package it is done successfully and after that, it shows error
[INFO] --- maven-deploy-plugin:2.8.2:deploy (default-deploy) # maven-webapp ---
[INFO] Downloading from deployment: http://localhost:8081/repository/sample-snap/com/infy/demos/maven-webapp/0.0.1-SNAPSHOT/maven-metadata.xml
[WARNING] Could not transfer metadata com.infy.demos:maven-webapp:0.0.1-SNAPSHOT/maven-metadata.xml from/to deployment (http://localhost:8081/repository/sample-snap/): Not authorized
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.173 s
[INFO] Finished at: 2019-11-25T12:22:12+05:30
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project maven-webapp: Failed to retrieve remote metadata com.infy.demos:maven-webapp:0.0.1-SNAPSHOT/maven-metadata.xml: Could not transfer metadata com.infy.demos:maven-webapp:0.0.1-SNAPSHOT/maven-metadata.xml from/to deployment (http://localhost:8081/repository/sample-snap/): Not authorized -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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
[JENKINS] Archiving C:\Program Files (x86)\Jenkins\workspace\maven-demo\pom.xml to com.infy.demos/maven-webapp/0.0.1-SNAPSHOT/maven-webapp-0.0.1-SNAPSHOT.pom
[JENKINS] Archiving C:\Program Files (x86)\Jenkins\workspace\maven-demo\target\maven-webapp.war to com.infy.demos/maven-webapp/0.0.1-SNAPSHOT/maven-webapp-0.0.1-SNAPSHOT.war
channel stopped
Finished: FAILURE
Already configure Nexus Repository Manager Servers in the Jenkins and tested the connection showing Nexus Repository Manager 3.x connection succeeded.
Using Nexus OSS 3.19.1-01.

maven dependency versionioning issue

I am trying to add the dependency as below to use the version mentioned or the latest.I am expecting maven to take the dependencies with version >= 0.0.1 but maven is failing to resolve the dependencies.If i mention the exact version the dependencies are getting downloaded.
Iam using maven 3.5
<dependency>
<groupId>com.company.esb.fuse</groupId>
<artifactId>common</artifactId>
<version>[0.0.1,)</version>
<scope>provided</scope>
</dependency>
maven logs:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building source out Write 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.401 s
[INFO] Finished at: 2018-01-22T17:26:21+01:00
[INFO] Final Memory: 14M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project source: Could not resolve dependencies for project com.company.esb.source.out:source:war:0.0.1-SNAPSHOT: Failed to collect dependencies at com.company.esb.fuse:common:jar:[0.0.1,): No versions available for com.company.esb.fuse:common:jar:[0.0.1,) within specified range -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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/DependencyResolutionException
Above details are not sufficient to determine the exact problem. But according to your maven logs,
No versions available for com.company.esb.fuse:common:jar:[0.0.1,)
Note that it says com.company, not com.compant as you typed in this question.
check your pom.xml first and put correct groupId.
If you are still getting the same error, check your local .m2 folder and confirm that you have at least one artifact with a version which is in the declared range.
UPDATE : the error may be in the maven-metadata file. check maven-metadata-local.xml file placed inside .m2/repository/com/company/esb/fuse/common. All versions should be there under <versions> tag.

Cannot install grails plugin to local or remote maven repo

I'm trying to install my grails plugin to local or remote repo, but when I run
mvn install -DskipTests I'd always get this message:
|Loading Grails 2.3.9
|Configuring classpath
|Running pre-compiled script
.
|Environment set to development
................................
|Packaging Grails application
................................
|Plugin packaged grails-mcplugin-license-0.4.3.zip
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.532s
[INFO] Finished at: Thu Jun 05 14:12:03 MSK 2014
[INFO] Final Memory: 13M/153M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.grails:grails-maven-plugin:2.4.0:package-plugin (default->package-plugin) on project McpluginLicense: Unable to copy the plugin ZIP to the target >directory -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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
I'm using grails-maven plugin right from github because it solves this problem -https://jira.grails.org/browse/MAVEN-237, can it be related to my issue? How do I track it down? I tried to look at maven debug output but I didn't notice anything that can help
I suggest installing the release plugin and then running
grails maven-install
The documentation is here.

How to Resolve Maven CDK Plugin Dependency Error when Following Cloudera Demo

I'm trying to following along with the Cloudera CDK-examples Demo (https://github.com/cloudera/cdk-examples/tree/master/demo); this is part of a conference (Big Data Techon 2013) session by Cloudera on Hadoop App development
However, I am unable to get mvn install to build successfully. I keep getting warnings like this
[WARNING] The POM for com.cloudera.cdk:cdk-maven-plugin:jar:0.8.1-SNAPSHOT is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for com.cloudera.cdk:cdk-maven-plugin:0.8.1-SNAPSHOT: Plugin com.cloudera.cdk:cdk-maven-plugin:0.8.1-SNAPSHOT or one of its dependencies could not be resolved: Failed to read artifact descriptor for com.cloudera.cdk:cdk-maven-plugin:jar:0.8.1-SNAPSHOT
and then it fails with these errors... I tried to troubleshoot on my own using Google and the link mentioned in the error, but it was to no avail
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.263s
[INFO] Finished at: Tue Oct 15 15:21:23 PDT 2013
[INFO] Final Memory: 6M/57M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'cdk' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/home/cloudera/.m2/repository), cdh.repo (https://repository.cloudera.com/artifactory/cloudera-repos), central (http://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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/NoPluginFoundForPrefixException
Looking at the pom.xml here, I see that the snapshots is disabled for both repository and pluginRepository.
You could try to enable it and try building.

Getting errors while trying to build a skeleton Mule Cloud Connector..

So I'm following the tutorials online to build a cloud connector but I can't even get the skeleton to be generated!
tutorial 1
tutorial 2
I get the following error, using the create-cloud-connector.bat script given by the Mule Cloud Connect Development Kit
> [INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.170s
[INFO] Finished at: Mon Jul 30 13:00:57 EDT 2012
[INFO] Final Memory: 7M/122M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate (default-cli) on project standalone-pom: The desired archetype does not exist (org.mule.tools:mule-cloud-connector-archetype:2.0.16) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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/MojoFailureException
what are some things I could be doing wrong?
I updated the Maven settings.xml file
the first question is " Name of the cloud service the new connector uses
[default: ] " can I enter anything there? (or does it have to be like an existing service? what if I'm building one that doesn't exist?)
It looks like the tutorial is pointing at rather old version of the archetype (2.0.16) that maven can't even find.
I recommend to replace the generation step with the following command
mvn archetype:generate -DarchetypeGroupId=org.mule.tools.devkit -DarchetypeArtifactId=mule-devkit-archetype-cloud-connector -DarchetypeVersion=3.3.0
You can find additional informations here

Resources