简体   繁体   English

无法使用 Ant Target 克隆 GIT 存储库

[英]Unable to clone a GIT repository using Ant Target

I'm trying to write an Ant target to clone a git repository.我正在尝试编写一个 Ant 目标来克隆一个 git 存储库。 Following is the Ant target.以下是 Ant 目标。 Here the ORGANIZATION is the name of the company, GROUP is the group name, and REPOSITORY is the name of the repository.这里的 ORGANIZATION 是公司的名称,GROUP 是组名,REPOSITORY 是存储库的名称。

<target name ="clone">
     <sshexec host="github.ORGANIZATION.com"
        username="git"
        keyfile="${user.home}/.ssh/id_rsa"
        passphrase="pujain"
        trust="true"
        command="git clone git@github.ORGANIZATION.com:GROUP/REPOSITORY.git"/>
  </target>

I'm getting the following exception:我收到以下异常:

[sshexec] You appear to be using ssh to clone a git:// URL. [sshexec] 您似乎在使用 ssh 来克隆 git:// URL。
[sshexec] Make sure your core.gitProxy config option and the [sshexec] 确保您的 core.gitProxy 配置选项和
[sshexec] GIT_PROXY_COMMAND environment variable are NOT set. [sshexec] 未设置 GIT_PROXY_COMMAND 环境变量。

I'm able to execute the same command from cmd.我可以从 cmd 执行相同的命令。

A proper SSH URL would be (for a private self-hosted GitLab server):正确的 SSH URL 将是(对于私有自托管 GitLab 服务器):

git@github.ORGANIZATION.com:GROUPNAME/REPOSITORY.git
                           ^^^^^^^^^^

There should be a ':', and a group or personal account, before the repo name.存储库名称之前应该有一个“:”,以及一个组或个人帐户。

What your sshexec taks is trying to do is:您的sshexec taks试图做的是:

  • connect to host " git@github.ORGANIZATION.com:REPOSITORY.git " (which does not make sense)连接到主机“ git@github.ORGANIZATION.com:REPOSITORY.git ”(这没有意义)
  • once connected to a remote server, execute git clone .连接到远程服务器后,执行git clone

If your script needs to clone a GitLab repo, all you need is an exec task , not an SSH exec task.如果您的脚本需要克隆 GitLab 存储库,您只需要一个exec 任务,而不是 SSH exec 任务。

<exec executable="git" dir="D:\" failonerror="true">
    <arg line="clone git@github.ORGANIZATION.com:REPOSITORY.git dest" />
</exec>

But that won't work with a passphrase-protected private key (unless it loaded in ssh-agent first).但这不适用于受密码保护的私钥(除非它首先加载到 ssh-agent 中)。
You would be better off using read-only deploy key made just for that usage, without passphrase.您最好使用专为该用途制作的只读部署密钥,无需密码。

I don't think this belong in the host name?我不认为这属于主机名? :REPOSITORY.git ? :REPOSITORY.git ?

Perhaps this will work?也许这会奏效?

<target name ="clone"> <sshexec host="github.ORGANIZATION.com" username="user" password="pass" passphrase="para" trust="true" command="git clone git@github.ORGANIZATION.com:REPOSITORY.git D:/dest" /> </target>

And just to clear things up, so, you want to connect to ssh server github.ORGANIZATION.com as user user and then run command git clone whatever D:/dest on that server.只是为了解决问题,因此,您希望以用户用户身份连接到 ssh 服务器github.ORGANIZATION.com ,然后在该服务器上运行命令git clone whatever D:/dest Is that right?那正确吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM