Skip to content

Commit bc1f788

Browse files
committed
Add variables to containerfile only for JBS
1 parent e620f56 commit bc1f788

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/build/preprocessor/AbstractPreprocessor.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import io.quarkus.logging.Log;
1010
import picocli.CommandLine;
1111

12+
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
13+
1214
/**
1315
* We keep all the options the same between maven, gradle, sbt and ant for now to keep the pipeline setup simpler.
1416
* Some of these may be ignored by different processors
@@ -59,20 +61,28 @@ public void run() {
5961
//noinspection ResultOfMethodCallIgnored
6062
jbsDirectory.toFile().mkdirs();
6163

62-
Log.warnf("### ENV {}", System.getenv("jvm-build-service"));
64+
Log.warnf("### ENV %s", System.getenv("jvm-build-service"));
6365

6466
String containerFile = """
6567
FROM %s
6668
USER 0
6769
WORKDIR /var/workdir
70+
""".formatted(recipeImage);
71+
72+
// This block is only needed for running inside JBS
73+
if (isNotEmpty(System.getenv("jvm-build-service"))) {
74+
containerFile += """
6875
RUN mkdir -p /var/workdir/software/settings /original-content/marker
6976
7077
ARG CACHE_URL=""
7178
ENV CACHE_URL=$CACHE_URL
79+
""";
80+
}
81+
containerFile += """
7282
COPY .jbs/run-build.sh /var/workdir
7383
COPY . /var/workdir/workspace/source/
7484
RUN /var/workdir/run-build.sh
75-
""".formatted(recipeImage);
85+
""";
7686

7787
// TODO: This is a bit of a hack but as Ant doesn't deploy and the previous implementation relied upon using the
7888
// BuildRequestProcessorImage we need to modify the Containerfile. In future the ant-build.sh should probably

pkg/reconciler/dependencybuild/dependencybuild.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ func (r *ReconcileDependencyBuild) handleStateBuilding(ctx context.Context, db *
632632
},
633633
}},
634634
}
635+
// Setting a default environment variable to represent being run inside the operator
635636
pr.Spec.TaskRunTemplate = tektonpipeline.PipelineTaskRunTemplate{
636637
PodTemplate: &pod.Template{
637638
Env: []v1.EnvVar{

0 commit comments

Comments
 (0)