Java “无法从 scm 存储库获取修订信息”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1619330/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 17:54:18  来源:igfitidea点击:

"Cannot get the revision information from the scm repository"

javamaven-2pom.xml

提问by Altug

I get maven error :

我收到 Maven 错误:

"Cannot get the revision information from the scm repository"

“无法从 scm 存储库获取修订信息”

Any idea how to solve this ?

知道如何解决这个问题吗?

Thanks.

谢谢。

采纳答案by Pascal Thivent

A quick search on Googleseems to indicate that this error is related to the buildnumber-maven-plugin. However, I couldn't reproduce the error on the command line on my machine (Maven 2.2.1, Java 1.6.0_16, svn 1.6.5 on GNU/Linux):

在 Google 上快速搜索似乎表明此错误与 buildnumber-maven-plugin 相关。但是,我无法在我的机器上的命令行上重现错误(Maven 2.2.1、Java 1.6.0_16、GNU/Linux 上的 svn 1.6.5):

pascal@laptop:~/tmp/$ svn co http://wiquery.googlecode.com/svn/branches/1.0-m2 wiquery
...
pascal@laptop:~/tmp/$ cd wiquery
pascal@laptop:~/tmp/wiquery$ mvn validate
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building WiQuery project
[INFO]    task-segment: [validate]
[INFO] ------------------------------------------------------------------------
[INFO] [buildnumber:create {execution: default}]
[INFO] Checking for local modifications: skipped.
[INFO] Updating project files from SCM: skipped.
[INFO] Executing: /bin/sh -c cd /home/pascal/tmp/wiquery && svn --non-interactive info
[INFO] Working directory: /home/pascal/tmp/wiquery
[INFO] Storing buildNumber: 208 at timestamp: 1256499766371
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Sun Oct 25 20:42:46 CET 2009
[INFO] Final Memory: 13M/77M
[INFO] ------------------------------------------------------------------------
pascal@laptop:~/tmp/wiquery$ 

From what I can see on Google, possible causes of problem include:

从我在谷歌上看到的,问题的可能原因包括:

  • svn executable (i.e. svn.exe on windows) not being on the path
  • too old svnkit version compared to your svn client (see this thread)
  • missing environment variables on OS X (see MOJO-1289)
  • etc etc
  • svn 可执行文件(即 Windows 上的 svn.exe)不在路径上
  • 与您的 svn 客户端相比,svnkit 版本太旧(请参阅此线程
  • 缺少 OS X 上的环境变量(请参阅MOJO-1289
  • 等等等等

But without more information on your context, your environment, what you are doing, when this error occurs, etc, it seems hard to go further in the diagnostic.

但是,如果没有关于您的上下文、您的环境、您正在做什么、何时发生此错误等的更多信息,似乎很难在诊断中更进一步。

回答by Mike Cornell

I've run into this error with the buildnumber-maven-plugin when I was helping a coworker migrate his project to Maven.

当我帮助同事将他的项目迁移到 Maven 时,我遇到了 buildnumber-maven-plugin 的这个错误。

We had not yet checked the code into svn in the migrated project, so therefore the .svn folders didn't exist. Obviously it couldn't get the svn revision since the data did not exist.

我们尚未将代码检入迁移项目中的 svn,因此 .svn 文件夹不存在。显然它无法获得 svn 修订版,因为数据不存在。

The solution was to comment out the plugin, import the code to svn. Perform a build with the svn enabled code, then bring the plugin back in and troubleshoot any additional errors. (We had some issues with doUpdate when running on Hudson, so we removed those steps).

解决办法是把插件注释掉,将代码导入svn。使用启用 svn 的代码执行构建,然后将插件带回并解决任何其他错误。(在 Hudson 上运行时,我们遇到了 doUpdate 的一些问题,因此我们删除了这些步骤)。

回答by xmedeko

This error is caused by the javasvn provider in the buildnumber-maven-plugin when .svn does not exists. Either checkout your project from SVN or do not use javasvn. Without javasvn the buildnumber-maven-plugin uses command line svn client and then in this case the buildnumber-maven-plugin can proceed even without the .svn directory (but the build number is not set correctly).

此错误是由 buildnumber-maven-plugin 中的 javasvn 提供程序在 .svn 不存在时引起的。从 SVN 签出您的项目或不使用 javasvn。如果没有 javasvn,buildnumber-maven-plugin 使用命令行 svn 客户端,然后在这种情况下,即使没有 .svn 目录,buildnumber-maven-plugin 也可以继续进行(但内部版本号设置不正确)。

I think it is a bug in the buildnumber-maven-plugin that the javasvn cannot proceed when .svn directory is missing.

我认为这是 buildnumber-maven-plugin 中的一个错误,即当 .svn 目录丢失时,javasvn 无法继续。

回答by CsBalazsHungary

One case what we could resolve here with Netbeans8:

我们可以在这里使用Netbeans8解决的一种情况:

enter image description here

在此处输入图片说明

note that Prefer Old Subversion 1.6 Format is checked

请注意,已选中 Prefer Old Subversion 1.6 Format

and also I matched the correct apache SVN to the given maven properties

并且我将正确的 apache SVN 与给定的 maven 属性匹配

回答by Shiva4palz

huh... was working on migrating svn to git... and pom xml had svn repo link hence updated it to git and it worked with updating pom xml scm

嗯...正在致力于将 svn 迁移到 git...并且 pom xml 有 svn repo 链接,因此将其更新为 git 并且它与更新 pom xml scm 一起工作

回答by AlexHH

I had the problem too an my solution on Windows was: to set the environment variable PATH to "...\git\bin". Java couldn't find the directory to use Git.

我也遇到了这个问题,我在 Windows 上的解决方案是:将环境变量 PATH 设置为“...\git\bin”。Java 找不到使用 Git 的目录。

回答by glenn380

Make sure Jenkins and the OS are pointed to the same version of Java.

确保 Jenkins 和操作系统指向相同版本的 Java。

I had a similar problem running Jenkins 2.121.2 on Windows.

我在 Windows 上运行 Jenkins 2.121.2 时遇到了类似的问题。

The build would succeed, but I wasn't getting any scm data.

构建会成功,但我没有得到任何 scm 数据。

The relevant console output:

相关的控制台输出:

[INFO] --- buildnumber-maven-plugin:1.4:create (default) @ amis ---
[INFO] Executing: cmd.exe /X /C "svn --non-interactive info"
[INFO] Working directory: D:\Program Files (x86)\Jenkins\workspace\myWebapp
[WARNING] Cannot get the revision information from the scm repository, proceeding with revision of Unavailable : 
Exception while executing SCM command.
[INFO] Storing buildNumber: Unavailable at timestamp: 1534704912706
[INFO] Executing: cmd.exe /X /C "svn --non-interactive info"
[INFO] Working directory: D:\Program Files (x86)\Jenkins\workspace\myWebapp
[WARNING] Cannot get the branch information from the scm repository, proceeding with UNKNOWN_BRANCH : 
Exception while executing SCM command.
[INFO] Storing buildScmBranch: UNKNOWN_BRANCH

In DOS, the following command would work, however:

但是,在 DOS 中,以下命令可以工作:

D:\Program Files (x86)\Jenkins\workspace\myWebapp\svn --non-interactive info

D:\Program Files (x86)\Jenkins\workspace\myWebapp\svn --非交互式信息

That is, I would get the expected scm info. So svn was in the path, no problem there.

也就是说,我会得到预期的 scm 信息。所以 svn 在路径中,没有问题。

It turns out the paths to my Java versions were crossed up.

事实证明,我的 Java 版本的路径被交叉了。

The first Java-related path in my PATH environment variable was:

我的 PATH 环境变量中第一个与 Java 相关的路径是:

C:\Program Files (x86)\Common Files\Oracle\Java\javapath

But Jenkins was configured to use:

但是 Jenkins 被配置为使用:

C:\Program Files\Java\jdk1.8.0_181 

In the PATH environment variable, I replaced the x86 Java path with the path that Jenkins was pointed to and it worked.

在 PATH 环境变量中,我将 x86 Java 路径替换为 Jenkins 指向的路径并且它可以工作。

I didn't root out the hows or whys of the paths. The two java.exe files that resolved from each path seemed to be the same version. The x86 version was able to run svn. The root cause is above my pay grade.

我没有找出路径的方法或原因。从每个路径解析的两个 java.exe 文件似乎是相同的版本。x86 版本能够运行 svn。根本原因高于我的工资等级。

回答by D3VLPR

For the git users, who are also seeing the same issue - Try adding the PATH of git to environmental variables. If that didn't work - follow the solution listed here - Cannot get the branch information from the scm repository

对于也遇到相同问题的 git 用户 - 尝试将 git 的 PATH 添加到环境变量中。如果这不起作用 - 请按照此处列出的解决方案进行操作 -无法从 scm 存储库获取分支信息