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

时间:2017-03-06 20:25:43

标签: node.js git maven jenkins ssh

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

searchMenu = (Button) findViewById(R.id.menu);
viewOrder = (Button) findViewById(R.id.order);
popUp = new PopupWindow(this);

// layout = new LinearLayout(this);
layout = new FrameLayout(this);


viewOrder.setOnClickListener(new View.OnClickListener() {

    public void onClick(View v) {

        if (click) {
            popUp.showAtLocation(layout, Gravity.TOP | Gravity.RIGHT,
                    0, 0);
            popUp.update(30, 75, 500, 400);
            click = false;
        } else {
            popUp.dismiss();
            click = true;
        }

    }
});

// popUp.setContentView(layout);

params = new LayoutParams(LayoutParams.WRAP_CONTENT,
        LayoutParams.WRAP_CONTENT);

layout.setBackgroundResource(R.drawable.order_back);
// layout.setBackgroundColor(Color.TRANSPARENT);
popUp.setContentView(layout);

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

<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>

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

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

第二个问题是大多数开发人员使用HTTPS连接到存储库,因此他们必须创建SSH密钥并将其注册到GitHub。然后,在构建期间,他们会被提示允许SSH连接,但它在构建的早期发生,以至于它在滚动缓冲区中丢失。

我可以更改哪些内容以使此过程更加无缝?我们可以拥有共享的SSH密钥吗?或者我是否需要更改Node依赖关系的URL以使用git + https?

1 个答案:

答案 0 :(得分:0)

  

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

1 /他们可以继续这样做,确保他们使用 credential helper 来缓存他们的github.com用户名和密码(例如Git for Windows ,您将使用Microsoft Git Credential Manager链接到Credential Manager in Windows

2 /为了不更改您的设置(使用ssh网址),开发人员可以使用以下全局配置:

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

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

相关问题