Skip to content

Commit 7259949

Browse files
authored
Merge pull request #2117 from rnc/KJB11
Convert pre-build task to yaml.
2 parents cf4dd15 + 5717743 commit 7259949

File tree

10 files changed

+382
-189
lines changed

10 files changed

+382
-189
lines changed

deploy/base-development.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,13 @@ fi
4242
# and if 'true' or 'false' is seen that is coerced to a bool which causes an issue
4343
export JBS_S3_SYNC_ENABLED="\"$JBS_S3_SYNC_ENABLED\""
4444

45-
kubectl delete --ignore-not-found deployments.apps hacbs-jvm-operator -n jvm-build-service
46-
kubectl delete --ignore-not-found deployments.apps jvm-build-workspace-artifact-cache
47-
4845
function cleanAllArtifacts() {
4946
# Following are created in CI code
5047
kubectl delete --ignore-not-found=true tasks.tekton.dev git-clone
5148
kubectl delete --ignore-not-found=true tasks.tekton.dev maven
5249
kubectl delete --ignore-not-found=true pipelines.tekton.dev sample-component-build
53-
kubectl delete --ignore-not-found=true clusterrolebindings.rbac.authorization.k8s.io pipeline-test-jvm-namespace
50+
kubectl delete --ignore-not-found=true clusterrolebindings.rbac.authorization.k8s.io pipeline-${JBS_WORKER_NAMESPACE}
51+
kubectl delete --ignore-not-found=true deployments.apps jvm-build-maven-repo -n ${JBS_WORKER_NAMESPACE}
5452

5553
kubectl delete --ignore-not-found=true artifactbuilds.jvmbuildservice.io --all
5654

@@ -61,6 +59,9 @@ function cleanAllArtifacts() {
6159
echo -e "\033[0;32mSetting context to $JBS_WORKER_NAMESPACE with quay image $JBS_QUAY_ORG\033[0m"
6260
# Its possible to set context before namespaces have been created.
6361
kubectl config set-context --current --namespace=$JBS_WORKER_NAMESPACE
62+
kubectl delete --ignore-not-found deployments.apps hacbs-jvm-operator -n jvm-build-service
63+
kubectl delete --ignore-not-found deployments.apps jvm-build-workspace-artifact-cache
64+
6465

6566
if [ "$1" = "--clean" ]; then
6667
cleanAllArtifacts

deploy/tasks/maven-deployment.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,10 @@ spec:
3737
type: string
3838
default: "quay.io/redhat-appstudio/hacbs-jvm-build-request-processor:dev"
3939
volumes:
40-
- name: shared
41-
emptyDir: {}
4240
- name: workdir
4341
emptyDir: {}
4442
stepTemplate:
4543
volumeMounts:
46-
- mountPath: /shared
47-
name: shared
4844
- mountPath: /var/workdir
4945
name: workdir
5046
steps:
@@ -70,10 +66,10 @@ spec:
7066
runAsUser: 0
7167
computeResources:
7268
limits:
73-
cpu: "1"
74-
memory: 2Gi
69+
cpu: 300m
70+
memory: 512Mi
7571
requests:
76-
cpu: 50m
72+
cpu: 10m
7773
memory: 512Mi
7874
env:
7975
- name: MVN_REPO

deploy/tasks/pre-build.yaml

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
---
2+
apiVersion: tekton.dev/v1
3+
kind: Task
4+
metadata:
5+
name: pre-build
6+
annotations:
7+
tekton.dev/pipelines.minVersion: 0.12.1
8+
tekton.dev/tags: image-build, konflux
9+
labels:
10+
app.kubernetes.io/version: "0.1"
11+
build.appstudio.redhat.com/build_type: docker
12+
spec:
13+
description: |-
14+
Sets up pre-build running the preprocessor, pushing the source and creating the OCI image.
15+
params:
16+
- name: IMAGE_URL
17+
description: URL of the OCI image to use.
18+
type: string
19+
- name: NAME
20+
description: Name of the pipeline run (i.e. unique dependency build name)
21+
type: string
22+
- name: GIT_SCRIPT
23+
description: Git clone commands
24+
type: string
25+
- name: GIT_IDENTITY
26+
description: Git username
27+
type: string
28+
- name: GIT_URL
29+
description: URL to determine whether we're using gitlab or github
30+
type: string
31+
- name: GIT_DEPLOY_TOKEN
32+
description: Name of jvm-build-git-repo-secrets secret containing git password/token to use.
33+
type: string
34+
- name: GIT_SSL_VERIFICATION
35+
description: Whether to disable ssl verification
36+
type: string
37+
default: "false"
38+
- name: GIT_REUSE_REPOSITORY
39+
description: Whether to reuse existing git repository or create new one
40+
type: string
41+
- name: SCM_URL
42+
description: Reference to the git repository
43+
type: string
44+
- name: SCM_HASH
45+
description: Git hash
46+
type: string
47+
- name: RECIPE_IMAGE
48+
description: The image from the build recipe to use
49+
- name: BUILD_SCRIPT
50+
description: The build script to embed with the Containerfile
51+
- name: PREPROCESSOR_ARGS
52+
description: The arguments for the build preprocessor
53+
- name: ORAS_OPTIONS
54+
type: string
55+
description: Optional environment variable string for build-trusted-artifacts
56+
default: ""
57+
- name: JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE
58+
description: Name of the processor image. Useful to override for development.
59+
type: string
60+
default: "quay.io/redhat-appstudio/hacbs-jvm-build-request-processor:dev"
61+
results:
62+
- name: PRE_BUILD_IMAGE_DIGEST
63+
description: Digest of the image just built
64+
- name: GIT_ARCHIVE
65+
description: Git archive information
66+
workspaces:
67+
- description: The git repo will be cloned onto the volume backing this Workspace.
68+
name: source
69+
mountPath: /var/workdir
70+
- name: tls
71+
steps:
72+
# Should we use our own git clone task? Or embed (somehow) Konflux's version?
73+
- name: git-clone
74+
image: $(params.RECIPE_IMAGE)
75+
computeResources:
76+
limits:
77+
cpu: 300m
78+
memory: 512Mi
79+
requests:
80+
cpu: 10m
81+
memory: 512Mi
82+
securityContext:
83+
runAsUser: 0
84+
env:
85+
- name: GIT_TOKEN
86+
valueFrom:
87+
secretKeyRef:
88+
optional: true
89+
name: jvm-build-git-secrets
90+
key: .git-credentials
91+
script: |
92+
$(params.GIT_SCRIPT)
93+
- name: preprocessor
94+
image: $(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE)
95+
securityContext:
96+
runAsUser: 0
97+
computeResources:
98+
limits:
99+
cpu: 300m
100+
memory: 512Mi
101+
requests:
102+
cpu: 10m
103+
memory: 512Mi
104+
script: |
105+
$(params.BUILD_SCRIPT)
106+
/opt/jboss/container/java/run/run-java.sh $(params.PREPROCESSOR_ARGS)
107+
- name: create-pre-build-source
108+
image: $(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE)
109+
securityContext:
110+
runAsUser: 0
111+
computeResources:
112+
limits:
113+
cpu: 300m
114+
memory: 512Mi
115+
requests:
116+
cpu: 10m
117+
memory: 512Mi
118+
env:
119+
- name: GIT_DEPLOY_TOKEN
120+
valueFrom:
121+
secretKeyRef:
122+
optional: true
123+
name: $(params.GIT_DEPLOY_TOKEN)
124+
key: gitdeploytoken
125+
args:
126+
- deploy-pre-build-source
127+
- --source-path=$(workspaces.source.path)/source
128+
- --task-run-name=$(context.taskRun.name)
129+
- --scm-uri=$(params.SCM_URL)
130+
- --scm-commit=$(params.SCM_HASH)
131+
- --image-id=$(params.NAME)
132+
- --git-identity=$(params.GIT_IDENTITY)
133+
- --git-url=$(params.GIT_URL)
134+
- --git-disable-ssl-verification=$(params.GIT_SSL_VERIFICATION)
135+
- --git-reuse-repository=$(params.GIT_REUSE_REPOSITORY)
136+
- name: create-pre-build-image
137+
image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:d6f57d97d19008437680190908fe5444cda380f9c77d0e9efde7153720412e05
138+
script: |
139+
echo "Creating pre-build-image archive"
140+
export ORAS_OPTIONS="$ORAS_OPTIONS --image-spec=v1.0 --artifact-type application/vnd.oci.image.config.v1+json"
141+
create-archive --store $(params.IMAGE_URL) $(results.PRE_BUILD_IMAGE_DIGEST.path)=$(workspaces.source.path)/source
142+
env:
143+
- name: ORAS_OPTIONS
144+
value: $(params.ORAS_OPTIONS)
145+
- name: IMAGE_URL
146+
value: $(params.IMAGE_URL)
147+

java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/deploy/git/GitHub.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ enum Type {
3232
public GitHub(String endpoint, String identity, String token, boolean ssl)
3333
throws IOException {
3434
if (isNotEmpty(token)) {
35-
github = new GitHubBuilder().withEndpoint(endpoint == null ? GITHUB_URL : endpoint)
35+
github = new GitHubBuilder().withEndpoint(isNotEmpty(endpoint) ? endpoint : GITHUB_URL)
3636
.withOAuthToken(token)
3737
.build();
3838
} else {
39-
github = new GitHubBuilder().withEndpoint(endpoint == null ? GITHUB_URL : endpoint)
39+
github = new GitHubBuilder().withEndpoint(isNotEmpty(endpoint) ? endpoint : GITHUB_URL)
4040
.build();
4141
}
4242
owner = identity;

0 commit comments

Comments
 (0)