Configuring nexus lifecycle as part of the maven build

时间:2017-10-12 10:04:17

标签: maven nexus devops sonatype

I'm trying to configure my Maven build to run the nexus lifecycle (Sonatype clm), so far I have added the following to my projects pom:

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.sonatype.clm</groupId>
                <artifactId>clm-maven-plugin</artifactId>
                <version>2.6.0-01</version>
                <configuration>
                    <serverUrl>http://localhost:8070</serverUrl>
                    <applicationId>test</applicationId>
                    <stage>develop</stage>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

I have then added to the settings.xml file in my ${User.home}/.m2 folder:

<servers>
    <server>
         <id>nexus-site</id>
         <username>nexus_username</username>
         <password>nexus_password</password>
    </server>
</servers>

The issue I have had so far is that when I try to run the command: mvn package clm:evaluate -DskipTests, I get a build failure. The error I get is:

[ERROR] Failed to execute goal com.sonatype.clm:clm-maven-plugin:2.6.0-01:evaluate (default-cli) on project backend: Could not save module scan to C:\Users\user\git\backend\target\sonatype-clm\scan.xml.gz: Unauthorized -> [Help 1]

Has anyone got any ideas what this could be and how I could go about fixing it? Thanks in advance.

1 个答案:

答案 0 :(得分:0)

这似乎是一个身份验证问题。如文档中所述,您需要在serverId文件中将pom标记添加到配置中 -

  

clm.serverId   用于身份验证,并且必须匹配给予Maven设置中指定的CLM服务器的ID

修改: 尝试使用下面提到的配置运行相同的命令:

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.sonatype.clm</groupId>
                <artifactId>clm-maven-plugin</artifactId>
                <version>2.6.0-01</version>
                <configuration>
                    <serverUrl>http://localhost:8070</serverUrl>
                    <stage>develop</stage>
                    <applicationId>test</applicationId>
                    <serverId>nexus-site</serverId>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>evaluate</goal>
                        </goals>
                        <phase>package</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </pluginManagement>
</build>