【问题标题】:LocalRepositoryNotAccessibleException Could not create local repository at /testartifacts/m2repositoryLocalRepositoryNotAccessibleException 无法在 /testartifacts/m2repository 创建本地存储库
【发布时间】:2020-11-12 06:23:31
【问题描述】:

我正在 Azure DevOps 中运行一个 CI 管道,其中包含一个名为“下载提供的依赖项 JAR”的 Maven 构建步骤。

这一步之前是有效的,但是它突然给我这个错误:

org.apache.maven.repository.LocalRepositoryNotAccessibleException: Could not create local repository at /testartifacts/m2repository

我也收到了警告:

##[warning]Could not parse the effective POM.

这就是它在 DevOps 中的样子:

我已将其设置为在运行构建之前清理工作目录,但这没有帮助。

根据我的阅读,这似乎是权限问题。

构建代理不应该已经有权限了吗?

感谢您的帮助。

这是我的 pom.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>au.com.mycompany.perfunittests</groupId>
    <artifactId>myapplication</artifactId>
    <version>1.0-SNAPSHOT</version>

    <profiles>
        <!-- Load Test -->
        <profile>
            <id>profile.loadTest</id>
            <!-- Test will only be chosen when -DtestType=load -->
            <activation>
                <!-- Test will be chosen when property testname is not supplied, i.e. the default -->
                <property>
                    <name>!testname</name>
                </property>
            </activation>
            <properties>
                <testname>loadtest.myapplication</testname>
                <isbenchmarktest>false</isbenchmarktest>
            </properties>
        </profile>
        <!-- Benchmark Test for Common -->
        <profile>
            <id>profile.benchmarkTest.Common</id>
            <activation>
                <property>
                    <name>testname</name>
                    <value>unittest.myapplication.common</value>
                </property>
            </activation>
            <properties>
                <testname>unittest.myapplication.common</testname>
                <isbenchmarktest>true</isbenchmarktest>
            </properties>
        </profile>
        <!-- Benchmark Test for Configuration -->
        <profile>
            <id>profile.benchmarkTest.Configuration</id>
            <activation>
                <property>
                    <name>testname</name>
                    <value>unittest.myapplication.configuration</value>
                </property>
            </activation>
            <properties>
                <testname>unittest.myapplication.configuration</testname>
                <isbenchmarktest>true</isbenchmarktest>
            </properties>
        </profile>
        <!-- Benchmark Test for Dashboard - note this is legacy Dashboard API calls -->
        <profile>
            <id>profile.benchmarkTest.Dashboard</id>
            <activation>
                <property>
                    <name>testname</name>
                    <value>unittest.myapplication.dashboard</value>
                </property>
            </activation>
            <properties>
                <testname>unittest.myapplication.dashboard</testname>
                <isbenchmarktest>true</isbenchmarktest>
            </properties>
        </profile>
        <!-- Benchmark Test for Management -->
        <profile>
            <id>profile.benchmarkTest.Management</id>
            <activation>
                <property>
                    <name>testname</name>
                    <value>unittest.myapplication.management</value>
                </property>
            </activation>
            <properties>
                <testname>unittest.myapplication.management</testname>
                <isbenchmarktest>true</isbenchmarktest>
            </properties>
        </profile>
    </profiles>
    
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- No need to run deploy lifecycle -->
        <maven.deploy.skip>true</maven.deploy.skip>

        <!-- No need to create a JAR -->
        <jar.skipIfEmpty>true</jar.skipIfEmpty>
        <maven.install.skip>true</maven.install.skip>

        <!-- Run in perftest env unless overridden using -Denv -->
        <env>perf</env>
    </properties>

    <repositories>
        <repository>
            <id>mycompanyproject-visualstudio.com-maven</id>
            <url>https://mycompanyproject.pkgs.visualstudio.com/_packaging/maven/maven/v1</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

    <build>
        <plugins>
            <plugin>
                <groupId>com.lazerycode.jmeter</groupId>
                <artifactId>jmeter-maven-plugin</artifactId>
                <version>2.8.6</version>
                <executions>
                    <execution>
                        <id>jmeter-tests</id>
                        <goals>
                            <goal>jmeter</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <jmeterVersion>5.0</jmeterVersion>
                    <!-- JMX file for unittests lives in the same directory as pom.xml -->
                    <testFilesDirectory>${project.basedir}</testFilesDirectory>
                    <testFilesIncluded>
                        <jMeterTestFile>${testname}.jmx</jMeterTestFile>
                    </testFilesIncluded>
                    <!-- Need to save in CSV format for lightning plugin -->
                    <resultsFileFormat>csv</resultsFileFormat>
                    <!-- Don't append timestamp to JTL file, so lightning can find it more easily -->
                    <testResultsTimestamp>false</testResultsTimestamp>
                    <!-- Don't stop the test on a failure -->
                    <ignoreResultFailures>true</ignoreResultFailures>
                    <propertiesUser>
                        <env>${env}</env>
                        <url.myapplication>perfweb.myapplication.com</url.myapplication>
                        <unittest.path.resources>${project.basedir}</unittest.path.resources>
                        <unittest.path.testdata>${project.basedir}/data</unittest.path.testdata>
                    </propertiesUser>
                    <!-- Additional output JTL format for lightning plugin -->
                    <propertiesJMeter>
                        <httpclient.reset_state_on_thread_group_iteration>false</httpclient.reset_state_on_thread_group_iteration>
                        <jmeter.save.saveservice.print_field_names>true</jmeter.save.saveservice.print_field_names>
                        <jmeter.save.saveservice.successful>true</jmeter.save.saveservice.successful>
                        <jmeter.save.saveservice.label>true</jmeter.save.saveservice.label>
                        <jmeter.save.saveservice.time>true</jmeter.save.saveservice.time>
                    </propertiesJMeter>
                    <customPropertiesFiles>
                        <file>${project.basedir}/${testname}.threadgroups.conf</file>
                    </customPropertiesFiles>
                    <!-- Additional libraries (mostly) from jmeter-plugins.org -->
                    <jmeterExtensions>
                        <artifact>au.com.mycompany:timinglistener:0.2-SNAPSHOT</artifact>
                        <artifact>com.google.code.gson:gson:2.8.2</artifact>
                        <artifact>com.opencsv:opencsv:4.1</artifact>
                        <artifact>com.sumologic.plugins.log4j:sumologic-log4j2-appender:1.7</artifact>
                    </jmeterExtensions>
                    <jMeterProcessJVMSettings>
                        <xms>2048</xms>
                        <xmx>2048</xmx>
                        <arguments>
                            <argument>-Dunittest.path.logs=${project.build.directory}/jmeter/logs</argument>
                            <argument>-Dunittest.testname=${testname}</argument>
                            <argument>-Dlog4j.configurationFile=file://${project.basedir}/log4j2.xml</argument>
                        </arguments>
                    </jMeterProcessJVMSettings>
                    <downloadExtensionDependencies>true</downloadExtensionDependencies>
                </configuration>
            </plugin>
            <plugin>
                <groupId>uk.co.automatictester</groupId>
                <artifactId>jmeter-lightning-maven-plugin</artifactId>
                <version>1.5.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>lightning</goal>
                        </goals>
                        <configuration>
                            <mode>verify</mode>
                            <!-- Lightning XML definition file lives in the same directory as pom.xml -->
                            <testSetXml>${project.basedir}/${testname}.xml</testSetXml>
                            <!-- Test output JTL file written to target/jmeter/results/<testname>.csv -->
                            <jmeterCsv>${project.build.directory}/jmeter/results/${testname}.csv</jmeterCsv>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

【问题讨论】:

  • @user7294900 我正在使用 Maven 构建一个 JMeter 项目。

标签: maven azure-devops jmeter continuous-integration maven-3


【解决方案1】:

看起来您在自托管代理上运行了您的管道。或者您将 maven 配置为从本地存储库中检索依赖项(在 mvnsettings.xml.m2/settings.xml 中)。如果您在自托管代理上运行管道。您可以检查本地 repo /testartifacts/m2repository 是否存在。

如果你在云代理上运行你的管道,你需要找到哪些设置文件配置了本地 repo,并删除 localRepository。

那么您可能需要使用 Maven Authenticate task 为 Azure Artifacts 源和外部 Maven 存储库提供凭据。

在管道顶部添加 Maven 身份验证任务。并从Feeds 下拉列表中选择您的 azure maven 提要

此任务会将凭据存储在代理上的临时 settings.xml 文件中(以提要名称作为服务器 id,见下文),该文件将用于验证 maven 存储库中的跟随 maven 任务。

注意:您在 pom.xml 文件中指定的 repository id(即见下文突出显示)应该与 azure artifacts maven feed 的名称相同 .或者它仍然无法验证后续 maven 任务中的提要。上面创建的临时 settings.xml 文件中的 服务器 idfeed 名称

【讨论】:

  • 我按照您的建议添加了身份验证步骤。我将 pom.xml 中的 mycompanyproject-visualstudio.com-maven 更改为 mycompany,因为这是提要的名称(也可以使用名为 maven 的提要,但我只选择了 mycompany)。我保存了 pom.xml 并推送到源代码管理,然后运行了构建,但我仍然遇到同样的错误。
  • @DavidKlempfner 您是否在自托管代理上运行您的管道。看起来maven正在寻找本地存储库,但找不到它,或者代理服务没有权限访问。见上面的更新
  • 原来我所要做的就是将代理规范从 ubuntu-18.04 更改为 vs2017-win2016。现在可以了。感谢您的帮助。
【解决方案2】:

原来我所要做的就是将代理规范从 ubuntu-18.04 更改为 vs2017-win2016。

【讨论】:

    猜你喜欢
    • 2015-08-19
    • 1970-01-01
    • 2012-11-29
    • 2015-10-19
    • 1970-01-01
    • 2011-02-23
    • 1970-01-01
    • 2016-09-21
    • 2018-04-30
    相关资源
    最近更新 更多