Maven jgitflow plugin - maven

I don't know if any of you do use the maven plugin jgitflow.
when running
clean jgitflow:release-start jgitflow:release-finish
on hudson, I get the following error:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to
execute goal external.atlassian.jgitflow:jgitflow-maven-plugin:1.0-m5.1:release-start
(default-cli) on project test-git-release: Execution default-cli of goal
external.atlassian.jgitflow:jgitflow-maven-plugin:1.0-m5.1:release-start
failed: String index out of range: -6
My pom.xml looks as follows:
<plugin>
<groupid>external.atlassian.jgitflow</groupid>
<artifactid>jgitflow-maven-plugin</artifactid>
<version>1.0-m5.1</version>
<configuration>
<enablesshagent>true</enablesshagent>
<defaultoriginurl>URL</defaultoriginurl>
<autoversionsubmodules>true</autoversionsubmodules>
<nodeploy>true</nodeploy>
<pushreleases>true</pushreleases>
<flowinitcontext>
<versiontagprefix>V_</versiontagprefix>
</flowinitcontext>
</configuration>
</plugin>
On my local machine I am able to run this command successfully.

Apparently is a known bug: official bug report, for the same version you mentioned and same behavior (working fine locally but same exception on Jenkins/Hudson).
Note that the linked bug report above provides a workaround maybe worth to try:
The workaround is in Jenkins:
Additional Behaviours
=> checkout to specific local branch
Update
According to the comments exchanged, proposed solutions and effective resolutions, here is the historical log for future helps:
Following the suggested workaround above and setting the local branch to checkout from origin/develop, the following error was encountered:
error occurred during unpacking on the remote end: unpack-objects abnormal exit
Such an error was actually due to permissions on the concerned folder, as also suggested by other SO threads, here and here. However changing the permissions afterwards did not help.
The issue was finally solved by creating the .git repository on the server itself. Doing so gave the group of the folder the same permissions as the owner.

A little timesaver for all the folks working with GitLab and experiencing this problem:
GitLab's Runner works on a DETACHED HEAD, which causes JGitFlow's search for GIT refs to fail, resulting in exactly this error.
The solution is as it is for Jenkins: before performing the JGitFlow operation, make a checkout. For GitLab you can do this by adding a git checkout in the /script part of the respective pipeline your gitlab-ci.yml, for example:
sample-pipeline:
stage: release
script:
-git checkout -B master
-mvn --batch-mode jgitflow:release-start jgitflow:release-finish
Since JGitFlow automatically checks out the develop branch and does its magic from there, you can always check out the master beforehand, as it has no effect at all; its just important that its not a DETACHED HEAD when GitLab starts its search for refs.

Related

Jenkins Travis-CI build fails in cli module (shade fails)

I am running a custom Jenkins 2.263.4 build on Travis-CI. We need a fix with relative pathes that never made it into the Jenkins core...well for us it is mandatory.
Based on release 2.263.4 I applied the fix in core/SecretRewriter.java and core/VirtualFile.java and also changed the version name to give it branding. This worked very well in the past releases. But the last update we did was one year ago.
Now I am running into the error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.2.1:shade (default) on project cli: Error creating shaded jar: duplicate entry: META-INF/services/io.jenkins.cli.shaded.org.apache.sshd.common.io.IoServiceFactoryFactory -> [Help 1]
I am not able to understand it at all.
Travis-CI is here: https://travis-ci.com/github/DanielWeber/jenkins
GitHub: https://github.com/DanielWeber/jenkins
I was not able to find this exact problem from somewhere else. I tried a bit with the shade config to set
<minimizeJar>false</minimizeJar>
and similar small things, but didn't really help.
My change is so small, I don't really understand what's happening.
If nothing helps, I might consider doing changes step by step then, rather than just merging the releae to our for, but hope someone sees the problem.
The issue is that the build is being execute two times based on the mvn install followed by mvn package which is defined in travis.yml file. This causes the issue.

Jenkins build step is unable to delete directory

Until recently everything worked fine with our build process in Jenkins. We got a quite big project with many modules and a complicated dependency structure.
Suddenly, the build fails with error messages like the following:
Failed to execute goal certain-plugin:109:certainEar(certainEar)
on project app: certain plugin: Can't explode ear file
'app-SNAPSHOT.ear': Error, directory can't be deleted
The maven command that gets executed in the build pipeline and results in the error message is the following:
mvn -B -U package -DskipTests
A temporary workaround is manually deleting the affected directory. Previously I had a similar problem with the deletion of an ear, there it was possible to exclude the affected ear from this build step as it was not required there. Afterwards I got the error message mentioned above.
Now I found a (kind of) final solution: Adding clean to the targets of the maven command:
mvn -B -U clean package -DskipTests
Now the building step works fine. But why the heck does this happen? Do you have any hints what could lead to this behavior? I'm quite clueless to say the least.
Somehow this could have something to do with the extraction of an ear out of our big app ear. Shortly after we finished this and merged it into our master branch those errors began to arise. As I was not involved in this work it's hard to track down what happened there exactly and what could lead to this behavior. In parallel I will investigate what the colleagues did there. Hints from you what the reasons could be will certainly help to track this down.
I found nothing similar to this error messages online that helped me in any way.
Your solution "mvn clean" indicates me that your job is executing on a jenkins workspace that contains the execution of the previous job. I would recommend to always start your job by clearing what's in the workspace. In freestyle job, under section Source Code Management you can add the behavior
Wipe out repository & force clone
in pipelines, you would use checkout step
checkout([$class: 'GitSCM',
extensions: scm.extensions + [[$class: 'WipeWorkspace']] + [[$class: 'PruneStaleBranch']],
userRemoteConfigs: [[
url: '<git_url>'
]]
])
there are other ways to clean a workspace in a pipeline like cleanWS and deleteDir. Do prefer the checkout WipeWorkspace plugin

Maven release branch fails with error=7, Argument list too long

We have recently migrated our multimodule(each module with a pom.xml) repository from SVN to GIT.SCM connection in all pom.xml files updated from svn to git.
When i am trying to create a branch from git repository using maven release plugin it fails with the below error
"Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5:branch (default-cli) on project intgr: An error is occurred in the checkin process: Exception while executing SCM command. Error while executing command. Error while executing process. Cannot run program "/bin/sh" (in directory "/u01/remote-agent-home/xml-data/build-dir/IN-CDBFG-JOB1/mahirepository"): error=7, Argument list too long -> [Help 1]"
On examining logs i understand below command generated this error.
"[INFO] Checking in modified POMs... [INFO] Executing: /bin/sh -c cd /u01/remote-agent-home/xml-data/build-dir/IN-CDBFG-JOB1/mahirepository && git add -- intgr-parent/pom.xml archetypes/pom.xml and 1000 more pom files "
Is there a way i can workaround or fix this issue?
Maven version : Apache Maven 3.0.4
JDK version : 1.7.0_01
Maven command :
mvn -s ./settingsBamboo.xml --batch-mode release:branch -DbranchName=${bamboo.branchname} -DupdateWorkingCopyVersions=true -DsuppressCommitBeforeBranch=true -DautoVersionSubmodules=true -DremoteTagging=false -DupdateBranchVersions=false -X
I am currently facing this problem as well, but I got a bit further on this.
The issue has nothing to do with Java or Maven, it's a Linux limitation.
using getconfig MAX_ARGS you can find the max amount of bytes you can use as arguments.
Large maven commands can easily go beyond this, and the amount of bytes differs largely per distro.
Check the amount of bytes you can use, and try to get your command below that.
You could for example move into the build dir first, and then run the command relative.
Another solution would be to increase the amount of usable space, but I have so far not gotten that working.
If anyone does or you have fixed this yourself, let me know.

Can't seem to get Multi-branch Pipeline to work with JenkinsFile

I'm sure I'm doing something stupid that most of you are going to laugh at, but I can't seem to get Jenkins to build with multi-branch pipeline. I've simplified the problem down to the very essence. A single branch (master) with an empty node JenkinsFile. I have a second project, a standard Freestyle project that basically runs true to verify it builds.
Here's my Freestyle configuration:
Repository URL: ssh://git#rgit.vegicorp.net:7999/dw/foobar.git
Credentials: None
BUILD
Execute Shell
Command: True
And the build works. (Basically, the repo checks out, true runs, and the build is reported as a success.
Here's my Multibranch build configuration:
BRANCH SOURCES
Project Repository: ssh://git#rgit.vegicorp.net:7999/dw/foobar.git
Credentials: None
BUILD CONFIGURATION
Mode: By JenkinsFile
When I do Branch Indexing, I get a failure and the log says:
Started
Setting origin to ssh://git#cmstash.travelclick.net:7999/dw/foobar.git
Fetching origin...
FATAL: Failed to recompute children of test » Jenkinsfile Test \
java.lang.IllegalStateException: Cannot open session, connection is \
not authenticated.
at com.trilead.ssh2.Connection.openSession(Connection.java:1127)
at org.jenkinsci.plugins.gitclient.trilead.TrileadSession.exec(TrileadSession.java:32)
at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:262)
at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:161)
at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:136)
at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122)
at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1138)
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:130)
at org.jenkinsci.plugins.gitclient.JGitAPIImpl.fetch(JGitAPIImpl.java:678)
at jenkins.plugins.git.AbstractGitSCMSource.retrieve(AbstractGitSCMSource.java:174)
at jenkins.scm.api.SCMSource.fetch(SCMSource.java:146)
at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:294)
at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:157)
at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:122)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Finished: FAILURE
My JenkinsFile (which sits in the root of the Repo) says:
node {
}
This works when I am not doing a multi-branch pipeline and just put this in as a Jenkins build script. I just want to verify that Jenkins is able to pick up my JenkinsFile.
Found the issue: You must have credentials set even if you don't need to use credentials. The freestyle job has no credentials set and has access to this particular Git repository. In our old Jenkins server, we use ssh:// and setup public/private keys in the $HOME/.ssh directory for our Git projects. None of our Git projects use credentials and don't need them.
However, Multibranch Pipeline does require credentials -- and a non-null JenkinsFile. When I finally set the credential, the job I had to add at least one step in the JenkinsFile or else it wouldn't trigger a single build.)
i think you are also hitting BUG like me ..
{`https://issues.jenkins-ci.org/browse/JENKINS-35567
Jenkins workflow-multibranch with git - IllegalStateException  Tried adding jgit and that didn’t help
`}
Did you got this resolved ?

Can you do this with Hudson?

I want to create a hudson job, that takes an id as a parameter. And use that id to calculate the svn-repo path.
Where I work you have a svn path for every issue that you resolve. And then all the issues are joined into a single svn-path.
What I want to do is to run static code analysis on the partial issues.
So I think maybe having an Ant build.xml that I use for every issue, then, parametrize the job with the issue id.
I have tried to achieve that but the svn path doesn't replace the parameter.
I have tried with #issueId, %issueId%, ${issueId} and ${env.issueId} without success.
Jump error like:
Location 'http://svn-path:8181/svn/devSet/issues/${env.chuid}' does not exist
Checking out a fresh workspace because C:\Documents and Settings\dnoseda\.hudson\jobs\test\workspace\${env.chuid} doesn't exist
Checking out http://svn-path:8181/svn/devSet/issues/${env.chuid}
ERROR: Failed to check out http://svn-path:8181/svn/devSet/issues/${env.chuid}
org.tmatesoft.svn.core.SVNException: svn: '/svn/!svn/bc/46190/devSet/issues/$%7Benv.chuid%7D' path not found: 404 Not Found (http://svn-path:8181)
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:64)
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:51)
at
I am think that I can not do what I want.
Do you know how I can setup the correct configuration to achieve this matter?
Thanks for any help.
Edit
The section of the configurate job that I want to put this parameter is this:
<scm class="hudson.scm.SubversionSCM">
<locations>
<hudson.scm.SubversionSCM_-ModuleLocation>
<remote>http://svn-path:8181/svn/devSet/issues/${env.issueid}</remote>
</hudson.scm.SubversionSCM_-ModuleLocation>
</locations>
New Edit: Solved
My version of hudson it was the last (1.349), but the version of svn plugin it was 1.11, being the last the 1.13, and it work with ${issueId}
Thank for the anwsers
From the hudson wiki:
"The parameter are available as environment parameters. So e.g. a shell ($FOO, %FOO%) or Ant ( ${env.FOO} ) can access these values."
Your syntax doesn't match the one in the wiki.
I've setup a svn project that does the parameter substitution successfully. The syntax is indeed ${issueId} so I assume you are doing something wrong, or are using a very old version of Hudson. Could you update the question with the versions of Hudson and the subversion plugin that you are using?
<project>
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties>
<hudson.model.ParametersDefinitionProperty>
<parameterDefinitions>
<hudson.model.StringParameterDefinition>
<name>issueId</name>
<description></description>
<defaultValue>none</defaultValue>
</hudson.model.StringParameterDefinition>
</parameterDefinitions>
</hudson.model.ParametersDefinitionProperty>
</properties>
<scm class="hudson.scm.SubversionSCM">
<locations>
<hudson.scm.SubversionSCM_-ModuleLocation>
<remote>https://svn.dev.java.net/svn/hudson/trunk/${issueId}</remote>
</hudson.scm.SubversionSCM_-ModuleLocation>
</locations>
<useUpdate>true</useUpdate>
<excludedRegions></excludedRegions>
<excludedUsers></excludedUsers>
<excludedRevprop></excludedRevprop>
</scm>
<canRoam>true</canRoam>
<disabled>false</disabled>
<triggers class="vector"/>
<concurrentBuild>false</concurrentBuild>
<builders/>
<publishers/>
<buildWrappers/>
</project>
Here is the build output. The checkout fails due to an authentication issue, but the parameter is successfully replaced:
Started by user anonymous
Building on master
Checking out a fresh workspace because C:\hudson\jobs\test-svn\workspace\${issueId} doesn't exist
Checking out https://svn.dev.java.net/svn/hudson/trunk/www
ERROR: Failed to check out https://svn.dev.java.net/svn/hudson/trunk/www
org.tmatesoft.svn.core.SVNCancelException: svn: No credential to try. Authentication failed
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.cancel(SVNErrorManager.java:37)
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.cancel(SVNErrorManager.java:32)
at org.tmatesoft.svn.core.internal.wc.DefaultSVNAuthenticationManager.getFirstAuthentication(DefaultSVNAuthenticationManager.java:168)
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:534)
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:273)
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:261)
at org.tmatesoft.svn.core.internal.io.dav.DAVConnection.exchangeCapabilities(DAVConnection.java:516)
at org.tmatesoft.svn.core.internal.io.dav.DAVConnection.open(DAVConnection.java:98)
at org.tmatesoft.svn.core.internal.io.dav.DAVRepository.openConnection(DAVRepository.java:1001)
at org.tmatesoft.svn.core.internal.io.dav.DAVRepository.getLatestRevision(DAVRepository.java:178)
at org.tmatesoft.svn.core.wc.SVNBasicClient.getRevisionNumber(SVNBasicClient.java:482)
at org.tmatesoft.svn.core.wc.SVNBasicClient.getLocations(SVNBasicClient.java:851)
at org.tmatesoft.svn.core.wc.SVNBasicClient.createRepository(SVNBasicClient.java:534)
at org.tmatesoft.svn.core.wc.SVNUpdateClient.doCheckout(SVNUpdateClient.java:893)
at org.tmatesoft.svn.core.wc.SVNUpdateClient.doCheckout(SVNUpdateClient.java:791)
at hudson.scm.SubversionSCM$CheckOutTask.invoke(SubversionSCM.java:615)
at hudson.scm.SubversionSCM$CheckOutTask.invoke(SubversionSCM.java:541)
at hudson.FilePath.act(FilePath.java:676)
at hudson.FilePath.act(FilePath.java:660)
at hudson.scm.SubversionSCM.checkout(SubversionSCM.java:534)
at hudson.scm.SubversionSCM.checkout(SubversionSCM.java:482)
at hudson.model.AbstractProject.checkout(AbstractProject.java:898)
at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:400)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:349)
at hudson.model.Run.run(Run.java:1106)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:93)
at hudson.model.Executor.run(Executor.java:122)
Notifying upstream projects of job completion
Finished: FAILURE
In this comment, it is mentioned that they use the ${ISSUEID}, which is why I suggested it, but all other signs I see say this doesn't actually work.
Otherwise I would recommend not using the SCM plugin and doing the SVN operation in a build script step. This would allow you to use the parameters as env variables like $ISSUEID

Resources