git - Maven BuildNumber 插件 Git SSH
问题描述
我有一个使用 的 maven 项目,buildnumber-maven-plugin
当我将项目从 GitLab 移动到 GitHub 时,我已经更改了 git 远程,但是现在当我尝试运行时mvn clean install
出现错误
ssh: Could not resolve hostname github.com:lukebrewerton: Name or service not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
但是我可以使用我的命令行和推/拉等克隆 GH 存储库,这似乎是行不通的 maven 命令。
我的 pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.socialgamer</groupId>
<artifactId>pyx</artifactId>
<version>0.7.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>pyx</name>
<scm>
<url>https://github.com/lukebrewerton/cahds</url>
<connection>scm:git:ssh://git@github.com:lukebrewerton/cahds.git</connection>
<developerConnection>scm:git:ssh://git@github.com:lukebrewerton/cahds.git</developerConnection>
</scm>
....
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>true</doCheck>
<doUpdate>true</doUpdate>
<revisionOnScmFailure>0</revisionOnScmFailure>
<shortRevisionLength>7</shortRevisionLength>
</configuration>
</plugin>
解决方案
我们这里有两个问题:
- POM 中的格式与所需的格式不对应:(
scm:git:ssh://server_name[:port]/path_to_repository
https://maven.apache.org/scm/git.html )。 - 传递给 Git 的 URL 与 Git 支持的格式不对应:https ://git-scm.com/docs/git-pull#URLS
据我所知,GitHub 中的克隆按钮为 Maven 和 Git 本身提供了一个无效的 URL。否则你应该把它提交给 SCM,我会看看它。
推荐阅读
- sql - 我可以更改使用 CREATE TABLE AS SELECT FROM Table A 创建的表 B 中列的数据类型和最大长度吗?
- javascript - MongoDB 中关于设计 Shift 模式的疑问
- ssl - 如何让虹吸管识别 SSL 证书包
- django - 如何使用 GitLab-CI 中的 docker 图像设置 Selenium Grid?
- python - 如何删除 ruamel.yaml 中的评论?
- c# - Json.NET 不能仅使用隐式运算符自动处理值类型吗?
- bash - 从 bash 脚本更改日期
- python - 如何在新数据上使用 sklearn TfidfVectorizer
- elasticsearch - 如何从日志中的字段设置 Logstash 管道中 Elasticsearch 输出的操作?
- javascript - Firebase 查询需要一个变量才能执行,但该变量是异步生成的