jenkins部署在虚拟机上,windows本地构建 ,节点连接下载agent.jar报错

jenkins-agent.jnlp文件下载放置在"D:\jenkins"

cmd使用命令:

‘’’
java -jar agent.jar -jnlpUrl http://192.168.182.1318080/computer/window_s/jenkins-agent.jnlp -secret 6ee46f7fae9d9c489911022a1c7eb28b20c33fec4d6130a02ccbce2831e06691 -workDir “D:\jenkins”
‘’’

报错:Error: Unable to access jarfile agent.jar

直接运行jenkins-agent.jnlp,显示连接正常:

新建项目,构建报错:

‘’’
Running as SYSTEM
Building on master in workspace /var/jenkins_home/window_s
The recommended git tool is: NONE
No credentials specified

git rev-parse --resolve-git-dir /var/jenkins_home/window_s/iSelenium_Python/.git # timeout=10
Fetching changes from the remote Git repository
git config remote.origin.url git://github.com/chenweizhong-beep/pytest.git # timeout=10
Fetching upstream changes from git://github.com/chenweizhong-beep/pytest.git
git --version # timeout=10
git --version # ‘git version 2.20.1’
git fetch --tags --force --progress – git://github.com/chenweizhong-beep/pytest.git +refs/heads/:refs/remotes/origin/ # timeout=10
git rev-parse refs/remotes/origin/master^{commit} # timeout=10
Checking out Revision 6d1c57964e32088298228897a98dc995506425f6 (refs/remotes/origin/master)
git config core.sparsecheckout # timeout=10
git checkout -f 6d1c57964e32088298228897a98dc995506425f6 # timeout=10
Commit message: “ci_demo”
git rev-list --no-walk 6d1c57964e32088298228897a98dc995506425f6 # timeout=10
[window_s] $ cmd /c call /tmp/jenkins8678531231940763932.bat
FATAL: command execution failed
java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
Caused: java.io.IOException: Cannot run program “cmd” (in directory “/var/jenkins_home/window_s”): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at hudson.Proc$LocalProc.(Proc.java:253)
at hudson.Proc$LocalProc.(Proc.java:222)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:996)
at hudson.Launcher$ProcStarter.start(Launcher.java:508)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:144)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:92)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:21)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:809)
at hudson.model.Build$BuildExecution.build(Build.java:199)
at hudson.model.Build$BuildExecution.doRun(Build.java:164)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:517)
at hudson.model.Run.execute(Run.java:1912)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:100)
at hudson.model.Executor.run(Executor.java:432)
Build step ‘Execute Windows batch command’ marked build as failure
Finished: FAILURE
‘’’

  • 第一个报错是说没有权限操作agent.jar,这个文件应该是在创建节点之后通过页面下载的,点击下载之后建议将其放置在C盘之外的地方,以免操作时由于权限保护影响到运行。
    image
  • 第二个报错,从日志里看,你没有在jenkins项目配置中指定运行节点,导致项目构建实际上是运行在master节点,也就是jenkins存在的位置中,而不是你上一步创建的子节点里。
    image

谢谢老师,已解决

关闭