Skip to content

Commit ca5e1ba

Browse files
committed
Convert pre-build task to yaml.
1 parent cf4dd15 commit ca5e1ba

File tree

5 files changed

+273
-80
lines changed

5 files changed

+273
-80
lines changed

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: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
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+
name: jvm-build-git-secrets
89+
key: .git-credentials
90+
script: |
91+
$(params.GIT_SCRIPT)
92+
- name: preprocessor
93+
image: $(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE)
94+
securityContext:
95+
runAsUser: 0
96+
computeResources:
97+
limits:
98+
cpu: 300m
99+
memory: 512Mi
100+
requests:
101+
cpu: 10m
102+
memory: 512Mi
103+
script: |
104+
$(params.BUILD_SCRIPT)
105+
/opt/jboss/container/java/run/run-java.sh $(params.PREPROCESSOR_ARGS)
106+
- name: create-pre-build-source
107+
image: $(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE)
108+
securityContext:
109+
runAsUser: 0
110+
computeResources:
111+
limits:
112+
cpu: 300m
113+
memory: 512Mi
114+
requests:
115+
cpu: 10m
116+
memory: 512Mi
117+
env:
118+
- name: GIT_DEPLOY_TOKEN
119+
valueFrom:
120+
secretKeyRef:
121+
name: $(params.GIT_DEPLOY_TOKEN)
122+
key: gitdeploytoken
123+
args:
124+
- deploy-pre-build-source
125+
- --source-path=$(workspaces.source.path)/source
126+
- --task-run-name=$(context.taskRun.name)
127+
- --scm-uri=$(params.SCM_URL)
128+
- --scm-commit=$(params.SCM_HASH)
129+
- --image-id=$(params.NAME)
130+
- --git-identity=$(params.GIT_IDENTITY)
131+
- --git-url=$(params.GIT_URL)
132+
- --git-disable-ssl-verification=$(params.GIT_SSL_VERIFICATION)
133+
- --git-reuse-repository=$(params.GIT_REUSE_REPOSITORY)
134+
- name: create-pre-build-image
135+
image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:d6f57d97d19008437680190908fe5444cda380f9c77d0e9efde7153720412e05
136+
script: |
137+
echo "Creating pre-build-image archive"
138+
export ORAS_OPTIONS="$ORAS_OPTIONS --image-spec=v1.0 --artifact-type application/vnd.oci.image.config.v1+json"
139+
create-archive --store $(params.IMAGE_URL) $(results.PRE_BUILD_IMAGE_DIGEST.path)=$(workspaces.source.path)/source
140+
env:
141+
- name: ORAS_OPTIONS
142+
value: $(params.ORAS_OPTIONS)
143+
- name: IMAGE_URL
144+
value: $(params.IMAGE_URL)
145+

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)