简体   繁体   English

Maven构建步骤从私有存储库安装Node包

[英]Maven build step to install Node package from private repository

I have a Maven project that pulls in Node dependencies as part of the build using exec-maven-plugin: 我有一个Maven项目,它使用exec-maven-plugin作为构建的一部分来引入Node依赖项:

<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. 其中一个Node依赖项托管在私有Git存储库中。 I don't want enter my password every time I build, so I use the git+ssh protocol in package.json: 我不希望每次构建时输入密码,所以我在package.json中使用git + ssh协议:

  "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. 这对我来说很好,因为我经常使用SSH连接到我的组织私有Git存储库,并且SSH密钥没有密码保护。 It also works on our Jenkins server, which has its own SSH key. 它也适用于我们的Jenkins服务器,它有自己的SSH密钥。

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. 这种方法的第一个问题是我的组织中的一些开发人员密码保护他们的SSH密钥,因此在构建期间提示他们输入密码。

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. 第二个问题是大多数开发人员使用HTTPS连接到存储库,因此他们必须创建SSH密钥并将其注册到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. 然后,在构建期间,系统会提示他们允许SSH连接,但它在构建中很早就会在滚动缓冲区中丢失。

What can I change to make this process more seamless? 我可以改变什么来使这个过程更加无缝? Can we have a shared SSH key? 我们可以拥有共享的SSH密钥吗? Or do I need to change the URL of the Node dependency to use git+https? 或者我是否需要更改Node依赖项的URL以使用git + https?

The second problem is most developers connect to the repository using HTTPS 第二个问题是大多数开发人员使用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 ) 1 /他们可以继续这样做,确保他们使用凭证助手来缓存他们的github.com用户名和密码(例如,使用Git for Windows ,您将使用Microsoft Git Credential Manager ,链接到Credential Manager) Windows

2/ In order to not change your settings (which are using an ssh url), a developer can use a global configuration like: 2 /为了不更改您的设置(使用ssh url),开发人员可以使用全局配置,例如:

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. 这样,任何git@github.com ssh url都将被解释/更改为https。

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

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