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.)