Jenkins Failed to Parse POMs: Permission Denied - maven

I have been having issues getting my new OpenShift Jenkins CI Server to work. I setup everything the way all tutorials tell me to, but when I try to build the project, I always get this same error:
Checking out Revision 3e88dcb5295354f9b02ef69ded84c97562c39aad (origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f 3e88dcb5295354f9b02ef69ded84c97562c39aad
> git rev-list 3e88dcb5295354f9b02ef69ded84c97562c39aad # timeout=10
Parsing POMs
ERROR: Failed to parse POMs
java.net.BindException: Permission denied
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376)
at java.net.ServerSocket.bind(ServerSocket.java:376)
at java.net.ServerSocket.bind(ServerSocket.java:330)
at hudson.maven.AbstractMavenProcessFactory$SocketHandler$AcceptorImpl.<init>(AbstractMavenProcessFactory.java:210)
at hudson.maven.AbstractMavenProcessFactory$SocketHandler.call(AbstractMavenProcessFactory.java:196)
at hudson.maven.AbstractMavenProcessFactory$SocketHandler.call(AbstractMavenProcessFactory.java:194)
at hudson.remoting.LocalChannel.call(LocalChannel.java:45)
at hudson.maven.AbstractMavenProcessFactory.newProcess(AbstractMavenProcessFactory.java:266)
at hudson.maven.ProcessCache.get(ProcessCache.java:236)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:778)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:536)
at hudson.model.Run.execute(Run.java:1741)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:374)
Finished: FAILURE
I am using Maven 3.3.9 and have made sure that all permissions are correct. This is a fresh install of OpenShift Jenkins with the only changes being adding JDK 7u79, GitHub plugin (including updating all dependencies for it) and adding Maven 3.3.9, however it is denied permission to the POM making it unable to be read.
I have seen this question OpenShif jenkins: java.net.BindException: Permission denied
However the link provided in the answer is outdated and no longer present, simply redirecting me to the documentation which does not help.
How can I allow my Jenkins server permission to allow it to parse the POM file and build my code?

Check your jenkins configuration :
scm Plugins
jenkins->configure system

Related

mvn gitflow:release-finish with main-branch

I'm getting the following errormessage:
Failed to execute goal com.amashchenko.maven.plugin:gitflow-maven-plugin:1.18.0:release-finish (default-cli) on project parent: release-finish: error: pathspec 'master' did not match any file(s) known to git
That's because the branch is called main instead of master.
Renaming the branch to master is not an option.
Is there any way to pass the information about the main-branch to the maven-gitflow-plugin?
As stated in the errormessage I'm using the plugin version 1.18.0
I think this is configurable in the gitflow-maven-plugin configuration:
<gitFlowConfig>
<productionBranch>main</productionBranch>
</gitFlowConfig>

How can I build my maven application succesfully on Jenkins?

I am new to Jenkins and don't have much luck. I am trying to build my spring boot application with maven in it. It builds succesfully until I add commands "clean compile package" in Invoke top-level Maven targets.
The build fails.
Started by user unknown or anonymous
Running as SYSTEM
Building in workspace /var/jenkins_home/jobs/sample/workspace
The recommended git tool is: NONE
No credentials specified
> git rev-parse --resolve-git-dir /var/jenkins_home/jobs/sample/workspace/.git # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://github.com/rshncp/stackApp.git # timeout=10
Fetching upstream changes from https://github.com/rshncp/stackApp.git
> git --version # timeout=10
> git --version # 'git version 2.30.2'
> git fetch --tags --force --progress -- https://github.com/rshncp/stackApp.git +refs/heads/*:refs/remotes/origin/* # timeout=10
> git rev-parse refs/remotes/origin/main^{commit} # timeout=10
Checking out Revision 497d77eeef33f9cc19c5390d21cf49e90ac24e05 (refs/remotes/origin/main)
> git config core.sparsecheckout # timeout=10
> git checkout -f 497d77eeef33f9cc19c5390d21cf49e90ac24e05 # timeout=10
Commit message: "first commit"
> git rev-list --no-walk 497d77eeef33f9cc19c5390d21cf49e90ac24e05 # timeout=10
[workspace] $ mvn clean compile package
FATAL: command execution failed
java.io.IOException: error=2, No such file or directory
at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:340)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:271)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
Caused: java.io.IOException: Cannot run program "mvn" (in directory "/var/jenkins_home/jobs/sample/workspace"): error=2, No such file or directory
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
at hudson.Proc$LocalProc.<init>(Proc.java:252)
at hudson.Proc$LocalProc.<init>(Proc.java:221)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:995)
at hudson.Launcher$ProcStarter.start(Launcher.java:507)
at hudson.Launcher$ProcStarter.join(Launcher.java:518)
at hudson.tasks.Maven.perform(Maven.java:367)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:806)
at hudson.model.Build$BuildExecution.build(Build.java:198)
at hudson.model.Build$BuildExecution.doRun(Build.java:163)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:514)
at hudson.model.Run.execute(Run.java:1888)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:99)
at hudson.model.Executor.run(Executor.java:431)
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE
How can I fix this?
Download Maven as plug-in. You must go to Jenkins Global Tool Configuration, and configure a Maven version with automatic installer (from the web).
Setup in global configuration, maven version. Look second answer of this case Cannot run program "mvn" error=2, No such file or directory

Error while bulding maven project - TeamCity

Everytime I try to build a Maven project hosted on a gitlab server with TeamCity, I get an error from the buildAgent. Both TeamCity and GitLab are on the same server.
It seems that the agent can't connect to gitlab but it does, because when I have to specify the pom.xml path in the build configuration section, I can navigate through the repository folders(http://prntscr.com/i8pyjf).
I have already tried different solutions:
I added both the root ssh and the ssh key of the ser that is running teamcity, both of them seem to work cause the test connection was succesful(http://prntscr.com/i8q0jf);
I added teamcity.git.use.native.ssh true in the buildAgent conf and the error log changed a little (the error is still the same but I get less lines)
I added teamcity.git.use.native.ssh true as a configuration parameter -> http://prntscr.com/i8pnqp (not sure if I did it right)
I tried adding the runAs plugin to force the user agent to use root
TeamCity version -> TeamCity Professional 2017.2.2 (build 50909)
Here's the error log:
[22:03:51] The build is removed from the queue to be prepared for the start
[22:03:51] Collecting changes in 1 VCS root
[22:03:51] [Collecting changes in 1 VCS root] VCS Root details
[22:03:51] [VCS Root details] "git#151.80.136.106:Developer/BanlogBridge.git" {instance id=11, parent internal id=1, parent id=Ban_Git15180136106DeveloperBanlogBridgeGit, description: "git#151.80.136.106:Developer/BanlogBridge.git#master"}
[22:03:51] [Collecting changes in 1 VCS root] Compute revision for 'git#151.80.136.106:Developer/BanlogBridge.git'
[22:03:51] [Compute revision for 'git#151.80.136.106:Developer/BanlogBridge.git'] Upper limit revision: 0d41a12c788798152c7da9327ef63b759f7d5b4c
[22:03:51] [Compute revision for 'git#151.80.136.106:Developer/BanlogBridge.git'] Cannot find modification with revision 0d41a12c788798152c7da9327ef63b759f7d5b4c
[22:03:51] [Compute revision for 'git#151.80.136.106:Developer/BanlogBridge.git'] No modification from VCS root is attached to build configuration, use upper limit revision
[22:03:51] [Compute revision for 'git#151.80.136.106:Developer/BanlogBridge.git'] Computed revision: 0d41a12c788798152c7da9327ef63b759f7d5b4c
[22:03:51] Starting the build on the agent Default Agent
[22:03:52] Clearing temporary directory: /usr/local/teamcity/buildAgent/temp/buildTmp
[22:03:52] Publishing internal artifacts
[22:03:52] [Publishing internal artifacts] Publishing 1 file using [ArtifactsCachePublisher]
[22:03:52] [Publishing internal artifacts] Publishing 1 file using [WebPublisher]
[22:03:52] Using vcs information from agent file: db80d9c7294729d5.xml
[22:03:52] Checkout directory: /usr/local/teamcity/buildAgent/work/db80d9c7294729d5
[22:03:52] Updating sources: auto checkout (on agent)
[22:03:52] [Updating sources] Will use agent side checkout
[22:03:52] [Updating sources] VCS Root: git#151.80.136.106:Developer/BanlogBridge.git
[22:03:52] [VCS Root: git#151.80.136.106:Developer/BanlogBridge.git] revision: 0d41a12c788798152c7da9327ef63b759f7d5b4c
[22:03:52] [VCS Root: git#151.80.136.106:Developer/BanlogBridge.git] Git version: 2.7.4.0
[22:03:52] [VCS Root: git#151.80.136.106:Developer/BanlogBridge.git] Will use native ssh (teamcity.git.use.native.ssh=true)
[22:03:52] [VCS Root: git#151.80.136.106:Developer/BanlogBridge.git] Update checkout directory (/usr/local/teamcity/buildAgent/work/db80d9c7294729d5)
[22:03:52] [Update checkout directory (/usr/local/teamcity/buildAgent/work/db80d9c7294729d5)] /usr/bin/git config core.sparseCheckout true
[22:03:52] [Update checkout directory (/usr/local/teamcity/buildAgent/work/db80d9c7294729d5)] /usr/bin/git show-ref
[22:03:52] [Update checkout directory (/usr/local/teamcity/buildAgent/work/db80d9c7294729d5)] /usr/bin/git show-ref refs/remotes/origin/master
[22:03:52] [Update checkout directory (/usr/local/teamcity/buildAgent/work/db80d9c7294729d5)] Commit '0d41a12c788798152c7da9327ef63b759f7d5b4c' is not found in local clone. Running 'git fetch'...
[22:03:52] [Update checkout directory (/usr/local/teamcity/buildAgent/work/db80d9c7294729d5)] /usr/bin/git fetch --progress origin +refs/heads/master:refs/remotes/origin/master
[22:03:52] [Updating sources] Failed to perform checkout on agent: '/usr/bin/git fetch --progress origin +refs/heads/master:refs/remotes/origin/master' command failed.
exit code: 128
stderr: Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
[22:03:52] Publishing internal artifacts
[22:03:52] [Publishing internal artifacts] Publishing 1 file using [ArtifactsCachePublisher]
[22:03:52] [Publishing internal artifacts] Publishing 1 file using [WebPublisher]
[22:03:52] Build failed to start. Artifacts will not be published for this build
[22:03:52] Build finished
Thank you for your help!
It happens because known hosts database on the TeamCity agent machine doesn't contain the fingerprint of the Gitlab server. You can add it by running some command via ssh, e.g. git ls-remote <your repository url>, and agree to add the fingerprint if it's correct.
Actually TeamCity checks out code with known hosts database check disabled. Please check if you have anything related to Gitlab in the .ssh/config on the TeamCity agent machine.

Maven release of Github project fails for using wrong Github account

I'm performing a release of a project on Github using Maven. release:prepare fails with:
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] remote: Permission to FOO/BAR.git denied to BAZ.
[ERROR] fatal: unable to access 'https://github.com/FOO/BAR.git/': The requested URL returned error: 403
The weird thing is that BAZ is the "wrong" github.com account. It is one of two user names I use on Github, but not one I have ever used with the BAR project. Let's say the right account is FIZZ.
SCM settings don't specify a user name:
<scm>
<connection>scm:git:https://github.com/FOO/BAR.git</connection>
<url>scm:git:https://github.com/FOO/BAR.git</url>
<developerConnection>scm:git:https://github.com/FOO/BAR.git</developerConnection>
...
</scm>
(FOO is an organization that I'm part of.) In fact, I can't figure out where on earth BAZ is coming from. It's not in ~/.gitconfig or .git/config. There is no ~/.m2/settings.xml file. My Maven settings.xml file says nothing about Github.
If I use git on the command line it works -- push is fine for example.
Can anyone tell me where else this might be coming from? a hidden config file or directory somewhere, whether Maven- or Git-related?
Or, what's the best practice for recording the Github user to use in a private local file, like a Maven settings.xml or .git/config, such that I need not put my own user into the build file?
I'm using Mac OS X.
The simplest thing would be to explicitly use an ssh url, see more details in this answer.
git remote set-url origin git#github.com:FIZZ/FOO/BAR.git
Finally figured this out. The problem is that I'm on OS X, and had logged in to my second account BAZ via Safari. This saved the username and password for https://github.com in Keychain. Apparently, the Maven SCM plugin consults this for HTTPS URLs, although git won't. After clearing Keychain, it correctly prompted me for a username and password.

How can I evade build fails in Hudson when there is no code change?

I am using Hudson to build from Git in my continuous integration system. Everything works fine except that when I start another build without any code change in Git. Then the build just crashes and burns with exceptions. How can I let the Hudson know that if there is no change in the Git side, just rebuild the old code?
Here comes the exception:
ERROR: Problem fetching from origin / origin - could be unavailable. Continuing anyway
ERROR: Could not fetch from any repository
FATAL: Could not fetch from any repository
hudson.plugins.git.GitException: Could not fetch from any repository
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:759)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:718)
at hudson.FilePath.act(FilePath.java:756)
at hudson.FilePath.act(FilePath.java:738)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:718)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1171)
at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:499)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:415)
at hudson.model.Run.run(Run.java:1362)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:405)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:145)

Resources