英文:
Jenkins Pipeline couldn't init the repo (Windows controller, Mac agent)
问题
I'm here to provide you with the translated content. Here is the translation of the provided text:
我有一台运行Windows的Jenkins控制机器和一台运行MacOS的代理机器。两台机器都安装了git。
如果我在我的Mac终端中键入`where git`,我会得到这个输出:`/usr/bin/git`。
**我的目标是:** 我试图将'team-ci'存储库检出到Pipeline项目的工作空间中。
问题在于,如果我使用以下方式进行操作
```java
git branch: 'main',
credentialsId: "defaultssh",
url: "git@global.com:team/team-ci.git"
, 那么它会尝试使用Windows可执行文件来检出'main'分支,因此,我选择了checkout
方法。
这是“全局工具配置”中的“Git安装”是什么样子的:
我编写了这个流水线代码:
pipeline {
agent {
label 'mac1'
}
stages {
stage('执行') {
steps {
script {
def branch = '*/main'
def credentialsId = 'defaultssh'
def projectUrl = "git@global.company.gitlab.com:team/team-ci.git"
def gitTool = isUnix() ? 'git_mac' : 'git_win'
echo "gitTool: " + gitTool
checkout([$class: 'GitSCM', branches: [[name: branch]],
gitTool: gitTool,
userRemoteConfigs: [[credentialsId: credentialsId, url: projectUrl]]
])
}
}
}
}
}
当我尝试运行此Pipeline项目时,在控制台中输出以下异常信息:
13:14:19 gitTool: git_mac
13:14:19 [Pipeline] checkout
13:14:19 推荐的git工具是:无
13:14:19 使用凭据defaultssh
13:14:19 克隆远程Git存储库时出错
13:14:19 错误:无法初始化/Library/Automation/jenkins/workspace/mac_pipeline_project的远程存储库
13:14:19 由于:无法执行git命令:/usr/bin/git init /Library/Automation/jenkins/workspace/mac_pipeline_project
13:14:19 由于:java.io.IOException:无法运行程序“/Library/Automation/jenkins/workspace/”(位于“/Library/Automation/jenkins/workspace/mac_pipeline_project”):错误=13,权限被拒绝
13:35:19 由于:java.io.IOException:错误=13,权限被拒绝
13:35:20 克隆远程Git存储库时出错
我应该怎么做才能成功克隆'team-ci'项目?
If you need any further assistance, feel free to ask.
<details>
<summary>英文:</summary>
I have a Jenkins controller machine that runs Windows and an agent machine that runs on MacOS. Both machines have git installed.
If I type `where git` in my Mac's terminal, I get this output: `/usr/bin/git`.
**My goal is:** I'm trying to check out the 'team-ci' repo into the workspace of the Pipeline Project.
The issue is that if I do it using
```java
git branch: 'main',
credentialsId: "defaultssh",
url: "git@global.com:team/team-ci.git"
, then it tries to check out the 'main' branch using the Windows executable, so instead, I opted out for the checkout
method.
Here's what the "Git installations" in "Global Tool Configuration" look like:
I wrote this pipeline code:
pipeline {
agent {
label 'mac1'
}
stages {
stage('Execute') {
steps {
script {
def branch = '*/main'
def credentialsId = 'defaultssh'
def projectUrl = "git@global.company.gitlab.com:team/team-ci.git"
def gitTool = isUnix() ? 'git_mac' : 'git_win'
echo "gitTool: " + gitTool
checkout([$class: 'GitSCM', branches: [[name: branch]],
gitTool: gitTool,
userRemoteConfigs: [[credentialsId: credentialsId, url: projectUrl]]
])
}
}
}
}
}
When I try to run this Pipeline Project, it outputs these exceptions in the console:
13:14:19 gitTool: git_mac
13:14:19 [Pipeline] checkout
13:14:19 The recommended git tool is: NONE
13:14:19 using credential defaultssh
13:14:19 Cloning the remote Git repository
13:14:19 ERROR: Error cloning remote repo 'origin'
13:14:19 hudson.plugins.git.GitException: Could not init /Library/Automation/jenkins/workspace/mac_pipeline_project
13:14:19 Caused by: hudson.plugins.git.GitException: Error performing git command: /usr/bin/git init /Library/Automation/jenkins/workspace/mac_pipeline_project
13:14:19 Caused by: java.io.IOException: Cannot run program "/Library/Automation/jenkins/workspace/" (in directory "/Library/Automation/jenkins/workspace/mac_pipeline_project"): error=13, Permission denied
13:35:19 Caused by: java.io.IOException: error=13, Permission denied
13:35:20 ERROR: Error cloning remote repo 'origin'
What can I do to successfully clone the 'team-ci' project?
答案1
得分: 1
我必须前往“仪表板/管理 Jenkins/节点/mac1”,并将“工具位置”值从“/Library/Automation/jenkins/workspace/”更改为“(Git) git_mac” 工具下的“/usr/bin/git”。
英文:
I had to go to the Dashboard/Manage Jenkins/Nodes/mac1 and change the "Tool locations" value from "/Library/Automation/jenkins/workspace/" to "/usr/bin/git" under the "(Git) git_mac" tool.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论