Skip to content

Commit 07a1b2f

Browse files
committed
Fix dev pipeline: Reduce Jenkinsfile method size to resolve compilation error
The Jenkinsfile was exceeding the JVM's 64KB method size limit when compiled to CPS bytecode, causing build #339 to fail with "Method too large" error. Changes: - Extract large shell scripts to separate files in jenkins/scripts/ - build-image.sh - build-ui-playground-image.sh - push-to-harbor.sh - push-ui-playground-to-harbor.sh - harbor-security-scan.sh - run-e2e-tests.sh - cleanup-images.sh - Reduce Jenkinsfile from 1110 to 619 lines (44% reduction) - Remove excessive debug statements - Simplify post blocks - Consolidate repetitive code patterns This refactoring maintains all functionality while ensuring the compiled CPS method stays within JVM limits. Fixes: https://jenkins.ethosengine.com/job/elohim/job/dev/339/console
1 parent 3c703a4 commit 07a1b2f

8 files changed

Lines changed: 249 additions & 562 deletions

Jenkinsfile

Lines changed: 71 additions & 562 deletions
Large diffs are not rendered by default.

jenkins/scripts/build-image.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
IMAGE_TAG=$1
5+
GIT_COMMIT_HASH=$2
6+
BRANCH_NAME=$3
7+
8+
# Verify BuildKit
9+
buildctl --addr unix:///run/buildkit/buildkitd.sock debug workers > /dev/null
10+
11+
# Create build context
12+
mkdir -p /tmp/build-context
13+
cp -r elohim-app /tmp/build-context/
14+
cp images/Dockerfile /tmp/build-context/
15+
cp images/nginx.conf /tmp/build-context/
16+
17+
# Build image
18+
cd /tmp/build-context
19+
BUILDKIT_HOST=unix:///run/buildkit/buildkitd.sock \
20+
nerdctl -n k8s.io build -t elohim-app:${IMAGE_TAG} -f Dockerfile .
21+
22+
# Additional tags
23+
nerdctl -n k8s.io tag elohim-app:${IMAGE_TAG} elohim-app:${GIT_COMMIT_HASH}
24+
25+
if [ "${BRANCH_NAME}" = "main" ]; then
26+
nerdctl -n k8s.io tag elohim-app:${IMAGE_TAG} elohim-app:latest
27+
fi
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
IMAGE_TAG=$1
5+
GIT_COMMIT_HASH=$2
6+
BRANCH_NAME=$3
7+
8+
# Verify BuildKit
9+
buildctl --addr unix:///run/buildkit/buildkitd.sock debug workers > /dev/null
10+
11+
# Create build context
12+
mkdir -p /tmp/build-context-playground
13+
cp -r elohim-library /tmp/build-context-playground/
14+
cp images/Dockerfile.ui-playground /tmp/build-context-playground/Dockerfile
15+
cp images/nginx-ui-playground.conf /tmp/build-context-playground/
16+
17+
# Build image
18+
cd /tmp/build-context-playground
19+
BUILDKIT_HOST=unix:///run/buildkit/buildkitd.sock \
20+
nerdctl -n k8s.io build -t elohim-ui-playground:${IMAGE_TAG} -f Dockerfile .
21+
22+
# Additional tags
23+
nerdctl -n k8s.io tag elohim-ui-playground:${IMAGE_TAG} elohim-ui-playground:${GIT_COMMIT_HASH}
24+
25+
if [ "${BRANCH_NAME}" = "main" ]; then
26+
nerdctl -n k8s.io tag elohim-ui-playground:${IMAGE_TAG} elohim-ui-playground:latest
27+
fi

jenkins/scripts/cleanup-images.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
IMAGE_TAG=$1
5+
GIT_COMMIT_HASH=$2
6+
BRANCH_NAME=$3
7+
8+
echo 'Cleaning up Docker images...'
9+
nerdctl -n k8s.io rmi elohim-app:${IMAGE_TAG} || true
10+
nerdctl -n k8s.io rmi elohim-app:${GIT_COMMIT_HASH} || true
11+
nerdctl -n k8s.io rmi harbor.ethosengine.com/ethosengine/elohim-site:${IMAGE_TAG} || true
12+
nerdctl -n k8s.io rmi harbor.ethosengine.com/ethosengine/elohim-site:${GIT_COMMIT_HASH} || true
13+
nerdctl -n k8s.io rmi elohim-ui-playground:${IMAGE_TAG} || true
14+
nerdctl -n k8s.io rmi elohim-ui-playground:${GIT_COMMIT_HASH} || true
15+
nerdctl -n k8s.io rmi harbor.ethosengine.com/ethosengine/elohim-ui-playground:${IMAGE_TAG} || true
16+
nerdctl -n k8s.io rmi harbor.ethosengine.com/ethosengine/elohim-ui-playground:${GIT_COMMIT_HASH} || true
17+
18+
if [ "${BRANCH_NAME}" = "main" ]; then
19+
nerdctl -n k8s.io rmi elohim-app:latest || true
20+
nerdctl -n k8s.io rmi harbor.ethosengine.com/ethosengine/elohim-site:latest || true
21+
nerdctl -n k8s.io rmi elohim-ui-playground:latest || true
22+
nerdctl -n k8s.io rmi harbor.ethosengine.com/ethosengine/elohim-ui-playground:latest || true
23+
fi
24+
25+
nerdctl -n k8s.io system prune -af --volumes || true
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
IMAGE_TAG=$1
5+
6+
AUTH_HEADER="Authorization: Basic $(echo -n "$HARBOR_USERNAME:$HARBOR_PASSWORD" | base64)"
7+
8+
# Trigger scan
9+
wget --post-data="" \
10+
--header="accept: application/json" \
11+
--header="Content-Type: application/json" \
12+
--header="$AUTH_HEADER" \
13+
-S -O- \
14+
"https://harbor.ethosengine.com/api/v2.0/projects/ethosengine/repositories/elohim-site/artifacts/${IMAGE_TAG}/scan" || \
15+
echo "Scan request failed"
16+
17+
# Poll for completion
18+
MAX_ATTEMPTS=24
19+
ATTEMPT=1
20+
21+
while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do
22+
VULN_DATA=$(wget -q -O- \
23+
--header="accept: application/json" \
24+
--header="$AUTH_HEADER" \
25+
"https://harbor.ethosengine.com/api/v2.0/projects/ethosengine/repositories/elohim-site/artifacts/${IMAGE_TAG}/additions/vulnerabilities" 2>/dev/null || echo "")
26+
27+
if [ ! -z "$VULN_DATA" ] && echo "$VULN_DATA" | grep -q '"scanner"'; then
28+
echo "✅ Scan completed"
29+
break
30+
fi
31+
32+
[ $((ATTEMPT % 5)) -eq 0 ] && echo "Waiting for scan (attempt $ATTEMPT/$MAX_ATTEMPTS)..."
33+
sleep 10
34+
ATTEMPT=$((ATTEMPT + 1))
35+
done

jenkins/scripts/push-to-harbor.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
IMAGE_TAG=$1
5+
GIT_COMMIT_HASH=$2
6+
BRANCH_NAME=$3
7+
8+
nerdctl -n k8s.io tag elohim-app:${IMAGE_TAG} harbor.ethosengine.com/ethosengine/elohim-site:${IMAGE_TAG}
9+
nerdctl -n k8s.io tag elohim-app:${IMAGE_TAG} harbor.ethosengine.com/ethosengine/elohim-site:${GIT_COMMIT_HASH}
10+
11+
nerdctl -n k8s.io push harbor.ethosengine.com/ethosengine/elohim-site:${IMAGE_TAG}
12+
nerdctl -n k8s.io push harbor.ethosengine.com/ethosengine/elohim-site:${GIT_COMMIT_HASH}
13+
14+
if [ "${BRANCH_NAME}" = "main" ]; then
15+
nerdctl -n k8s.io tag elohim-app:${IMAGE_TAG} harbor.ethosengine.com/ethosengine/elohim-site:latest
16+
nerdctl -n k8s.io push harbor.ethosengine.com/ethosengine/elohim-site:latest
17+
fi
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
IMAGE_TAG=$1
5+
GIT_COMMIT_HASH=$2
6+
BRANCH_NAME=$3
7+
8+
nerdctl -n k8s.io tag elohim-ui-playground:${IMAGE_TAG} harbor.ethosengine.com/ethosengine/elohim-ui-playground:${IMAGE_TAG}
9+
nerdctl -n k8s.io tag elohim-ui-playground:${IMAGE_TAG} harbor.ethosengine.com/ethosengine/elohim-ui-playground:${GIT_COMMIT_HASH}
10+
11+
nerdctl -n k8s.io push harbor.ethosengine.com/ethosengine/elohim-ui-playground:${IMAGE_TAG}
12+
nerdctl -n k8s.io push harbor.ethosengine.com/ethosengine/elohim-ui-playground:${GIT_COMMIT_HASH}
13+
14+
if [ "${BRANCH_NAME}" = "main" ]; then
15+
nerdctl -n k8s.io tag elohim-ui-playground:${IMAGE_TAG} harbor.ethosengine.com/ethosengine/elohim-ui-playground:latest
16+
nerdctl -n k8s.io push harbor.ethosengine.com/ethosengine/elohim-ui-playground:latest
17+
fi

jenkins/scripts/run-e2e-tests.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
BASE_URL=$1
5+
ENV=$2
6+
GIT_COMMIT_HASH=$3
7+
8+
export CYPRESS_baseUrl=$BASE_URL
9+
export CYPRESS_ENV=$ENV
10+
export CYPRESS_EXPECTED_GIT_HASH=$GIT_COMMIT_HASH
11+
export NO_COLOR=1
12+
export DISPLAY=:99
13+
14+
# Start Xvfb
15+
Xvfb :99 -screen 0 1024x768x24 -ac > /dev/null 2>&1 &
16+
XVFB_PID=$!
17+
sleep 2
18+
19+
# Verify Cypress
20+
npx cypress verify > /dev/null
21+
mkdir -p cypress/reports
22+
23+
# Run tests
24+
npx cypress run \
25+
--headless \
26+
--browser chromium \
27+
--spec "cypress/e2e/staging-validation.feature"
28+
29+
# Cleanup
30+
kill $XVFB_PID 2>/dev/null || true

0 commit comments

Comments
 (0)