Jenkins + Maven release plugin: release:branch + Git - Unable to commit files - java

I'm trying to make a release using the Maven release plugin, but I get an error
[ERROR] Command output:
[ERROR] GitLab: The project you were looking for could not be found.
[ERROR] fatal: The remote end hung up unexpectedly
In my pom.xml such settings:
<scm>
<developerConnection>scm:git:ssh://git#git.domain.ua/myproject/mylib.git</developerConnection>
<url>https://git.domain.ua/myproject/mylib</url>
<tag>HEAD</tag>
</scm>
My Jenkins job settings:
Repository URL: ssh://git#git.domain.ua/myproject/mylib.git
Credentials: my ssh-key also imported in Git repo as deploy key
Branch Specifier (blank for 'any'): */development
Maven Release goals and options: -Dresume=false release:branch javadoc:javadoc
DryRun goals and options: -Dresume=false -DdryRun=true release:prepare
As you can see from the logs, Git-plugin successfully clones a branch, but Maven cannot make a commit for some reason:
Cloning the remote Git repository
Cloning repository ssh://git#git.domain.ua/myproject/mylib.git
> git init /opt/jenkins/workspace/MYJOB # timeout=10
Fetching upstream changes from ssh://git#git.domain.ua/myproject/mylib.git
> git --version # timeout=10
using GIT_SSH to set credentials JENKINS(jenkins user with jenkins#USER)
git checkout development
Switched to a new branch 'development'
Branch development set up to track remote branch development from origin.
Parsing POMs
Established TCP socket on 44626
[INFO] Executing: /bin/sh -c cd /opt/jenkins/workspace/MYJOB && git push ssh://git#git.domain.ua/myproject/mylib.git refs/heads/development:refs/heads/development
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.1:branch (default-cli) on project MYPROJECT: Unable to commit files
[ERROR] Provider message:
[ERROR] The git-push command failed.
[JENKINS] Archiving /opt/jenkins/workspace/MYPROJECT/pom.xml to *****-SNAPSHOT.pom
[ERROR] Command output:
[ERROR] GitLab: The project you were looking for could not be found.
[ERROR] fatal: The remote end hung up unexpectedly
I guess Maven doesn't know anything about the key that uses the Git-plugin, but I can't figure out how to configure the Maven Release Plugin to use the same key?

Try doing this in your Jenkins job configuration:
Update the Branch Specifier (blank for 'any') to the syntax refs/heads/development.
Under SCM > Git > Additional Behaviours, select Checkout to specific local branch and then enter ** as the branch name.
Under Build Environment, select SSH Agent > Specific credentials, and then specify the same SSH key that you used for cloning the repository.

The error is in the clone via https protocol and the push via ssh protocol. You must define which protocol to use for the transfer. For comparison, use the result of the command: git remote show origin, with the scm parameter set in the pom.xml file.
Example:
<scm>
<connection>scm:git:git#github.com:user/repo-name.git</connection>
<developerConnection>scm:git:git#github.com:user/repo-name.git</developerConnection>
<url>git#github.com:user/repo-name.git</url>
<tag>HEAD</tag>
</scm>

try to remove the ssh:// and just use : scm:git:git#git.domain.ua/myproject/mylib.git
replace the url tag by a connection tag with the value : scm:git:git#git.domain.ua/myproject/mylib.git
In the end it's gonna be something like this :
scm:git:git#git.domain.ua/myproject/mylib.git
scm:git:git#git.domain.ua/myproject/mylib.git
Also the plugin is searching for a project "MYPROJECT" uppercase , or i guess in gitlab youhave "myproject", you can check and change all "MYPROJECT " reference to "myproject" and then try again.
Best regards,

Related

Maven Internal error: org.eclipse.tycho.core.osgitools.OsgiManifestParserException: Exception parsing OSGi MANIFEST

I am configuring maven for few dsl (xtext) types of projects.
I configured all I need for a dsl1 (xtext) plugins, it worked successfully (generate java sources, build, run tests, export, generate P2).
Then, I moved same pom.xml configurations for my next dsl2 plugins, that are pretty the same and got an issue:
[ERROR] Failed to execute goal org.eclipse.xtext:xtext-maven-plugin:2.16.0.M1:generate (default) on project com.dsl.dsl2: Execution default of goal org.eclipse.xtext:xtext-maven-plugin:2.16.0.M1:generate failed: Plugin org.eclipse.xtext:xtext-maven-plugin:2.16.0.M1 or one of its dependencies could not be resolved: Could not find artifact com.dsl.dsl2:com.dsl.dsl2:jar:0.1.0-SNAPSHOT
The plugin that run is com.dsl.dsl2 and it tells that it can not find itself.
Indeed for some reason maven fails to copy it into corresponding .m2/repository location.
I tried different solutions to solve it, and one of them was to remove the whole ~/.m2/repository and to regenerate it.
But now, instead of solving my problem, I am facing different other problems.
For all my repos that worked before to run mvn clean verify, now all complains with same error:
[INFO] Resolving class path of MavenProject: com.dsl.dsl2:com.dsl.dsl2:1.1.1-SNAPSHOT # /<my_path>/<my_repo>/com.dsl.dsl2/pom.xml
[ERROR] Internal error: org.eclipse.tycho.core.osgitools.OsgiManifestParserException: Exception parsing OSGi MANIFEST ~/.m2/repository/p2/osgi/bundle/org.eclipse.xtext.xtext.generator/2.15.0.v20180916-0722/org.eclipse.xtext.xtext.generator-2.15.0.v20180916-0722.jar: zip file is empty -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: org.eclipse.tycho.core.osgitools.OsgiManifestParserException: Exception parsing OSGi MANIFEST ~/.m2/repository/p2/osgi/bundle/org.eclipse.xtext.xtext.generator/2.15.0.v20180916-0722/org.eclipse.xtext.xtext.generator-2.15.0.v20180916-0722.jar: zip file is empty
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:120)
...
Caused by: org.eclipse.tycho.core.osgitools.OsgiManifestParserException: Exception parsing OSGi MANIFEST ~/.m2/repository/p2/osgi/bundle/org.eclipse.xtext.xtext.generator/2.15.0.v20180916-0722/org.eclipse.xtext.xtext.generator-2.15.0.v20180916-0722.jar: zip file is empty
at org.eclipse.tycho.core.osgitools.DefaultBundleReader.doLoadManifest (DefaultBundleReader.java:68)
...
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: java.util.zip.ZipException: zip file is empty
at java.util.zip.ZipFile.open (Native Method)
...
I am most interested in solving this last issue first. The jar file seems to be correct:
% ls -lsa ~/.m2/repository/p2/osgi/bundle/org.eclipse.swt.gtk.linux.x86/3.105.3.v20170228-0512/
2568 <user> 2616403 org.eclipse.swt.gtk.linux.x86-3.105.3.v20170228-0512.jar
4 <user> 219 org.eclipse.swt.gtk.linux.x86-3.105.3.v20170228-0512-p2artifacts.xml
And I don't know why it is using xtext 2.15.0 as
I specified in pom.xml properties
<xtend.version>2.16.0.M1</xtend.version>
<xtext.version>2.16.0.M1</xtext.version>
My maven:
% mvn -version
Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-17T21:33:14+03:00)
Maven home: ~/maven/apache-maven-3.5.4
Java version: 1.8.0_45, vendor: Oracle Corporation, runtime:
Default locale: en_US, platform encoding: ISO-8859-1
OS name: "linux", version: "2.6.32-642.11.1.el6.x86_64", arch: "amd64", family: "unix"
And I am using proxy.
Update
That is the content of unzipped jar it complains about.
% ls /org.eclipse.swt.gtk.linux.x86-3.105.3.v20170228-0512
about_files fragment.properties libswt-cairo-gtk-4629.so libswt-gtk-4629.so libswt-pi-gtk-4629.so libswt-xulrunner-fix10.so META-INF swt.xpt
about.html libswt-atk-gtk-4629.so libswt-glx-gtk-4629.so libswt-mozilla-gtk-4629.so libswt-webkit-gtk-4629.so libswt-xulrunner-fix31.so org version.txt
chrome.manifest libswt-awt-gtk-4629.so libswt-gnome-gtk-4629.so libswt-pi3-gtk-4629.so libswt-xpcominit-gtk-4629.so libswt-xulrunner-gtk-4629.so swt.js
I am using simple target platform configuration:
<repository>
<id>xtext</id>
<url>http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/</url>
<layout>p2</layout>
</repository>
<repository>
<id>eclipse</id>
<url>http://download.eclipse.org/releases/neon/201705151400/</url>
<layout>p2</layout>
</repository>
Update
I have solved my problem, but I can't say that it's a solution for the problems I had.
The last error I had is about Time Out due to Proxy limitations, I
believe. It has been solved in next day by itself.
The 1st outlined error I solved by recreating my pom configurations based on https://www.eclipse.org/Xtext/documentation/350_continuous_integration.html
Basically, I am not using any more <artifactId>xtext-maven-plugin</artifactId> that was failing, and it is recommended to use it in a non Eclipse plugin in case you need. I don't need it.

Sonarcloud is not authorized using Travis CI and Maven

I have an experimental project on my Github used for the practising the CI service integrations. I struggle with using Sonarcloud.
I have followed both Tavis CI + Sonarcloud tutorial and Maven example. Mz first confusion starts with the token and properties file whereas the first source suggests creating sonar-project.properties file and the Maven example source does not have any. Here where the documentation is very unclear.
I ignored the properties file and I have done the following steps:
Generated token on sonarcloud.io for my project: e53.....239
Encrypted token on travis-encrypt.github.io since it's the most comfortable way for a Windows user. The 2 following inputs resulted in g3s.....+Q=:
NicharNET/Gistintex
SONAR_TOKEN="e53...239" - I tried both to wrap between quotation marks and without.
Added to Settings -> Environment variable key SONAR_TOKEN with the value of the generated Sonarcloud token e53...239.
Completed travis.yml with the secure token:
language: java
sudo: false
jdk: oraclejdk8
addons:
sonarcloud:
organization: "nicharnet-github"
token:
secure: "g3sLTdS597mklh1I9HgXr71NRCiOk2n9I41PL2wklnAidwibfocyEcWvSQxjmbhNTjdrcW0cAfzh73Ago8hwfdloraryDY9Ng9L1runxayShtPOqZMPI6nz8zUwLaDfqJVwXWv6A3xICOMFl0UhvF351GPErHhrUO7YIa8el3kESeotYy7kkTzeQ7BA239y7EVFw8H4OCW2gjP2G/InxKnlXfNjgQA3GsnZdJ3uWO3No5kwt5ybfuCCV42cp/UczLIzNbo0RW9Z9jBl5IFMzJaUQUfWV3Pp5QEPmpB7Anr/4W1EtjJPjpSIC/+jBmbrkvC/CSzzTPjaH9LzEQ5m4F5JpRw01blqgKH/153qfs1jRgZK6WVRuhe7yAATHCO/IM0DM+kC0mUJTcXKyv9pRm93E4wp+KzdHYy0LdA83wFgMmvlB8pcm20ImAe7B2SBFx5TGtETa6ea6k2BS+DfBXe6sLBnrl1zZB8nxCDnYiwT1BJFxizgv3EJ6Krjd3cSSxr6PGnXDD/yTeFNJarpMbA+wR6AQetJ89LiDBXYiw6GPgWk/A4vUDIsIaXGqCpydeZHkr2ufS1Ap4yYS0Um2GeDeQXTsBTSCg7BViFgduUI1NPYT1avKg7b64nsdpdjBVofOvzJsgiT66WlaJmt23BUCJsnmXwwEcW1387b4G+Q="
script:
- mvn clean install org.jacoco:jacoco-maven-plugin:prepare-agent sonar:sonar
Committed and pushed changes into the repository and Travis CI started to work and resulted in:
Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.1.1168:sonar (default-cli) on project gistintex: Not authorized. Please check the properties sonar.login and sonar.password.
The error could be found on my Travis CI build. What do I do wrong?
I have skimmed through Error using Travis CI with Sonarcloud: Not authorized. Please check the properties sonar.login and sonar.password SO question and Travis CI Sonarqube analysis article, which unfortunately didn't help me though. My GitHub project source.
I have tried to add these plugins to pom.xml and run the analysis locally:
org.codehaus.mojo: sonar-maven-plugin: 5.1
org.sonarsource.scanner.maven: sonar-maven-plugin: 3.4.1.1168
Running this on my machine resulted in the correct Sonarcloud analysis:
mvn sonar:sonar \
-Dsonar.organization=nicharnet-github \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.login=e53.....239
However, my goal is to run the analysis after every committed version using Travis CI. I am sure I have done wrong the key encryption but I can't figure what exactly.
The key encryption problem usually happens when you execute the generation without the login command against travis.com instead of travis.org
In order to run on every commit you could connect your repo with SonarCloud Scan, generate a secret in your sonarcloud.io project page and there you will find instructions to modify your .travis.yml
if you use travis.org
travis encrypt <YOUR_SONAR_SECRET>
if you use travis.com
travis login --pro
then generate your token like this:
travis encrypt --pro <YOUR_SONAR_SECRET>
finally you need to add your pipeline instruction to your .travis.yml file
Check in your Travis CI repo settings when it should be triggered
here some related links:
Error using Travis CI with Sonarcloud: Not authorized. Please check the properties sonar.login and sonar.password
https://docs.travis-ci.com/user/encryption-keys/#usage
https://github.com/marketplace/actions/sonarcloud-scan
https://sonarcloud.io/documentation/integrations/github/

Run simple Rest Java hello world program

I am trying to run a simple Rest HelloWorld program as described in https://spring.io/guides/gs/rest-service/. I have downloaded Spring and Maven and added the MAVEN_HOME and M3_HOME environment variables. I have run the mvn -v command successfully in Windows command prompt. I browsed to the initial directory where the pom.xml is located. Then I run mvn spring-root:run but I get the following error:
No plugin found for prefix 'spring-boot' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\user.m2\repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
I have already searched for this error message on the internet but the suggestions are not solving my problem. Am I forgetting something related to any installation? Any idea or suggestion is highly appreciated.
Oh, I realized now I had same issue in the past...
To address
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.9.RELEASE:repackage (default) on project gs-rest-service: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.5.9.RELEASE:repackage failed: Unable to find main class -> [Help 1]
You have to create Application class (something annotated with #SpringBootApplication)
#SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
or skip tests mvn clean install -DskipTests.
For mvnw spring-boot:run I'm getting ConnectException right now...
Downloading https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
Exception in thread "main" java.net.ConnectException: Connection refused: connect
but it is very likely issue on my side...

Couldn't transfer dependancies from maven when running from Jenkins

I have a script in Java, I could run it with maven commands locally and even in the local Jenkins setup (localhost)
Same set of scripts when I try to run from company jenkins server, it throws an error as this :
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org: unknown error: Unknown host repo.maven.apache.org: unknown error -> [Help 1]
[ERROR]*
Note :
I setup the jenkins server from ansible playbook, and the pipeline script is as follows:
node {
def mvnHome
stage('Preparation') { // for display purposes
// Get some code from a GitHub repository
git branch: '*/work', credentialsId: 'git-deploy', url:'<correct git url>'
}
stage('Build') {
// Run the maven build
docker.image("maven:3.2-jdk-8").inside("--privileged=true -e TZ=Asia/Singapore") {
sh 'mvn --version'
sh 'which mvn'
sh "'/usr/bin/mvn' clean test"
}
}
What could be the cause? please help.
It looks like a proxy issue.
Your Maven setup is unable to download the maven-clean-plugin-2.5.jar.
Try to download the jar file manually in the machine where Jenkins is installed. Open the following link in the browser:
http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.jar
If you are able to download it here, then check your browser's proxy and try to use the same proxy in the settings.xml of your maven.
Example:
<proxy>
<id>example-proxy</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy.example.com</host>
<port>8080</port>
<username>proxyuser</username>
<password>somepassword</password>
<nonProxyHosts>www.google.com|*.example.com</nonProxyHosts>
</proxy>
Check this guide for proxy settings in Maven.

Maven central repo: Return code is: 503 , ReasonPhrase:backend read error

In the continuous integration system (travis-ci.org) on our project, I'm starting to get error:
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.4.6-SNAPSHOT:start (start-container) on project p6spy-it: Failed resolving artifact: Could not transfer artifact org.jboss.jbossas:jboss-as-distribution:zip:6.1.0.Final from/to central (http://repo.maven.apache.org/maven2): Failed to transfer file: http://repo.maven.apache.org/maven2/org/jboss/jbossas/jboss-as-distribution/6.1.0.Final/jboss-as-distribution-6.1.0.Final.zip. Return code is: 503 , ReasonPhrase:backend read error.
[ERROR] org.jboss.jbossas:jboss-as-distribution:zip:6.1.0.Final
[ERROR]
[ERROR] from the specified remote repositories:
[ERROR] codehaus-snapshots (http://nexus.codehaus.org/snapshots/, releases=false, snapshots=true),
[ERROR] cloudbees-release (http://repository-p6spy.forge.cloudbees.com/release, releases=true, snapshots=false),
[ERROR] sonatype (https://oss.sonatype.org/content/repositories/releases/, releases=true, snapshots=false),
[ERROR] sonatype-snapshots (https://oss.sonatype.org/content/repositories/snapshots/, releases=false, snapshots=true),
[ERROR] sonatype-apache (https://repository.apache.org/releases/, releases=true, snapshots=false),
[ERROR] apache-snapshots (https://repository.apache.org/snapshots/, releases=false, snapshots=true),
[ERROR] sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots, releases=false, snapshots=true),
[ERROR] central (http://repo.maven.apache.org/maven2, releases=true, snapshots=false)
Full build output can be seen on: https://api.travis-ci.org/jobs/15104889/log.txt?deansi=true
If I access the problematic url via browser: http://repo.maven.apache.org/maven2/org/jboss/jbossas/jboss-as-distribution/6.1.0.Final/jboss-as-distribution-6.1.0.Final.zip
I get the same error as well:
Error 503 backend read error
However one day back all was fine.
What should I do with that/How to fix that? Just wait for them to refresh some internal caches?
Try:
(1) Download jboss-as-distribution-6.1.0.Final.pom and jboss-as-distribution-6.1.0.Final.zip from the Maven Central Repository.
(2) Install the zip file into your local Maven repository manually.
mvn install:install-file \
-Dfile=jboss-as-distribution-6.1.0.Final.zip \
-DpomFile=jboss-as-distribution-6.1.0.Final.pom
It seems "Return code is: 503 , ReasonPhrase:backend read error." error occurs when the target zip file is big. I encountered the same error when downloading appengine-java-sdk-1.9.0.zip.
If downloading remote artifacts is mission critical for your build, have you considered running your own instance of Nexus?
http://www.sonatype.org/nexus/
This will protect you against transient networking and server errors, by acting as a local cache inside your network. It'll also improve the performance of your build processes.
A second lessor option is to use the alternate URLs provided by the Search service:
jboss page on Maven Central
http://search.maven.org/remotecontent?filepath=org/jboss/jbossas/jboss-as-distribution/6.1.0.Final/jboss-as-distribution-6.1.0.Final.zip
Maybe, just maybe you'll get redirected to a webserver that is either hosted on S3 or in a more available cluster.
Finally if you're interested in what Sonatype are doing to scale up Maven Central, their blogs have postd some interesting updates:
http://blog.sonatype.com/people/tag/central/
http://blog.sonatype.com/people/2012/07/we-just-kicked-central-performance-and-availability-up-a-notch-with-edgecast/
http://blog.sonatype.com/people/2008/12/central-maven-repository-taffic-using-s3/

Categories