diff --git a/Makefile b/Makefile index 7fa0095809..370b6877dc 100644 --- a/Makefile +++ b/Makefile @@ -65,8 +65,8 @@ dev-image: echo "ERROR: QUAY_USERNAME is not set"; \ exit 1; \ fi - docker build . -t quay.io/$(QUAY_USERNAME)/hacbs-jvm-controller:dev - docker push quay.io/$(QUAY_USERNAME)/hacbs-jvm-controller:dev + docker build . -t quay.io/$(QUAY_USERNAME)/hacbs-jvm-controller:"$${JBS_QUAY_IMAGE_TAG:-dev}" + docker push quay.io/$(QUAY_USERNAME)/hacbs-jvm-controller:"$${JBS_QUAY_IMAGE_TAG:-dev}" dev: dev-image cd java-components && mvn clean install -Dlocal -DskipTests -Ddev diff --git a/deploy/tasks/pre-build.yaml b/deploy/tasks/pre-build.yaml index 161040a71b..aef5947243 100644 --- a/deploy/tasks/pre-build.yaml +++ b/deploy/tasks/pre-build.yaml @@ -53,8 +53,6 @@ spec: default: "" - name: BUILD_SCRIPT description: The build script to embed with the Containerfile -# - name: PREPROCESSOR_ARGS -# description: The arguments for the build preprocessor - name: ORAS_OPTIONS type: string description: Optional environment variable string for build-trusted-artifacts diff --git a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/build/preprocessor/AbstractPreprocessor.java b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/build/preprocessor/AbstractPreprocessor.java index 470c0775c4..f388031852 100644 --- a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/build/preprocessor/AbstractPreprocessor.java +++ b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/build/preprocessor/AbstractPreprocessor.java @@ -6,6 +6,7 @@ import java.nio.file.Paths; import java.util.List; +import io.quarkus.logging.Log; import picocli.CommandLine; /** @@ -37,12 +38,9 @@ protected enum ToolType { @Override public void run() { - System.err.println("### debug creating with tool " + type + " and recipe " + recipeImage); - - Path artifactDirectory = Path.of(buildRoot.getParent().toString(), "artifacts"); Path jbsDirectory = Path.of(buildRoot.toString(), ".jbs"); //noinspection ResultOfMethodCallIgnored - jbsDirectory.toFile().mkdir(); + jbsDirectory.toFile().mkdirs(); String containerFile = """ FROM %s @@ -61,23 +59,24 @@ public void run() { if (type == ToolType.ANT) { // Don't think we need to mess with keystore as copy-artifacts is simply calling copy commands. containerFile += - "\nFROM " + buildRequestProcessorImage + " AS build-request-processor" + - "\nUSER 0" + - "\nWORKDIR /var/workdir" + - "\nCOPY --from=0 /var/workdir/ /var/workdir/" + - "\nRUN /opt/jboss/container/java/run/run-java.sh copy-artifacts --source-path=" + buildRoot + " --deploy-path=" + artifactDirectory + - "\nFROM scratch" + - "\nCOPY --from=1 /var/workdir/workspace/artifacts /"; + """ + FROM %s AS build-request-processor + USER 0 + WORKDIR /var/workdir + COPY --from=0 /var/workdir/ /var/workdir/ + RUN /opt/jboss/container/java/run/run-java.sh copy-artifacts --source-path=/var/workdir/workspace/source --deploy-path=/var/workdir/workspace/artifacts + FROM scratch + COPY --from=1 /var/workdir/workspace/artifacts /""".formatted(buildRequestProcessorImage); } else { containerFile += """ - FROM scratch\ + FROM scratch COPY --from=0 /var/workdir/workspace/artifacts /"""; } try { Files.writeString(Paths.get(jbsDirectory.toString(), "Containerfile"), containerFile); } catch (IOException e) { - + Log.errorf("Unable to write Containerfile", e); throw new RuntimeException(e); } } diff --git a/java-components/pom.xml b/java-components/pom.xml index 0d2fe06de6..23a195480d 100644 --- a/java-components/pom.xml +++ b/java-components/pom.xml @@ -71,6 +71,8 @@ 2.4.7 false + + dev @@ -452,7 +454,7 @@ ${env.QUAY_USERNAME} - dev + ${imageTag} true true mutable-jar @@ -611,5 +613,16 @@ management-console - + + + true + + env.JBS_QUAY_IMAGE_TAG + + + + ${env.JBS_QUAY_IMAGE_TAG} + + + diff --git a/pkg/reconciler/dependencybuild/buildrecipeyaml.go b/pkg/reconciler/dependencybuild/buildrecipeyaml.go index ec0c418aa9..e9f442b0d1 100644 --- a/pkg/reconciler/dependencybuild/buildrecipeyaml.go +++ b/pkg/reconciler/dependencybuild/buildrecipeyaml.go @@ -165,18 +165,6 @@ func createPipelineSpec(log logr.Logger, tool string, commitTime int64, jbsConfi tlsVerify = "false" } - //preprocessorArgs := []string{ - // "maven-prepare", - // "$(workspaces." + WorkspaceSource + ".path)/source", - // "--tool=" + tool, - // "--recipe-image=" + recipe.Image, - // "--request-processor-image=" + buildRequestProcessorImage, - //} - //if len(recipe.DisabledPlugins) > 0 { - // for _, i := range recipe.DisabledPlugins { - // preprocessorArgs = append(preprocessorArgs, "-dp "+i) - // } - //} var javaHome string if recipe.JavaVersion == "7" || recipe.JavaVersion == "8" { javaHome = "/lib/jvm/java-1." + recipe.JavaVersion + ".0" @@ -213,14 +201,11 @@ func createPipelineSpec(log logr.Logger, tool string, commitTime int64, jbsConfi } else if tool == "gradle" { // We always add Maven information (in InvocationBuilder) so add the relevant settings.xml buildToolSection = mavenSettings + "\n" + gradleBuild - //preprocessorArgs[0] = "gradle-prepare" } else if tool == "sbt" { buildToolSection = sbtBuild - //preprocessorArgs[0] = "sbt-prepare" } else if tool == "ant" { // We always add Maven information (in InvocationBuilder) so add the relevant settings.xml buildToolSection = mavenSettings + "\n" + antBuild - //preprocessorArgs[0] = "ant-prepare" } else { buildToolSection = "echo unknown build tool " + tool + " && exit 1" } @@ -668,7 +653,7 @@ func createKonfluxScripts(konfluxScript string) string { func pullPolicy(buildRequestProcessorImage string) v1.PullPolicy { pullPolicy := v1.PullIfNotPresent - if strings.HasSuffix(buildRequestProcessorImage, ":dev") { + if strings.HasSuffix(buildRequestProcessorImage, ":dev") || strings.HasSuffix(buildRequestProcessorImage, ":latest") { pullPolicy = v1.PullAlways } return pullPolicy