@@ -4,44 +4,73 @@ metadata:
44 name : integration-and-unit-tests
55 namespace : multiarch-tuning-ope-tenant
66spec :
7- params : [ ]
7+ params :
8+ - name : SNAPSHOT
9+ description : ' Snapshot of the application'
10+ type : string
11+ default : ' {"components": [{"name":"multiarch-tuning-operator", "containerImage": "quay.io/example/repo:latest"}]}'
812 tasks :
913 - name : clone-and-test
14+ params :
15+ - name : SNAPSHOT
16+ value : $(params.SNAPSHOT)
1017 taskSpec :
18+ params :
19+ - name : SNAPSHOT
20+ type : string
1121 volumes :
1222 - name : source
1323 emptyDir : { }
1424 steps :
1525 - image : brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_9_1.25
1626 env :
17- - name : URL
18- valueFrom :
19- fieldRef :
20- fieldPath : metadata.annotations['pac.test.appstudio.openshift.io/source-repo-url']
21- - name : REVISION
22- valueFrom :
23- fieldRef :
24- fieldPath : metadata.annotations['pac.test.appstudio.openshift.io/sha']
27+ - name : SNAPSHOT
28+ value : $(params.SNAPSHOT)
2529 computeResources :
2630 limits :
2731 cpu : 8
28- memory : 4Gi
32+ memory : 8Gi
2933 requests :
3034 cpu : 500m
31- memory : 1Gi
35+ memory : 2Gi
3236 volumeMounts :
3337 - name : source
3438 mountPath : /workspace
3539 script : |
3640 #!/bin/bash
3741 set -exuo pipefail
42+
43+ echo "Debug: SNAPSHOT content:"
44+ echo "${SNAPSHOT}"
45+
46+ # Parse JSON using Python (available in golang-builder image)
47+ read -r URL REVISION <<< $(python3 -c "
48+ import json, sys
49+ snapshot = json.loads('''${SNAPSHOT}''')
50+ components = snapshot.get('components', [])
51+ if components:
52+ comp = components[0]
53+ # Try source.git first (newer format)
54+ url = comp.get('source', {}).get('git', {}).get('url', '')
55+ rev = comp.get('source', {}).get('git', {}).get('revision', '')
56+ # Fallback to top-level fields
57+ if not url:
58+ url = comp.get('repository', '')
59+ if not rev:
60+ rev = comp.get('revision', '')
61+ print(url, rev)
62+ ")
63+
3864 if [ -z "$URL" ] || [ -z "$REVISION" ]; then
39- echo "URL and REVISION must be set"
65+ echo "ERROR: Could not extract git URL and revision from SNAPSHOT"
66+ echo "SNAPSHOT must include components[].source.git.url and components[].source.git.revision"
4067 exit 1
4168 fi
69+
4270 echo "Initializing the env vars"
4371 echo "URL: $URL"
4472 echo "REVISION: $REVISION"
73+
4574 mkdir /workspace/source
4675 cd /workspace/source
4776 git init
0 commit comments