TMo*_*aes 3 git jenkins jenkins-pipeline
我是新的 Jenkins 用户,收到以下错误ERROR: Error fetching remote repo 'origin',我在 Stack 上阅读了一些关于此错误的帖子,其中一些说有关“容量磁盘” /tmp,其他人说有关工作区默认值,但没有一个能帮助我解决那。
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'
Run Code Online (Sandbox Code Playgroud)
有趣的是,如果我使用 Freestyle 项目,使用与上面在 Pipeline Project 中使用的相同凭据添加 git 存储库,我必须克隆该项目,所以我认为身份验证不是问题。
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" ]
Run Code Online (Sandbox Code Playgroud)
詹金斯文件
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'
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
小智 5
凭证确实是问题所在,您需要将凭证 ID 添加到 git 管道步骤中,如下所示:
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'
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
可以从http://yourjenkinsinstall/credentials 获取credentialsId。
| 归档时间: |
|
| 查看次数: |
26923 次 |
| 最近记录: |