maven failsafe uses wrong repository on verify

69 Views Asked by At

I have a quarkus application with integrationtests.

In the pom.xml are two profiles defined. When running the verify build with -Drelease=true it should use the profile called release and therefore using the release repository when building. When i locally run the build command or verify command it will use the correct release repositories.

When i run the same in gitlab, the build stage uses the correct release repository, but when the verify stage runs it downloads the dependencies from the snapshot repository. I am not sure if this is a Quarkus, Maven, Jdk, Gitlab Bug or whatelse. Couldn't figure out whats wrong here since its working locally but not in gitlab.

Also maven prints before building which profile is used and it says it uses the correct release profile.

pom.xml profiles

<profiles>
        <profile>
            <id>snapshot</id>
            <activation>
                <property>
                    <name>release</name>
                    <value>!true</value>
                </property>
                <activeByDefault>true</activeByDefault>
            </activation>
            <repositories>
                <repository>
                    <id>commons snapshot</id>
                    <url>http://url.de/maven/commons-snapshot</url>
                </repository>
            </repositories>
        </profile>
        <profile>
            <id>release</id>
            <activation>
                <property>
                    <name>release</name>
                    <value>true</value>
                </property>
            </activation>
            <repositories>
                <repository>
                    <id>commons release</id>
                    <url>http://url.de/maven/commons-release</url>
                </repository>
            </repositories>
        </profile>
  </profiles>

pom.xml failsafe plugin

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>3.0.0</version>
    <executions>
        <execution>
            <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
            </goals>
            <configuration>
                <failIfNoTests>true</failIfNoTests>
                <skip>${skipITs}</skip>
                <includes>**/*IT*</includes>
                <excludes>**/*Test*</excludes>
                <systemPropertyVariables>
                    <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
                    <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                    <maven.settings>.mvn/local-settings.xml</maven.settings>
                </systemPropertyVariables>
            </configuration>
        </execution>
    </executions>
</plugin>

.mvn/local-settings.xml

<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd">
    <mirrors>
        <mirror>
            <id>maven-default-http-blocker</id>
            <mirrorOf>external:dummy:*</mirrorOf>
            <name>Pseudo repository to mirror external repositories initially
                using HTTP.
            </name>
            <url>http://0.0.0.0/</url>
            <blocked>false</blocked>
        </mirror>
    </mirrors>
</settings>

gitlab-ci.yml

variables:
  MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true -Drelease=$RELEASE"
  MAVEN_CLI_OPTS: "--batch-mode --errors --show-version --fail-at-end help:active-profiles"

image: maven:3-openjdk-17

cache:
  key: $CI_COMMIT_REF_SLUG

stages:
    - build
    - verify

build:
  stage: build
  script:
    - mvn $MAVEN_CLI_OPTS compile
  artifacts:
    paths:
     - "target/"
    expire_in: 1 week

verify:
  stage: verify
  needs: 
    - job: build
      artifacts: true
  script:
    - mvn $MAVEN_CLI_OPTS verify
  artifacts:
    when: always
    reports:
      junit:
        - target/failsafe-reports/TEST-*.xml
        - target/surefire-reports/TEST-*.xml

As I said it is working locally (thats why im not sure if this is even quarkus related). When its run in gitlab the build stage is working and using the correct release repository. When running the verify stage it says

230318 [INFO] -------------------------------------------------------
230318 [INFO]  T E S T S
230318 [INFO] -------------------------------------------------------
231542 [INFO] Running eu.gemtec.star.asterisk.integration.ITBase

ITBase is a @QuarkusIntegrationTest Then there are some downloads from the wrong repository.

Downloaded from commons snapshot: http://url.de/maven/commons-snapshot/eu/model/model1/1.1.0-SNAPSHOT/device-1.1.0-20230308.144121-1.jar (9.9 kB at 12 kB/s)

Then it fails because maven tries to download a dependency that doesnt event exist in this version in both of the channels. But i think the real problem here is that somehow the snapshot repository is used instead of the release repository.

Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact model:status.rest.api:jar:1.4.1-20221026.115121-1 in commons snapshot (http://url.de/maven/commons-snapshot)
    at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:48)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:369)
    at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)

Also what i am wondering about is that this version model:status.rest.api:jar:1.4.1-20221026.115121-1 doesnt exist in either the release nor the snapshot repository.

Linux runner-wgxkyhte-project-39-concurrent-0 5.15.0-70-generic #77-Ubuntu SMP Tue Mar 21 14:02:37 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

openjdk 17.0.2 2022-01-18

Quarkus version 2.16.6.Final

Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0)
0

There are 0 best solutions below