From b445a353bb20fb202cd7df17d29e378a291c173a Mon Sep 17 00:00:00 2001 From: Nick Cross Date: Fri, 25 Oct 2024 15:13:55 +0100 Subject: [PATCH 1/2] Pass maven settings through --- deploy/tasks/maven-deployment.yaml | 1 + .../com/redhat/hacbs/container/deploy/DeployCommand.java | 6 ++++++ pkg/apis/jvmbuildservice/v1alpha1/systemconfig_types.go | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/deploy/tasks/maven-deployment.yaml b/deploy/tasks/maven-deployment.yaml index b8aa1361e..12b7b10dc 100644 --- a/deploy/tasks/maven-deployment.yaml +++ b/deploy/tasks/maven-deployment.yaml @@ -76,3 +76,4 @@ spec: - --directory=/var/workdir/deployment - --mvn-repo=$(params.MVN_REPO) - --mvn-username=$(params.MVN_USERNAME) + - --mvn-settings=/var/workdir/settings.xml diff --git a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/deploy/DeployCommand.java b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/deploy/DeployCommand.java index 35769ff54..316b4d0c0 100644 --- a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/deploy/DeployCommand.java +++ b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/deploy/DeployCommand.java @@ -28,6 +28,9 @@ public class DeployCommand implements Runnable { @ConfigProperty(name = "maven.password") Optional mvnPassword; + @CommandLine.Option(names = "--mvn-settings") + String mvnSettings; + @CommandLine.Option(names = "--mvn-repo") String mvnRepo; @@ -45,6 +48,9 @@ public void run() { Log.warnf("No deployed artifacts found. Has the build been correctly configured to deploy?"); throw new RuntimeException("Deploy failed"); } + if (isNotEmpty(mvnSettings)) { + System.setProperty("maven.settings", mvnSettings); + } if (isNotEmpty(mvnRepo)) { // Maven Repo Deployment MavenRepositoryDeployer deployer = new MavenRepositoryDeployer(mvnCtx, mvnUser, mvnPassword.orElse(""), mvnRepo, serverId, deploymentPath); diff --git a/pkg/apis/jvmbuildservice/v1alpha1/systemconfig_types.go b/pkg/apis/jvmbuildservice/v1alpha1/systemconfig_types.go index 368c7b3b3..5f2ac31e9 100644 --- a/pkg/apis/jvmbuildservice/v1alpha1/systemconfig_types.go +++ b/pkg/apis/jvmbuildservice/v1alpha1/systemconfig_types.go @@ -47,7 +47,7 @@ type SystemConfigList struct { const ( KonfluxGitDefinition = "https://raw.githubusercontent.com/konflux-ci/build-definitions/refs/heads/main/task/git-clone/0.1/git-clone.yaml" - KonfluxPreBuildDefinitions = "https://raw.githubusercontent.com/rnc/jvm-build-service/PIPELINE/deploy/tasks/pre-build.yaml" + KonfluxPreBuildDefinitions = "https://raw.githubusercontent.com/redhat-appstudio/jvm-build-service/main/deploy/tasks/pre-build.yaml" KonfluxBuildDefinitions = "https://raw.githubusercontent.com/konflux-ci/build-definitions/refs/heads/main/task/buildah-oci-ta/0.2/buildah-oci-ta.yaml" - KonfluxMavenDeployDefinitions = "https://raw.githubusercontent.com/rnc/jvm-build-service/PIPELINE/deploy/tasks/maven-deployment.yaml" + KonfluxMavenDeployDefinitions = "https://raw.githubusercontent.com/rnc/jvm-build-service/MVNSETTINGS/deploy/tasks/maven-deployment.yaml" ) From a9505a59ca3f3b04c55329a2fd67b2734a191a3d Mon Sep 17 00:00:00 2001 From: Nick Cross Date: Mon, 28 Oct 2024 14:28:29 +0000 Subject: [PATCH 2/2] Improve diagnostics --- .../deploy/mavenrepository/MavenRepositoryDeployer.java | 6 +++--- .../com/redhat/hacbs/container/deploy/MavenDeployTest.java | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/deploy/mavenrepository/MavenRepositoryDeployer.java b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/deploy/mavenrepository/MavenRepositoryDeployer.java index b67675baf..8b75b7518 100644 --- a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/deploy/mavenrepository/MavenRepositoryDeployer.java +++ b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/deploy/mavenrepository/MavenRepositoryDeployer.java @@ -122,9 +122,9 @@ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throw new RuntimeException(e); } } else { - if (files.stream().anyMatch(p -> !p.toFile().isDirectory())) { - Log.warnf("For directory %s, no pom file found with files %s", dir, - files); + var filtered = files.stream().filter(f -> !f.toFile().isDirectory()).toList(); + if (!filtered.isEmpty()) { + Log.warnf("For directory %s, no pom file found with files %s", dir, filtered); } } diff --git a/java-components/build-request-processor/src/test/java/com/redhat/hacbs/container/deploy/MavenDeployTest.java b/java-components/build-request-processor/src/test/java/com/redhat/hacbs/container/deploy/MavenDeployTest.java index 5f1e65d8b..0f5db5e3e 100644 --- a/java-components/build-request-processor/src/test/java/com/redhat/hacbs/container/deploy/MavenDeployTest.java +++ b/java-components/build-request-processor/src/test/java/com/redhat/hacbs/container/deploy/MavenDeployTest.java @@ -69,6 +69,8 @@ public void testDeploy() throws IOException { deployCommand.run(); List logRecords = LogCollectingTestResource.current().getRecords(); + + assertTrue(logRecords.stream().anyMatch(r -> LogCollectingTestResource.format(r).contains("no pom file found with files"))); assertTrue(logRecords.stream().anyMatch(r -> LogCollectingTestResource.format(r) .contains("Deploying [com.company.foo:foo-baz:pom:3.25.8]"))); assertTrue(logRecords.stream().anyMatch(r -> LogCollectingTestResource.format(r) @@ -86,6 +88,8 @@ private Path createDeploymentRepo() Path artifacts = Paths.get(testData.toString(), "artifacts").toAbsolutePath(); Files.createDirectories(artifacts); + Files.createFile(Paths.get(artifacts.toString(), "test-file.txt")); + // Add data to artifacts folder for (Map.Entry> artifactFiles : ARTIFACT_FILE_MAP.entrySet()) { String groupPath = GROUP.replace(DOT, File.separator);