Reputation: 1542
I'm new Jenkins users and I receive the follow error ERROR: Error fetching remote repo 'origin'
, I read some posts about this error here at Stack, some of them says about "capacity disk" in /tmp
, others says about workspace default, but none of them is help me to solve that.
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://github.com/not-show-my-url.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:996)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1237)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1297)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:125)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:93)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:80)
at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress -- https://github.com/thiagolmoraes/Mobile-Contrato.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/not-show-my-url.git'
What is funny, if I use a Freestyle project, add git repository with the same credentials that I use above in Pipeline Project, I got to clone the project, so I think authentication is not the problem.
Dockerfile
FROM node
RUN apt-get update && apt-get upgrade -y \
&& apt-get clean
RUN mkdir /app
WORKDIR /app
COPY package*.json /app/
RUN npm install
COPY src /app/src
EXPOSE 3000
CMD [ "npm", "start" ]
Jenkinsfile
pipeline {
agent any
tools {nodejs "node" }
stages {
stage('Cloning Git') {
steps {
git 'https://github.com/not-show-my-url.git'
}
}
stage('Build') {
steps {
sh 'npm install'
}
}
stage('Test') {
steps {
sh 'npm test'
}
}
}
}
Upvotes: 3
Views: 32853
Reputation: 4274
You have to add the credentials and then, using for config pipline job:
Upvotes: 0
Reputation: 219
Credentials are indeed the issue, you need to add the credentials id to your git pipeline step like so:
pipeline {
agent any
tools {nodejs "node" }
stages {
stage('Cloning Git') {
steps {
git url: 'https://github.com/not-show-my-url.git',
credentialsId: 'your-credentials-id'
}
}
stage('Build') {
steps {
sh 'npm install'
}
}
stage('Test') {
steps {
sh 'npm test'
}
}
}
}
The credentialsId can be obtained from http://yourjenkinsinstall/credentials.
Upvotes: 5