LocalRepositoryNotAccessibleException 无法在 /testartifacts/m2repository 创建本地存储库

LocalRepositoryNotAccessibleException Could not create local repository at /testartifacts/m2repository

我运行在 Azure DevOps 中使用一个名为“下载提供的依赖项 JAR”的 Maven 构建步骤设置 CI 管道。

此步骤之前有效,但突然出现此错误:

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>

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

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

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

在管道顶部添加 Maven 身份验证任务。 select 来自 Feeds 下拉列表

的 azure maven 提要

此任务会将凭据存储在代理上的一个临时 settings.xml 文件(使用 feed 名称作为服务器 ID,见下文),该文件将被使用在以下 Maven 任务中验证 Maven 存储库。

注意:您在 pom.xml 文件中指定的 存储库 ID (即,请参见下面突出显示的部分)应与 的名称相同你的 azure artifacts maven feed。或者它仍然无法验证 follow maven 任务中的提要。对于上面创建的临时 settings.xml 文件中的 服务器 ID 提要名称 .

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