@@ -256,73 +256,73 @@ func createPipelineSpec(log logr.Logger, tool string, commitTime int64, jbsConfi
256256 if jbsConfig .Spec .CacheSettings .DisableTLS {
257257 cacheUrl = "http://jvm-build-workspace-artifact-cache." + jbsConfig .Namespace + ".svc.cluster.local/v2/cache/rebuild"
258258 }
259+ cacheUrl = cacheUrl + buildRepos + "/" + strconv .FormatInt (commitTime , 10 )
259260
260261 //we generate a docker file that can be used to reproduce this build
261262 //this is for diagnostic purposes, if you have a failing build it can be really hard to figure out how to fix it without this
262263 log .Info (fmt .Sprintf ("Generating dockerfile with recipe build image %#v" , recipe .Image ))
263- preprocessorScript := "#!/bin/sh\n /root/ software/system-java/bin/java -jar /root /software/build-request-processor/quarkus-run.jar " + doSubstitution (strings .Join (preprocessorArgs , " " ), paramValues , commitTime , buildRepos ) + "\n "
264+ preprocessorScript := "#!/bin/sh\n /var/workdir/ software/system-java/bin/java -jar /var/workdir /software/build-request-processor/quarkus-run.jar " + doSubstitution (strings .Join (preprocessorArgs , " " ), paramValues , commitTime , buildRepos ) + "\n "
264265 buildScript := doSubstitution (build , paramValues , commitTime , buildRepos )
265266 envVars := extractEnvVar (toolEnv )
266267 cmdArgs := extractArrayParam (PipelineParamGoals , paramValues )
267268 konfluxScript := "#!/bin/sh\n " + envVars + "\n set -- \" $@\" " + cmdArgs + "\n \n " + buildScript
268269
269270 // Diagnostic Containerfile
270- // TODO: While it doesn't functionally matter, ideally we should match Konflux layout (i.e. /var/workdir etc).
271271 df := "FROM " + buildRequestProcessorImage + " AS build-request-processor" +
272272 "\n FROM " + strings .ReplaceAll (buildRequestProcessorImage , "hacbs-jvm-build-request-processor" , "hacbs-jvm-cache" ) + " AS cache" +
273273 "\n FROM " + recipe .Image +
274274 "\n USER 0" +
275- "\n WORKDIR /root " +
275+ "\n WORKDIR /var/workdir " +
276276 "\n ENV CACHE_URL=" + doSubstitution ("$(params." + PipelineParamCacheUrl + ")" , paramValues , commitTime , buildRepos ) +
277- "\n RUN mkdir -p /root/project /root/ software/settings /original-content/marker && microdnf install procps-ng " +
277+ "\n RUN mkdir -p /var/workdir/ software/settings /original-content/marker" +
278278 // TODO: Debug only
279279 "\n RUN rpm -ivh https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/tree-1.7.0-15.el8.x86_64.rpm" +
280- "\n COPY --from=build-request-processor /deployments/ /root /software/build-request-processor" +
280+ "\n COPY --from=build-request-processor /deployments/ /var/workdir /software/build-request-processor" +
281281 // Copying JDK17 for the cache.
282282 // TODO: Could we determine if we are using UBI8 and avoid this?
283- "\n COPY --from=build-request-processor /lib/jvm/jre-17 /root /software/system-java" +
283+ "\n COPY --from=build-request-processor /lib/jvm/jre-17 /var/workdir /software/system-java" +
284284 "\n COPY --from=build-request-processor /etc/java/java-17-openjdk /etc/java/java-17-openjdk" +
285- "\n COPY --from=cache /deployments/ /root /software/cache" +
285+ "\n COPY --from=cache /deployments/ /var/workdir /software/cache" +
286286 // Use git script rather than the preBuildImages as they are OCI archives and can't be used with docker/podman.
287+ // TODO: ### Is this gitscript using the correct SHA? The Konflux one is but this is using pre preprocessor changes.
287288 "\n RUN " + doSubstitution (gitScript , paramValues , commitTime , buildRepos ) +
288- "\n RUN echo " + base64 .StdEncoding .EncodeToString ([]byte ("#!/bin/sh\n /root/ software/system-java/bin/java -Dbuild-policy.default.store-list=rebuilt,central,jboss,redhat -Dkube.disabled=true -Dquarkus.kubernetes-client.trust-certs=true -jar /root/ software/cache/quarkus-run.jar >/root /cache.log &" +
289- "\n while ! cat /root/ cache.log | grep 'Listening on:'; do\n echo \" Waiting for Cache to start\" \n sleep 1\n done \n " )) + " | base64 -d >/root /start-cache.sh" +
290- "\n RUN echo " + base64 .StdEncoding .EncodeToString ([]byte (preprocessorScript )) + " | base64 -d >/root /preprocessor.sh" +
291- "\n RUN echo " + base64 .StdEncoding .EncodeToString ([]byte (buildScript )) + " | base64 -d >/root /build.sh" +
292- "\n RUN echo " + base64 .StdEncoding .EncodeToString ([]byte ("#!/bin/sh\n /root/ preprocessor.sh\n " + envVars + "\n /root/ build.sh " + cmdArgs + "\n " )) + " | base64 -d >/root /run-full-build.sh" +
293- "\n RUN echo " + base64 .StdEncoding .EncodeToString ([]byte (dockerfileEntryScript )) + " | base64 -d >/root /entry-script.sh" +
294- "\n RUN chmod +x /root /*.sh" +
295- "\n CMD [ \" /bin/bash\" , \" /root /entry-script.sh\" ]"
289+ "\n RUN echo " + base64 .StdEncoding .EncodeToString ([]byte ("#!/bin/sh\n /var/workdir/ software/system-java/bin/java -Dbuild-policy.default.store-list=rebuilt,central,jboss,redhat -Dkube.disabled=true -Dquarkus.kubernetes-client.trust-certs=true -jar /var/workdir/ software/cache/quarkus-run.jar >/var/workdir /cache.log &" +
290+ "\n while ! cat /var/workdir/ cache.log | grep 'Listening on:'; do\n echo \" Waiting for Cache to start\" \n sleep 1\n done \n " )) + " | base64 -d >/var/workdir /start-cache.sh" +
291+ "\n RUN echo " + base64 .StdEncoding .EncodeToString ([]byte (preprocessorScript )) + " | base64 -d >/var/workdir /preprocessor.sh" +
292+ "\n RUN echo " + base64 .StdEncoding .EncodeToString ([]byte (buildScript )) + " | base64 -d >/var/workdir /build.sh" +
293+ "\n RUN echo " + base64 .StdEncoding .EncodeToString ([]byte ("#!/bin/sh\n /var/workdir/ preprocessor.sh\n " + envVars + "\n /var/workdir/ build.sh " + cmdArgs + "\n " )) + " | base64 -d >/var/workdir /run-full-build.sh" +
294+ "\n RUN echo " + base64 .StdEncoding .EncodeToString ([]byte (dockerfileEntryScript )) + " | base64 -d >/var/workdir /entry-script.sh" +
295+ "\n RUN chmod +x /var/workdir /*.sh" +
296+ "\n CMD [ \" /bin/bash\" , \" /var/workdir /entry-script.sh\" ]"
296297
297298 // Konflux Containerfile
298- // TODO: While it doesn't functionally matter, ideally we should match Konflux layout (i.e. /var/workdir etc).
299299 kf := "FROM " + recipe .Image +
300300 "\n USER 0" +
301- "\n WORKDIR /root " +
302- "\n RUN mkdir -p /root/project /root /software/settings /original-content/marker" +
301+ "\n WORKDIR /var/workdir " +
302+ "\n RUN mkdir -p /var/workdir /software/settings /original-content/marker" +
303303 // TODO ### HACK : How to use SSL to avoid certificate problem with buildah task?
304304 // "\nENV CACHE_URL=" + "http://jvm-build-workspace-artifact-cache." + jbsConfig.Namespace + ".svc.cluster.local/v2/cache/rebuild" + buildRepos + "/" + strconv.FormatInt(commitTime, 10) +
305305 "\n ENV JBS_DISABLE_CACHE=true" +
306- "\n COPY .jbs/run-build.sh /root " +
307- "\n COPY . /root/project /source/" +
308- "\n RUN /root /run-build.sh"
306+ "\n COPY .jbs/run-build.sh /var/workdir " +
307+ "\n COPY . /var/workdir/workspace /source/" +
308+ "\n RUN /var/workdir /run-build.sh"
309309 // TODO: This is a bit of a hack but as Ant doesn't deploy and the previous implementation relied upon using the
310310 // BuildRequestProcessorImage we need to modify the Containerfile. In future the ant-build.sh should probably
311311 // encapsulate this.
312312 if tool == "ant" {
313313 kf = kf +
314314 "\n FROM " + buildRequestProcessorImage + " AS build-request-processor" +
315315 "\n USER 0" +
316- "\n WORKDIR /root " +
317- "\n COPY --from=0 /root/project / /root/project /" +
316+ "\n WORKDIR /var/workdir " +
317+ "\n COPY --from=0 /var/workdir / /var/workdir /" +
318318 // Don't think we need to mess with keystore as copy-artifacts is simply calling copy commands.
319319 "\n RUN /opt/jboss/container/java/run/run-java.sh " + doSubstitution (strings .Join (copyArtifactsArgs , " " ), []tektonpipeline.Param {}, commitTime , buildRepos ) +
320320 "\n FROM scratch" +
321- "\n COPY --from=1 /root/project /artifacts /"
321+ "\n COPY --from=1 /var/workdir/workspace /artifacts /"
322322 } else {
323323 kf = kf +
324324 "\n FROM scratch" +
325- "\n COPY --from=0 /root/project /artifacts /"
325+ "\n COPY --from=0 /var/workdir/workspace /artifacts /"
326326 }
327327
328328 pullPolicy := pullPolicy (buildRequestProcessorImage )
@@ -345,7 +345,7 @@ func createPipelineSpec(log logr.Logger, tool string, commitTime int64, jbsConfi
345345 {Name : PipelineParamPath , Type : tektonpipeline .ParamTypeString },
346346 {Name : PipelineParamEnforceVersion , Type : tektonpipeline .ParamTypeString },
347347 {Name : PipelineParamProjectVersion , Type : tektonpipeline .ParamTypeString },
348- {Name : PipelineParamCacheUrl , Type : tektonpipeline .ParamTypeString , Default : & tektonpipeline.ResultValue {Type : tektonpipeline .ParamTypeString , StringVal : cacheUrl + buildRepos + "/" + strconv . FormatInt ( commitTime , 10 ) }},
348+ {Name : PipelineParamCacheUrl , Type : tektonpipeline .ParamTypeString , Default : & tektonpipeline.ResultValue {Type : tektonpipeline .ParamTypeString , StringVal : cacheUrl }},
349349 }
350350 secretVariables := secretVariables (jbsConfig )
351351
@@ -446,7 +446,7 @@ func createPipelineSpec(log logr.Logger, tool string, commitTime int64, jbsConfi
446446 }
447447
448448 if jbsConfig .Spec .ContainerBuilds {
449- // TODO: ### Note - its also possible to refer to a remote pipeline ref as well as a task.
449+ // Note - its also possible to refer to a remote pipeline ref as well as a task.
450450 resolver := tektonpipeline.ResolverRef {
451451 Resolver : "git" ,
452452 Params : []tektonpipeline.Param {
@@ -458,7 +458,7 @@ func createPipelineSpec(log logr.Logger, tool string, commitTime int64, jbsConfi
458458 },
459459 },
460460 {
461- // TODO: ### Currently always using 'head' of branch.
461+ // Currently always using 'head' of branch.
462462 Name : "revision" ,
463463 Value : tektonpipeline.ParamValue {
464464 Type : tektonpipeline .ParamTypeString ,
@@ -1037,9 +1037,9 @@ func doSubstitution(script string, paramValues []tektonpipeline.Param, commitTim
10371037 }
10381038 }
10391039 script = strings .ReplaceAll (script , "$(params.CACHE_URL)" , "http://localhost:8080/v2/cache/rebuild" + buildRepos + "/" + strconv .FormatInt (commitTime , 10 )+ "/" )
1040- script = strings .ReplaceAll (script , "$(workspaces.build-settings.path)" , "/root /software/settings" )
1041- script = strings .ReplaceAll (script , "$(workspaces.source.path)" , "/root/project " )
1042- script = strings .ReplaceAll (script , "$(workspaces.tls.path)" , "/root/project /tls/service-ca.crt" )
1040+ script = strings .ReplaceAll (script , "$(workspaces.build-settings.path)" , "/var/workdir /software/settings" )
1041+ script = strings .ReplaceAll (script , "$(workspaces.source.path)" , "/var/workdir/workspace " )
1042+ script = strings .ReplaceAll (script , "$(workspaces.tls.path)" , "/var/workdir/software /tls/service-ca.crt" )
10431043 return script
10441044}
10451045
0 commit comments