Skip to content

Commit 8968af6

Browse files
committed
Use single pipeline. Modify workspace. Make settings.xml available to deploy
1 parent f919901 commit 8968af6

File tree

5 files changed

+104
-22
lines changed

5 files changed

+104
-22
lines changed

deploy/tasks/maven-deployment.yaml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,33 @@ spec:
3232
description: Name of the processor image. Useful to override for development.
3333
type: string
3434
default: "quay.io/redhat-appstudio/hacbs-jvm-build-request-processor:dev"
35-
volumes:
36-
- name: workdir
37-
emptyDir: {}
38-
stepTemplate:
39-
volumeMounts:
40-
- mountPath: /var/workdir
41-
name: workdir
35+
workspaces:
36+
- description: Workspace.
37+
name: source
38+
mountPath: /var/workdir
39+
# volumes:
40+
# - name: workdir
41+
# emptyDir: {}
42+
# stepTemplate:
43+
# volumeMounts:
44+
# - mountPath: /var/workdir
45+
# name: workdir
4246
steps:
4347
- name: restore-trusted-artifact
4448
image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:81c4864dae6bb11595f657be887e205262e70086a05ed16ada827fd6391926ac
4549
script: |
50+
echo "Restoring artifacts to workspace"
51+
ls -laR /var/workdir
52+
echo "Root"
53+
ls -laR $HOME
4654
echo "Restoring artifacts to workspace"
4755
URL=$IMAGE_URL
4856
DIGEST=$IMAGE_DIGEST
4957
AARCHIVE=$(oras manifest fetch $ORAS_OPTIONS $URL@$DIGEST | jq --raw-output '.layers[0].digest')
5058
echo "URL $URL DIGEST $DIGEST AARCHIVE $AARCHIVE"
51-
use-archive oci:$URL@$AARCHIVE=/var/workdir/artifacts
59+
use-archive oci:$URL@$AARCHIVE=/var/workdir/
60+
ls -laR /var/workdir
61+
echo "DONE"
5262
env:
5363
- name: IMAGE_DIGEST
5464
value: $(params.IMAGE_DIGEST)
@@ -77,6 +87,6 @@ spec:
7787
key: mavenpassword
7888
args:
7989
- deploy
80-
- --directory=/var/workdir/artifacts
90+
- --directory=/var/workdir/deployment
8191
- --mvn-repo=$(params.MVN_REPO)
8292
- --mvn-username=$(params.MVN_USERNAME)

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void run() {
105105
export MAVEN_HOME=${MAVEN_HOME:=/opt/maven/3.8.8}
106106
export GRADLE_USER_HOME="${JBS_WORKDIR}/software/settings/.gradle"
107107
108-
mkdir -p ${JBS_WORKDIR}/logs ${JBS_WORKDIR}/packages ${HOME}/.sbt/1.0 ${GRADLE_USER_HOME} ${HOME}/.m2
108+
mkdir -p ${JBS_WORKDIR}/logs ${JBS_WORKDIR}/packages ${JBS_WORKDIR}/settings ${HOME}/.sbt/1.0 ${GRADLE_USER_HOME} ${HOME}/.m2
109109
cd ${JBS_WORKDIR}/source
110110
111111
if [ -n "${JAVA_HOME}" ]; then
@@ -119,6 +119,7 @@ public void run() {
119119
runBuild += getMavenSetup();
120120

121121
runBuild += """
122+
cp -a ${HOME}/.m2/*.xml ${JBS_WORKDIR}/settings
122123
fi
123124
124125
if [ -n "${GRADLE_HOME}" ]; then
@@ -190,7 +191,8 @@ private String getContainerFile() {
190191
COPY --from=0 /var/workdir/ /var/workdir/
191192
RUN /opt/jboss/container/java/run/run-java.sh copy-artifacts --source-path=/var/workdir/workspace/source --deploy-path=/var/workdir/workspace/artifacts
192193
FROM scratch
193-
COPY --from=1 /var/workdir/workspace/artifacts /
194+
COPY --from=1 /var/workdir/workspace/settings /
195+
COPY --from=1 /var/workdir/workspace/artifacts /deployment/
194196
""".formatted(buildRequestProcessorImage);
195197
} else {
196198
containerFile +=

pkg/apis/jvmbuildservice/v1alpha1/systemconfig_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ const (
4949
KonfluxGitDefinition = "https://raw.githubusercontent.com/konflux-ci/build-definitions/refs/heads/main/task/git-clone/0.1/git-clone.yaml"
5050
KonfluxPreBuildDefinitions = "https://raw.githubusercontent.com/redhat-appstudio/jvm-build-service/main/deploy/tasks/pre-build.yaml"
5151
KonfluxBuildDefinitions = "https://raw.githubusercontent.com/konflux-ci/build-definitions/refs/heads/main/task/buildah-oci-ta/0.2/buildah-oci-ta.yaml"
52-
KonfluxMavenDeployDefinitions = "https://raw.githubusercontent.com/redhat-appstudio/jvm-build-service/main/deploy/tasks/maven-deployment.yaml"
52+
KonfluxMavenDeployDefinitions = "https://raw.githubusercontent.com/rnc/jvm-build-service/PIPELINE/deploy/tasks/maven-deployment.yaml"
5353
)

pkg/reconciler/dependencybuild/buildrecipeyaml.go

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func createPipelineSpec(log logr.Logger, tool string, commitTime int64, jbsConfi
137137
verifyBuiltArtifactsArgs := verifyParameters(jbsConfig, recipe)
138138
deployArgs := []string{
139139
"verify",
140-
"--path=$(workspaces.source.path)/artifacts",
140+
"--path=$(workspaces.source.path)/verify-artifacts",
141141
"--logs-path=$(workspaces.source.path)/logs",
142142
"--task-run-name=$(context.taskRun.name)",
143143
"--build-id=" + buildId,
@@ -463,7 +463,7 @@ func createPipelineSpec(log logr.Logger, tool string, commitTime int64, jbsConfi
463463
}
464464

465465
// Note - its also possible to refer to a remote pipeline ref as well as a task.
466-
resolver := tektonpipeline.ResolverRef{
466+
buildResolver := tektonpipeline.ResolverRef{
467467
// We can use either a http or git resolver. Using http as avoids cloning an entire repository.
468468
Resolver: "http",
469469
Params: []tektonpipeline.Param{
@@ -483,7 +483,7 @@ func createPipelineSpec(log logr.Logger, tool string, commitTime int64, jbsConfi
483483
RunAfter: runAfter,
484484
TaskRef: &tektonpipeline.TaskRef{
485485
// Can't specify name and resolver as they clash.
486-
ResolverRef: resolver,
486+
ResolverRef: buildResolver,
487487
},
488488
Timeout: &v12.Duration{Duration: time.Hour * v1alpha1.DefaultTimeout},
489489
Params: []tektonpipeline.Param{
@@ -556,7 +556,7 @@ URL=%s
556556
DIGEST=$(tasks.%s.results.IMAGE_DIGEST)
557557
AARCHIVE=$(oras manifest fetch $ORAS_OPTIONS $URL@$DIGEST | jq --raw-output '.layers[0].digest')
558558
echo "URL $URL DIGEST $DIGEST AARCHIVE $AARCHIVE"
559-
use-archive oci:$URL@$AARCHIVE=$(workspaces.source.path)/artifacts`, orasOptions, registryArgsWithDefaults(jbsConfig, ""), BuildTaskName),
559+
use-archive oci:$URL@$AARCHIVE=$(workspaces.source.path)/verify-artifacts`, orasOptions, registryArgsWithDefaults(jbsConfig, ""), BuildTaskName),
560560
},
561561
{
562562
Name: "verify-and-check-for-contaminates",
@@ -586,11 +586,80 @@ use-archive oci:$URL@$AARCHIVE=$(workspaces.source.path)/artifacts`, orasOptions
586586
},
587587
}}
588588
ps.Tasks = append(pipelineTask, ps.Tasks...)
589-
590589
for _, i := range postBuildTask.Results {
591590
ps.Results = append(ps.Results, tektonpipeline.PipelineResult{Name: i.Name, Description: i.Description, Value: tektonpipeline.ResultValue{Type: tektonpipeline.ParamTypeString, StringVal: "$(tasks." + PostBuildTaskName + ".results." + i.Name + ")"}})
592591
}
593592

593+
deployResolver := tektonpipeline.ResolverRef{
594+
// We can use either a http or git resolver. Using http as avoids cloning an entire repository.
595+
Resolver: "http",
596+
Params: []tektonpipeline.Param{
597+
{
598+
Name: "url",
599+
Value: tektonpipeline.ParamValue{
600+
Type: tektonpipeline.ParamTypeString,
601+
StringVal: v1alpha1.KonfluxMavenDeployDefinitions,
602+
},
603+
},
604+
},
605+
}
606+
ps.Tasks = append([]tektonpipeline.PipelineTask{
607+
{
608+
Name: DeployTaskName,
609+
RunAfter: append(runAfterBuild, PostBuildTaskName),
610+
Workspaces: []tektonpipeline.WorkspacePipelineTaskBinding{
611+
{Name: WorkspaceSource, Workspace: WorkspaceSource},
612+
},
613+
TaskRef: &tektonpipeline.TaskRef{
614+
// Can't specify name and resolver as they clash.
615+
ResolverRef: deployResolver,
616+
},
617+
Params: []tektonpipeline.Param{
618+
{
619+
Name: PipelineResultImage,
620+
Value: tektonpipeline.ParamValue{
621+
Type: tektonpipeline.ParamTypeString,
622+
StringVal: "$(tasks." + BuildTaskName + ".results." + PipelineResultImage + ")",
623+
},
624+
},
625+
{
626+
Name: PipelineResultImageDigest,
627+
Value: tektonpipeline.ParamValue{
628+
Type: tektonpipeline.ParamTypeString,
629+
StringVal: "$(tasks." + BuildTaskName + ".results." + PipelineResultImageDigest + ")",
630+
},
631+
},
632+
{
633+
Name: "MVN_REPO",
634+
Value: tektonpipeline.ParamValue{
635+
Type: tektonpipeline.ParamTypeString,
636+
StringVal: jbsConfig.Spec.MavenDeployment.Repository,
637+
},
638+
},
639+
{
640+
Name: "MVN_USERNAME",
641+
Value: tektonpipeline.ParamValue{
642+
Type: tektonpipeline.ParamTypeString,
643+
StringVal: jbsConfig.Spec.MavenDeployment.Username,
644+
},
645+
},
646+
{
647+
Name: "MVN_PASSWORD",
648+
Value: tektonpipeline.ParamValue{
649+
Type: tektonpipeline.ParamTypeString,
650+
StringVal: v1alpha1.MavenSecretName,
651+
},
652+
},
653+
{
654+
Name: "JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE",
655+
Value: tektonpipeline.ParamValue{
656+
Type: tektonpipeline.ParamTypeString,
657+
StringVal: buildRequestProcessorImage,
658+
},
659+
},
660+
},
661+
}}, ps.Tasks...)
662+
594663
for _, i := range pipelineParams {
595664
ps.Params = append(ps.Params, tektonpipeline.ParamSpec{Name: i.Name, Description: i.Description, Default: i.Default, Type: i.Type})
596665
var value tektonpipeline.ResultValue

pkg/reconciler/dependencybuild/dependencybuild.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ func (r *ReconcileDependencyBuild) Reconcile(ctx context.Context, request reconc
140140
return reconcile.Result{}, nil
141141
case v1alpha1.DependencyBuildStateBuilding:
142142
return r.handleStateBuilding(ctx, &db)
143-
case v1alpha1.DependencyBuildStateDeploying:
144-
return r.handleStateDeploying(ctx, &db)
143+
//case v1alpha1.DependencyBuildStateDeploying:
144+
// return r.handleStateDeploying(ctx, &db)
145145
case v1alpha1.DependencyBuildStateContaminated:
146146
return r.handleStateContaminated(ctx, &db)
147147
case v1alpha1.DependencyBuildStateComplete:
@@ -168,8 +168,8 @@ func (r *ReconcileDependencyBuild) Reconcile(ctx context.Context, request reconc
168168
return r.handleAnalyzeBuildPipelineRunReceived(ctx, &pr)
169169
case PipelineTypeBuild:
170170
return r.handleBuildPipelineRunReceived(ctx, &pr)
171-
case PipelineTypeDeploy:
172-
return r.handleDeployPipelineRunReceived(ctx, &pr)
171+
//case PipelineTypeDeploy:
172+
// return r.handleDeployPipelineRunReceived(ctx, &pr)
173173
}
174174
}
175175

@@ -849,7 +849,7 @@ func (r *ReconcileDependencyBuild) handleBuildPipelineRunReceived(ctx context.Co
849849

850850
problemContaminates := db.Status.ProblemContaminates()
851851
if len(problemContaminates) == 0 {
852-
return reconcile.Result{}, r.updateDependencyBuildState(ctx, db, v1alpha1.DependencyBuildStateDeploying, "build was completed")
852+
return reconcile.Result{}, r.updateDependencyBuildState(ctx, db, v1alpha1.DependencyBuildStateComplete, "build was completed")
853853
} else {
854854
msg := "The DependencyBuild %s/%s was contaminated with community dependencies"
855855
log.Info(fmt.Sprintf(msg, db.Namespace, db.Name))
@@ -1364,6 +1364,7 @@ func (r *ReconcileDependencyBuild) removePipelineFinalizer(ctx context.Context,
13641364
func (r *ReconcileDependencyBuild) handleStateDeploying(ctx context.Context, db *v1alpha1.DependencyBuild) (reconcile.Result, error) {
13651365

13661366
log, _ := logr.FromContext(ctx)
1367+
log.Info(fmt.Sprintf("### handleStateDeploying %#v", db.Name))
13671368
//first we check to see if the pipeline exists
13681369

13691370
pr := tektonpipeline.PipelineRun{}

0 commit comments

Comments
 (0)