Maven构建一个步骤来从私有存储库安装Node包 [英] Maven build step to install Node package from private repository

查看:145
本文介绍了Maven构建一个步骤来从私有存储库安装Node包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Maven项目,它使用exec-maven-plugin作为构建的一部分引入Node依赖项:

 << ;插件> 
< groupId> org.codehaus.mojo< / groupId>
< artifactId> exec-maven-plugin< / artifactId>
<配置>
< workingDirectory> src / main< / workingDirectory>
< / configuration>
<执行次数>
<执行>
< id> npm-install< / id>
<配置>
< executable> npm< / executable>
<参数>
<参数>安装< /参数>
< / arguments>
< / configuration>
<阶段>初始化< /阶段>
<目标>
< goal> exec< / goal>
< /目标>
< /执行>

其中一个Node依赖关系托管在私有Git存储库中。我不想在每次构建时输入密码,所以我在package.json中使用git + ssh协议:

  依赖关系:{
sass-theme:git + ssh://git@github.com/MyOrg/sass-theme.git#v1.0.2,
node-sass :^ 4.5.0
}

这对我来说很好,因为我经常连接到我的组织使用SSH的私人Git存储库,并且SSH密钥不受密码保护。它也适用于我们的Jenkins服务器,它有自己的SSH密钥。



这种方法的第一个问题是我的组织密码保护他们的SSH密钥的一些开发人员,所以他们'b
$ b

第二个问题是大多数开发人员使用HTTPS连接到存储库,所以他们必须创建一个SSH密钥并注册它与GitHub。然后,在构建过程中,系统会提示他们允许SSH连接,但在构建过程中发生的这种情况在滚动缓冲区中会丢失。



什么可以我改变了,使这个过程更加无缝?我们可以共享一个SSH密钥吗?或者是否需要更改节点依赖项的URL以使用git + https?

解决方案


第二个问题是大多数开发人员使用HTTPS连接到存储库


1 /他们可以继续这样做,确保他们使用 凭证助手 来缓存他们的 github。 com 用户名和密码(使用 Windows版Git 例如,您将使用 Microsoft Git Credential Manager ,链接到 Windows中的凭证管理器



2 /为了不改变你的设置(这是使用g ssh url),开发人员可以使用全局配置,如:

  git config --global url。https:/ /github.com\".insteadOf git + ssh://git@github.com 

这样,任何 git@github.com ssh url会被解释/更改为https。


I have a Maven project that pulls in Node dependencies as part of the build using exec-maven-plugin:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <configuration>
        <workingDirectory>src/main</workingDirectory>
    </configuration>
    <executions>
        <execution>
            <id>npm-install</id>
            <configuration>
                <executable>npm</executable>
                <arguments>
                    <argument>install</argument>
                </arguments>
            </configuration>
            <phase>initialize</phase>
            <goals>
                <goal>exec</goal>
            </goals>
        </execution>

One of the Node dependencies is hosted in a private Git repository. I don't want enter my password every time I build, so I use the git+ssh protocol in package.json:

  "dependencies": {
    "sass-theme": "git+ssh://git@github.com/MyOrg/sass-theme.git#v1.0.2",
    "node-sass": "^4.5.0"
  }

This works fine for me since I regularly connect to my organizations private Git repository using SSH, and the SSH key is not password protected. It also works on our Jenkins server, which has its own SSH key.

The first problem with this approach is some developers in my organization password protect their SSH keys, so they're prompted to enter their password during the build.

The second problem is most developers connect to the repository using HTTPS, so they have to create an SSH key and register it with GitHub. Then, during the build, they're prompted to allow the SSH connection, but it occurs so early in the build that it gets lost in the scroll buffer.

What can I change to make this process more seamless? Can we have a shared SSH key? Or do I need to change the URL of the Node dependency to use git+https?

解决方案

The second problem is most developers connect to the repository using HTTPS

1/ They can continue to do that, making sure they are using a credential helper to cache their github.com username and password (with Git for Windows for instance, you would be using the Microsoft Git Credential Manager, linked to the Credential Manager in Windows)

2/ In order to not change your settings (which are using an ssh url), a developer can use a global configuration like:

git config --global url."https://github.com".insteadOf git+ssh://git@github.com

That way, any git@github.com ssh url would be interpreted/changed as an https one.

这篇关于Maven构建一个步骤来从私有存储库安装Node包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆