【问题标题】:how to specify jenkins slave git address from jenkins master in jenkins pipeline script如何在詹金斯管道脚本中从詹金斯主人指定詹金斯奴隶git地址
【发布时间】:2017-08-30 09:31:06
【问题描述】:

我正在尝试为我的 Maven 项目使用 Jenkins 主从架构。我在 Windows 机器上有 Jenkins master,在 Linux 机器上有 slave。现在的问题是当我运行我的 Jenkins 脚本时,它给了我一个错误,比如无法初始化 git 存储库,因为 Jenkins 正试图在 Linux 从机上执行 git.exe。谁能让我知道我该如何解决?

以下是我的 Jenkins 流水线脚本和错误日志

node ('lx-dotoolsd1')
{
    stage 'Checkout'
    git branch: 'master', credentialsId: 'ee44e971-4cce-4e59-95b6-
    da222007775b', url: ' http://o-heena@bitbucket:7990/scm/phoen/audit-
    confirmation.git'
    stage 'Test'
    def pom = readMavenPom file: 'pom.xml'
    print "Build: " + pom.version
    env.POM_VERSION = pom.version
    //batch 'mvn clean compile install'
    //junit '**/target/surefire-reports/TEST-*.xml'
    currentBuild.description = "v${pom.version} (${env.branch})"
}

错误如下

Started by user Patel,Heena
[Pipeline] node
Running on lx-dotoolsd1 in /var/jenkins/workspace/pipelineTest
[Pipeline] {
[Pipeline] stage (Checkout)
Entering stage Checkout
Proceeding
[Pipeline] git
Cloning the remote Git repository
Cloning repository http://o-heena@bitbucket:7990/scm/phoen/audit-confirmation.git
> git.exe init /var/jenkins/workspace/pipelineTest # timeout=10
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Could not init /var/jenkins/workspace/pipelineTest
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:656)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:463)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:152)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:145)
at hudson.remoting.UserRequest.perform(UserRequest.java:152)
at hudson.remoting.UserRequest.perform(UserRequest.java:50)
at hudson.remoting.Request$2.run(Request.java:332)

【问题讨论】:

  • 你检查过你的节点属性了吗?你那里添加你从机的Git路径了吗?
  • 我不知道,能否请您详细说明一下您所说的情况

标签: git jenkins jenkins-pipeline master jenkins-slave


【解决方案1】:

当您的Linux Node 正在从全局工具配置访问Git 路径时,会出现此问题。

由于您的主机是 Windows,Git 路径指向 Git.exe

我认为你没有为你的从机设置Git路径。

转到http://<JENKINS_URL>/computer/<NODE_NAME>/configure,这将带您进入您的从属配置页面。在Node Properties 下检查Tool Location 并从List of Tool Location 选择Git 并添加安装在您从机中的Git 的GIT_HOME 路径。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-11-11
    • 1970-01-01
    • 1970-01-01
    • 2015-07-25
    • 1970-01-01
    • 1970-01-01
    • 2018-08-02
    相关资源
    最近更新 更多