且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法运行程序“mvn"错误=2,没有这样的文件或目录

更新时间:2022-03-10 08:54:17

这里有很多东西.

您要么没有在作业配置中选择 Maven 版本.或者你没有配置 Jenkins 来安装 Maven 版本.或者你希望在 Slave 上使用本地安装的 Maven,但它没有为 jenkins 用户配置.

You either didn't select Maven version in Job configuration. Or you didn't configure Jenkins to install a Maven version. Or you expected to use locally installed Maven on the Slave, but it's not configured for jenkins user.

由于我不知道你配置了什么(或没有配置)以及你期望使用什么,我无法直接回答,但我可以解释它是如何工作的.

Since I don't know what you've configured (or didn't configure) and what you expected to use, I can't answer directly, but I can explain how it works.

  • 您必须在本地安装 Maven
  • 您必须能够使用 jenkins 用户启动它
  1. 执行sudo jenkins,然后在你的Slave上执行mvn验证jenkins用户是否可以运行mvn
  2. 如果失败,您需要正确安装/配置 Maven
  1. Execute sudo jenkins, and then execute mvn on your Slave to verify that jenkins user can run mvn
  2. If that fails, you need to properly install/configure Maven

  • 在作业配置中,对于 Maven 版本,您必须选择 Default.这是使用本地安装在节点上的版本的设置
  • In Job configuration, for Maven Version, you must select Default. This is the setting that uses the version that's installed locally on the node
    • 您必须转到 Jenkins 全局工具配置,并使用自动安装程序(来自网络)配置 Maven 版本.
    • 在作业配置中,对于 Maven 版本,您必须选择您刚刚配置的那个特定版本.