I am using auth token from github to access my github repo, i am able to do it locally in my linux machine using the same auth token. So the token is not the issue here. However, jenkins just Failed to setup credentials, and I am unable to figure out why. Anything will help.
Thanks
Summary
14:31:51 > git --version # timeout=10 14:31:51 > git --version # ‘git version 2.25.1’ 14:31:51 using GIT_ASKPASS to set credentials TheoPatToken 14:31:51 ERROR: Error fetching remote repo ‘origin’ 14:31:51 hudson.plugins.git.GitException: Failed to fetch from repo · GitHub14:31:51 at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:999) 14:31:51 at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1241) 14:31:51 at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1305) 14:31:51 at hudson.scm.SCM.checkout(SCM.java:540) 14:31:51 at hudson.model.AbstractProject.checkout(AbstractProject.java:1248) 14:31:51 at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:649) 14:31:51 at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:85) 14:31:51 at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:521) 14:31:51 at hudson.model.Run.execute(Run.java:1895) 14:31:51 at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44) 14:31:51 at hudson.model.ResourceController.execute(ResourceController.java:101) 14:31:51 at hudson.model.Executor.run(Executor.java:442) 14:31:51 Caused by: hudson.plugins.git.GitException: Failed to setup credentials 14:31:51 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2187) 14:31:51 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:635) 14:31:51 at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:170) 14:31:51 at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:161) 14:31:51 at hudson.remoting.UserRequest.perform(UserRequest.java:211) 14:31:51 at hudson.remoting.UserRequest.perform(UserRequest.java:54) 14:31:51 at hudson.remoting.Request$2.run(Request.java:377) 14:31:51 at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78) 14:31:51 at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) 14:31:51 at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) 14:31:51 at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) 14:31:51 at java.base/java.lang.Thread.run(Thread.java:840) 14:31:51 Suppressed: hudson.remoting.Channel$CallSiteStackTrace: Remote call to Theo_node 14:31:51 at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1787) 14:31:51 at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356) 14:31:51 at hudson.remoting.Channel.call(Channel.java:1003) 14:31:51 at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.execute(RemoteGitImpl.java:153) 14:31:51 at jdk.internal.reflect.GeneratedMethodAccessor875.invoke(Unknown Source) 14:31:51 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 14:31:51 at java.base/java.lang.reflect.Method.invoke(Method.java:568) 14:31:51 at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.invoke(RemoteGitImpl.java:138) 14:31:51 at jdk.proxy114/jdk.proxy114.$Proxy204.execute(Unknown Source) 14:31:51 at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:997) 14:31:51 at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1241) 14:31:51 at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1305) 14:31:51 at hudson.scm.SCM.checkout(SCM.java:540) 14:31:51 at hudson.model.AbstractProject.checkout(AbstractProject.java:1248) 14:31:51 at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:649) 14:31:51 at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:85) 14:31:51 at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:521) 14:31:51 at hudson.model.Run.execute(Run.java:1895) 14:31:51 at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44) 14:31:51 at hudson.model.ResourceController.execute(ResourceController.java:101) 14:31:51 at hudson.model.Executor.run(Executor.java:442) 14:31:51 Caused by: java.io.IOException: Cannot run program “cp”: error=2, No such file or directory 14:31:51 at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143) 14:31:51 at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073) 14:31:51 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.createNonBusyExecutable(CliGitAPIImpl.java:2743) 14:31:51 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.createUnixStandardAskpass(CliGitAPIImpl.java:2520) 14:31:51 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2145) 14:31:51 … 11 more 14:31:51 Caused by: java.io.IOException: error=2, No such file or directory 14:31:51 at java.base/java.lang.ProcessImpl.forkAndExec(Native Method) 14:31:51 at java.base/java.lang.ProcessImpl.(ProcessImpl.java:314) 14:31:51 at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:244) 14:31:51 at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110) 14:31:51 … 15 more 14:31:51 ERROR: Error fetching remote repo ‘origin’
The error message Cannot run program "cp": error=2, No such file or directory indicates that the cp command is not found on the Jenkins node where the job is running.
This is likely causing the failure to set up credentials.
@poddingue thanks for replying. I have looked into that, but the cp works fine when I do it manually as well. Here is another clip of error that showed the PatToken is not correct causing the repo is not able to clone. So I think the problem is before Cannot run program "cp": error=2, No such file or directory
Summary
using GIT_ASKPASS to set credentials Temporary Read-Only GitHub Account 12:56:45 ERROR: Error cloning remote repo ‘origin’ 12:56:45 hudson.plugins.git.GitException: Failed to setup credentials 12:56:45 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2187) 12:56:45 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:635) 12:56:45 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:871) 12:56:45 at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:170) 12:56:45 at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:161) 12:56:45 at hudson.remoting.UserRequest.perform(UserRequest.java:211) 12:56:45 at hudson.remoting.UserRequest.perform(UserRequest.java:54) 12:56:45 at hudson.remoting.Request$2.run(Request.java:377) 12:56:45 at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78) 12:56:45 at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) 12:56:45 at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) 12:56:45 at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
Also, from the node logs, i can see there are some errors show below. However, jenkins is able to create a folder in my node, so I assume this error is not relevant
Summary
This is a Unix agent
ERROR: Unexpected error in launching an agent. This is probably a bug in Jenkins
Also: hudson.remoting.Channel$CallSiteStackTrace: Remote call to Theo_node
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1787)
at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
at hudson.remoting.Channel.call(Channel.java:1003)
at hudson.FilePath.act(FilePath.java:1283)
at org.jenkinsci.plugins.envinject.EnvInjectComputerListener.onOnline(EnvInjectComputerListener.java:144)
at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:751)
at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:441)
at hudson.plugins.sshslaves.SSHLauncher.startAgent(SSHLauncher.java:645)
at hudson.plugins.sshslaves.SSHLauncher.lambda$launch$0(SSHLauncher.java:465)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:840)
java.lang.reflect.InaccessibleObjectException: Unable to make private native java.lang.reflect.Field java.lang.Class.getDeclaredFields0(boolean) accessible: module java.base does not “opens java.lang” to unnamed module @7f78fa3e
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:200)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:194)
at org.jenkinsci.plugins.envinject.service.EnvInjectMasterEnvVarsSetter.getModifiers(EnvInjectMasterEnvVarsSetter.java:29)
at org.jenkinsci.plugins.envinject.service.EnvInjectMasterEnvVarsSetter.call(EnvInjectMasterEnvVarsSetter.java:55)
at org.jenkinsci.plugins.envinject.service.EnvInjectMasterEnvVarsSetter.call(EnvInjectMasterEnvVarsSetter.java:19)
at hudson.remoting.UserRequest.perform(UserRequest.java:211)
at hudson.remoting.UserRequest.perform(UserRequest.java:54)
at hudson.remoting.Request$2.run(Request.java:377)
at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:840)
The message “Failed to setup credentials” is reported when the Jenkins git client plugin detects an unexpected failure while launching command line git with credentials.
As setup for credentials in the git client plugin, the cp command creates a separate copy of the credential so that the Java process does not retain an open file descriptor on the credential file. The message Cannot run program "cp": error=2, No such file or directory means that the Java process running on the agent was unable to find the cp program. That message usually indicates that something has harmed the PATH environment variable on the agent running the command. You’ll need to fix that so that the cp command can be found.
If you are unable to fix the PATH configuration on the agent so that the cp command can be found, then you could try switching your configuration from using command line to instead use JGit. JGit is missing some features that are available in command line git and JGit generally uses more memory than command line git, but it is an option. Detailed instructions for that change are in the git client plugin documentation.