@@ -333,7 +333,6 @@ func createPipelineSpec(log logr.Logger, tool string, commitTime int64, jbsConfi
333333 return nil , "" , "" , "" , err
334334 }
335335
336- createBuildScript := createBuildScript (build )
337336 pipelineParams := []tektonpipeline.ParamSpec {
338337 {Name : PipelineBuildId , Type : tektonpipeline .ParamTypeString },
339338 {Name : PipelineParamScmUrl , Type : tektonpipeline .ParamTypeString },
@@ -383,7 +382,7 @@ func createPipelineSpec(log logr.Logger, tool string, commitTime int64, jbsConfi
383382 Requests : v1.ResourceList {"memory" : limits .defaultRequestMemory , "cpu" : limits .defaultRequestCPU },
384383 Limits : v1.ResourceList {"memory" : limits .defaultRequestMemory , "cpu" : limits .defaultLimitCPU },
385384 },
386- Script : gitScript + " \n " + createBuildScript ,
385+ Script : gitScript ,
387386 Env : []v1.EnvVar {
388387 {Name : PipelineParamCacheUrl , Value : "$(params." + PipelineParamCacheUrl + ")" },
389388 {Name : "GIT_TOKEN" , ValueFrom : & v1.EnvVarSource {SecretKeyRef : & v1.SecretKeySelector {LocalObjectReference : v1.LocalObjectReference {Name : v1alpha1 .GitSecretName }, Key : v1alpha1 .GitSecretTokenKey , Optional : & trueBool }}},
@@ -447,172 +446,80 @@ func createPipelineSpec(log logr.Logger, tool string, commitTime int64, jbsConfi
447446 }
448447 }
449448
450- if jbsConfig .Spec .ContainerBuilds {
451- // Note - its also possible to refer to a remote pipeline ref as well as a task.
452- resolver := tektonpipeline.ResolverRef {
453- // We can use either a http or git resolver. Using http as avoids cloning an entire repository.
454- Resolver : "http" ,
455- Params : []tektonpipeline.Param {
456- {
457- Name : "url" ,
458- Value : tektonpipeline.ParamValue {
459- Type : tektonpipeline .ParamTypeString ,
460- StringVal : v1alpha1 .KonfluxBuildDefinitions ,
461- },
462- },
463- },
464- }
465-
466- ps .Tasks = append ([]tektonpipeline.PipelineTask {
449+ // Note - its also possible to refer to a remote pipeline ref as well as a task.
450+ resolver := tektonpipeline.ResolverRef {
451+ // We can use either a http or git resolver. Using http as avoids cloning an entire repository.
452+ Resolver : "http" ,
453+ Params : []tektonpipeline.Param {
467454 {
468- Name : BuildTaskName ,
469- RunAfter : runAfter ,
470- TaskRef : & tektonpipeline.TaskRef {
471- // Can't specify name and resolver as they clash.
472- ResolverRef : resolver ,
473- },
474- Timeout : & v12.Duration {Duration : time .Hour * v1alpha1 .DefaultTimeout },
475- Params : []tektonpipeline.Param {
476- {
477- Name : "DOCKERFILE" ,
478- Value : tektonpipeline.ParamValue {
479- Type : tektonpipeline .ParamTypeString ,
480- StringVal : ".jbs/Containerfile" },
481- },
482- {
483- Name : "IMAGE" ,
484- Value : tektonpipeline.ParamValue {
485- Type : tektonpipeline .ParamTypeString ,
486- StringVal : registryArgsWithDefaults (jbsConfig , buildId )},
487- },
488- {
489- Name : "SOURCE_ARTIFACT" ,
490- Value : tektonpipeline.ParamValue {
491- Type : tektonpipeline .ParamTypeString ,
492- StringVal : preBuildImage ,
493- },
494- },
495- {
496- Name : "ORAS_OPTIONS" ,
497- Value : tektonpipeline.ParamValue {
498- Type : tektonpipeline .ParamTypeString ,
499- StringVal : orasOptions ,
500- },
501- },
502- {
503- Name : "TLSVERIFY" ,
504- Value : tektonpipeline.ParamValue {
505- Type : tektonpipeline .ParamTypeString ,
506- StringVal : tlsVerify ,
507- },
508- },
455+ Name : "url" ,
456+ Value : tektonpipeline.ParamValue {
457+ Type : tektonpipeline .ParamTypeString ,
458+ StringVal : v1alpha1 .KonfluxBuildDefinitions ,
509459 },
460+ },
461+ },
462+ }
510463
511- // TODO: ### How to pass build-settings/tls information to buildah task?
512- // Note - buildah-oci-ta task has no defined workspace
513- //Workspaces: []tektonpipeline.WorkspacePipelineTaskBinding{
514- // //{Name: WorkspaceBuildSettings, Workspace: WorkspaceBuildSettings},
515- // {Name: WorkspaceSource, Workspace: WorkspaceSource},
516- // //{Name: WorkspaceTls, Workspace: WorkspaceTls},
517- //},
518- }}, ps .Tasks ... )
519-
520- // Results for https://github.com/konflux-ci/build-definitions/tree/main/task/buildah-oci-ta/0.2
521- // IMAGE_DIGEST
522- // IMAGE_URL
523- ps .Results = append (ps .Results , tektonpipeline.PipelineResult {Name : PipelineResultImage , Value : tektonpipeline.ResultValue {Type : tektonpipeline .ParamTypeString , StringVal : "$(tasks." + BuildTaskName + ".results." + PipelineResultImage + ")" }})
524- ps .Results = append (ps .Results , tektonpipeline.PipelineResult {Name : PipelineResultImageDigest , Value : tektonpipeline.ResultValue {Type : tektonpipeline .ParamTypeString , StringVal : "$(tasks." + BuildTaskName + ".results." + PipelineResultImageDigest + ")" }})
525- } else {
526- buildTask := tektonpipeline.TaskSpec {
527- Workspaces : []tektonpipeline.WorkspaceDeclaration {{Name : WorkspaceBuildSettings }, {Name : WorkspaceSource , MountPath : WorkspaceMount }, {Name : WorkspaceTls }},
528- Params : append (pipelineParams , tektonpipeline.ParamSpec {Name : PipelineResultPreBuildImageDigest , Type : tektonpipeline .ParamTypeString }),
529- Results : []tektonpipeline.TaskResult {
530- {Name : PipelineResultImage },
531- {Name : PipelineResultImageDigest },
464+ ps .Tasks = append ([]tektonpipeline.PipelineTask {
465+ {
466+ Name : BuildTaskName ,
467+ RunAfter : runAfter ,
468+ TaskRef : & tektonpipeline.TaskRef {
469+ // Can't specify name and resolver as they clash.
470+ ResolverRef : resolver ,
532471 },
533- Steps : []tektonpipeline.Step {
472+ Timeout : & v12.Duration {Duration : time .Hour * v1alpha1 .DefaultTimeout },
473+ Params : []tektonpipeline.Param {
534474 {
535- Name : "restore-pre-build-source" ,
536- Image : strings .TrimSpace (strings .Split (buildTrustedArtifacts , "FROM" )[1 ]),
537- ImagePullPolicy : v1 .PullIfNotPresent ,
538- SecurityContext : & v1.SecurityContext {RunAsUser : & zero },
539- Env : secretVariables ,
540- Script : fmt .Sprintf (`echo "Restoring source to workspace : $(workspaces.source.path)"
541- export ORAS_OPTIONS="%s"
542- use-archive $(params.%s)=$(workspaces.source.path)/source
543- mv $(workspaces.source.path)/source/.jbs/build.sh $(workspaces.source.path)` , orasOptions , PipelineResultPreBuildImageDigest ),
475+ Name : "DOCKERFILE" ,
476+ Value : tektonpipeline.ParamValue {
477+ Type : tektonpipeline .ParamTypeString ,
478+ StringVal : ".jbs/Containerfile" },
544479 },
545480 {
546- Timeout : & v12.Duration {Duration : time .Hour * v1alpha1 .DefaultTimeout },
547- Name : "build" ,
548- Image : recipe .Image ,
549- ImagePullPolicy : pullPolicy ,
550- WorkingDir : "$(workspaces." + WorkspaceSource + ".path)/source" ,
551- SecurityContext : & v1.SecurityContext {RunAsUser : & zero },
552- Env : append (toolEnv , v1.EnvVar {Name : PipelineParamCacheUrl , Value : "$(params." + PipelineParamCacheUrl + ")" }),
553- ComputeResources : v1.ResourceRequirements {
554- Requests : v1.ResourceList {"memory" : limits .buildRequestMemory , "cpu" : limits .buildRequestCPU },
555- Limits : v1.ResourceList {"memory" : limits .buildRequestMemory , "cpu" : limits .buildLimitCPU },
556- },
557- Args : []string {"$(params.GOALS[*])" },
558- Script : "$(workspaces." + WorkspaceSource + ".path)/build.sh \" $@\" " ,
481+ Name : "IMAGE" ,
482+ Value : tektonpipeline.ParamValue {
483+ Type : tektonpipeline .ParamTypeString ,
484+ StringVal : registryArgsWithDefaults (jbsConfig , buildId )},
559485 },
560486 {
561- Name : "deploy-ant-artifacts" ,
562- Image : buildRequestProcessorImage ,
563- ImagePullPolicy : pullPolicy ,
564- SecurityContext : & v1.SecurityContext {RunAsUser : & zero },
565- Env : secretVariables ,
566- ComputeResources : v1.ResourceRequirements {
567- Requests : v1.ResourceList {"memory" : limits .defaultBuildRequestMemory , "cpu" : limits .defaultRequestCPU },
568- Limits : v1.ResourceList {"memory" : limits .defaultBuildRequestMemory , "cpu" : limits .defaultLimitCPU },
487+ Name : "SOURCE_ARTIFACT" ,
488+ Value : tektonpipeline.ParamValue {
489+ Type : tektonpipeline .ParamTypeString ,
490+ StringVal : preBuildImage ,
569491 },
570- Script : artifactbuild .InstallKeystoreIntoBuildRequestProcessor (copyArtifactsArgs ),
571492 },
572- // Store post-build artifacts here using oras to match container build
573493 {
574- Name : "store-post-build-artifacts" ,
575- Image : strings .TrimSpace (strings .Split (buildTrustedArtifacts , "FROM" )[1 ]),
576- ImagePullPolicy : v1 .PullIfNotPresent ,
577- SecurityContext : & v1.SecurityContext {RunAsUser : & zero },
578- Env : secretVariables ,
579- Script : fmt .Sprintf (`echo "Creating post-build-image archive"
580- export ORAS_OPTIONS="%s --image-spec=v1.0 --artifact-type application/vnd.oci.image.config.v1+json --no-tty --format=json"
581- IMGURL=%s
582- create-archive --store $IMGURL /tmp/artifacts=$(workspaces.source.path)/artifacts | tee /tmp/oras-create.json
583- IMGDIGEST=$(cat /tmp/oras-create.json | grep -Ev '(Prepared artifact|Artifacts created)' | jq -r '.digest')
584- echo "Storing IMGURL $IMGURL and IMGDIGEST $IMGDIGEST"
585- echo -n "$IMGURL" >> $(results.%s.path)
586- echo -n "$IMGDIGEST" >> $(results.%s.path)
587- ` , orasOptions , registryArgsWithDefaults (jbsConfig , buildId + "-artifacts" ), PipelineResultImage , PipelineResultImageDigest ),
494+ Name : "ORAS_OPTIONS" ,
495+ Value : tektonpipeline.ParamValue {
496+ Type : tektonpipeline .ParamTypeString ,
497+ StringVal : orasOptions ,
498+ },
588499 },
589- }}
590-
591- pipelineTask := []tektonpipeline.PipelineTask {{
592- Name : BuildTaskName ,
593- RunAfter : runAfter ,
594- TaskSpec : & tektonpipeline.EmbeddedTask {
595- TaskSpec : buildTask ,
596- },
597- Timeout : & v12.Duration {Duration : time .Hour * v1alpha1 .DefaultTimeout },
598- Params : []tektonpipeline.Param {
599500 {
600- Name : PipelineResultPreBuildImageDigest ,
601- Value : tektonpipeline.ParamValue {Type : tektonpipeline .ParamTypeString , StringVal : preBuildImage },
501+ Name : "TLSVERIFY" ,
502+ Value : tektonpipeline.ParamValue {
503+ Type : tektonpipeline .ParamTypeString ,
504+ StringVal : tlsVerify ,
505+ },
602506 },
603507 },
604- Workspaces : []tektonpipeline.WorkspacePipelineTaskBinding {
605- {Name : WorkspaceBuildSettings , Workspace : WorkspaceBuildSettings },
606- {Name : WorkspaceSource , Workspace : WorkspaceSource },
607- {Name : WorkspaceTls , Workspace : WorkspaceTls },
608- },
609- }}
610- ps .Tasks = append (pipelineTask , ps .Tasks ... )
611508
612- for _ , i := range buildTask .Results {
613- ps .Results = append (ps .Results , tektonpipeline.PipelineResult {Name : i .Name , Description : i .Description , Value : tektonpipeline.ResultValue {Type : tektonpipeline .ParamTypeString , StringVal : "$(tasks." + BuildTaskName + ".results." + i .Name + ")" }})
614- }
615- }
509+ // TODO: ### How to pass build-settings/tls information to buildah task?
510+ // Note - buildah-oci-ta task has no defined workspace
511+ //Workspaces: []tektonpipeline.WorkspacePipelineTaskBinding{
512+ // //{Name: WorkspaceBuildSettings, Workspace: WorkspaceBuildSettings},
513+ // {Name: WorkspaceSource, Workspace: WorkspaceSource},
514+ // //{Name: WorkspaceTls, Workspace: WorkspaceTls},
515+ //},
516+ }}, ps .Tasks ... )
517+
518+ // Results for https://github.com/konflux-ci/build-definitions/tree/main/task/buildah-oci-ta/0.2
519+ // IMAGE_DIGEST
520+ // IMAGE_URL
521+ ps .Results = append (ps .Results , tektonpipeline.PipelineResult {Name : PipelineResultImage , Value : tektonpipeline.ResultValue {Type : tektonpipeline .ParamTypeString , StringVal : "$(tasks." + BuildTaskName + ".results." + PipelineResultImage + ")" }})
522+ ps .Results = append (ps .Results , tektonpipeline.PipelineResult {Name : PipelineResultImageDigest , Value : tektonpipeline.ResultValue {Type : tektonpipeline .ParamTypeString , StringVal : "$(tasks." + BuildTaskName + ".results." + PipelineResultImageDigest + ")" }})
616523
617524 postBuildTask := tektonpipeline.TaskSpec {
618525 Workspaces : []tektonpipeline.WorkspaceDeclaration {{Name : WorkspaceBuildSettings }, {Name : WorkspaceSource , MountPath : WorkspaceMount }, {Name : WorkspaceTls }},
@@ -724,14 +631,6 @@ func secretVariables(jbsConfig *v1alpha1.JBSConfig) []v1.EnvVar {
724631 return secretVariables
725632}
726633
727- func createBuildScript (build string ) string {
728- ret := "tee $(workspaces." + WorkspaceSource + ".path)/build.sh <<'RHTAPEOF'\n "
729- ret += build
730- ret += "\n RHTAPEOF\n "
731- ret += "chmod +x $(workspaces." + WorkspaceSource + ".path)/build.sh\n "
732- return ret
733- }
734-
735634func createKonfluxScripts (containerfile string , konfluxScript string ) string {
736635 ret := "mkdir -p $(workspaces." + WorkspaceSource + ".path)/source/.jbs\n "
737636 ret += "tee $(workspaces." + WorkspaceSource + ".path)/source/.jbs/Containerfile <<'RHTAPEOF'\n "
@@ -858,7 +757,6 @@ func pipelineBuildCommands(imageId string, db *v1alpha1.DependencyBuild, jbsConf
858757 // Setting ORAS_OPTIONS to ensure the archive is compatible with jib (for OCIRepositoryClient).
859758 preBuildImageArgs := fmt .Sprintf (`echo "Creating pre-build-image archive"
860759export ORAS_OPTIONS="%s --image-spec=v1.0 --artifact-type application/vnd.oci.image.config.v1+json"
861- cp $(workspaces.source.path)/build.sh $(workspaces.source.path)/source/.jbs
862760create-archive --store %s $(results.%s.path)=$(workspaces.source.path)/source
863761` , orasOptions , registryArgsWithDefaults (jbsConfig , preBuildImageTag ), PipelineResultPreBuildImageDigest )
864762
@@ -877,9 +775,6 @@ create-archive --store %s $(results.%s.path)=$(workspaces.source.path)/source
877775 "--scm-uri=" + db .Spec .ScmInfo .SCMURL ,
878776 "--scm-commit=" + db .Spec .ScmInfo .CommitHash ,
879777 }
880- if ! jbsConfig .Spec .ContainerBuilds {
881- deployArgs = append (deployArgs , "--build-info-path=$(workspaces.source.path)/build-info" )
882- }
883778
884779 konfluxArgs := []string {
885780 "deploy-pre-build-source" ,
0 commit comments