linux - 为声明式管道指定要在多操作系统代理 Jenkins 环境中使用的 Git 工具
问题描述
我对 Jenkins 还很陌生,但我正在尝试建立一个多操作系统代理环境。Jenkins Master 在 Windows Server 2019 上,我有一个单独的 Windows Server 2019 代理 (Laconia) 和一个 Ubuntu 20.04 代理 (Java8Europa) 都通过 SSH 成功连接。我还在这两个实例上配置了 Git,并在全局工具配置中创建了两个 Git 工具位置,如下所示,并确认这些位置可以在各个机器上运行。
我遇到的问题是,即使我将各个节点设置为使用正确的 Git 工具,如下所示,如果我尝试执行一个简单的声明性管道作业,它也只会使用列表顶部的 Git 实例以上(WindowsGit)。我的声明性管道以正确执行的 Windows 脚本开始,但是当它尝试在 Linux 机器上执行 Linux shell 脚本时,它在尝试使用 WindowsGit 时失败。
我将在下面包含控制台日志输出,但是无论如何我可以通过 Jenkinsfile 强制每个代理应该使用哪个 git 工具?我确实读到了代理忽略了一些工具位置,并且有一些文章表明 Git 是其中之一,事实上,如果我将 Git 安装的顺序切换为将 LinuxGit 放在顶部,则管道无法运行似乎支持这些文章的 Windows 脚本。我还有其他方法可以解决这个问题吗?
[Pipeline] withEnv
[Pipeline] {
[Pipeline] bat
administrator@LACONIA C:\Jenkins\WorkingRepo\workspace\ReidacusOrg_siplogscanner_main@2>hello.bat
administrator@LACONIA C:\Jenkins\WorkingRepo\workspace\ReidacusOrg_siplogscanner_main@2>echo "This is coming from a Windows Script"
"This is coming from a Windows Script"
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Say Hello)
[Pipeline] node
Running on Java8(Europa) in /home/andrew/jenkins/workspace/ReidacusOrg_siplogscanner_main
[Pipeline] {
[Pipeline] checkout
using credential GitHubAPIAccess
Cloning the remote Git repository
Cloning with configured refspecs honoured and without tags
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Could not init /home/andrew/jenkins/workspace/ReidacusOrg_siplogscanner_main
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:997)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:752)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:161)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:154)
at hudson.remoting.UserRequest.perform(UserRequest.java:211)
at hudson.remoting.UserRequest.perform(UserRequest.java:54)
at hudson.remoting.Request$2.run(Request.java:376)
at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78)
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)
Suppressed: hudson.remoting.Channel$CallSiteStackTrace: Remote call to Java8(Europa)
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1800)
at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
at hudson.remoting.Channel.call(Channel.java:1001)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.execute(RemoteGitImpl.java:146)
at jdk.internal.reflect.GeneratedMethodAccessor882.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.invoke(RemoteGitImpl.java:132)
at com.sun.proxy.$Proxy96.execute(Unknown Source)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1221)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1299)
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.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: hudson.plugins.git.GitException: Error performing git command: "C:\Git\bin\git.exe" init /home/andrew/jenkins/workspace/ReidacusOrg_siplogscanner_main
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2457)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2380)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2376)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1923)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:995)
... 11 more
Caused by: java.io.IOException: Cannot run program ""C:\Git\bin\git.exe"" (in directory "/home/andrew/jenkins/workspace/ReidacusOrg_siplogscanner_main"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at hudson.Proc$LocalProc.<init>(Proc.java:252)
at hudson.Proc$LocalProc.<init>(Proc.java:221)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:996)
at hudson.Launcher$ProcStarter.start(Launcher.java:508)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2443)
... 15 more
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 20 more
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Say Bye)
Stage "Say Bye" skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Cloning repository https://github.com/reidacus/siplogscanner.git
"C:\Git\bin\git.exe" init /home/andrew/jenkins/workspace/ReidacusOrg_siplogscanner_main #
timeout=10
GitHub has been notified of this commit’s build result
ERROR: Error cloning remote repo 'origin'**
Finished: FAILURE
提前致谢。
解决方案
推荐阅读
- node.js - keystonejs模型中的动态类型选择
- vba - 循环和 IF 语句花费太多时间
- docker - Dockerfile 注释中的哈希“#”是否需要在第 1 列中?
- python - 在 PySide 中创建另一个相同类的窗口
- nexus - 创建公共 pypi 存储库的完整副本/离线副本
- apache-camel - 如何在 apache camel xml 配置文件中过滤 jms 消息
- java - 春天 i18n 不工作
- php - 如何在 yii 中使用复选框进行排序和过滤
- ios - 使用多部分请求上传文件 - Swift 4
- javascript - 检查表单是否已通过 php 中的 ajax 提交