Skip to content

Commit 3f763a5

Browse files
authored
Resolve Maven version dynamically in Jenkinsfile (#127)
* Resolve Maven version dynamically in Jenkinsfile Instead of hardcoding the Maven version (which breaks whenever Apache releases a new version), resolve the latest 3.x release from the GitHub API at build time. * Fix Groovy escaping for sed backslashes in Jenkinsfile * Use Maven Central metadata for version resolution, add CodeQL dispatch trigger - Switch from GitHub API to Maven Central maven-metadata.xml to resolve the latest Maven 3.x version (avoids rate limiting on unauthenticated requests) - Filter for stable 3.x releases only (no alpha/beta/rc, no Maven 4.x) - Add workflow_dispatch trigger to CodeQL workflow for manual runs * Use Maven Central metadata for version resolution, add CodeQL dispatch trigger
1 parent 27a9eae commit 3f763a5

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ defaults:
1414
run:
1515
working-directory: ./client
1616
on:
17+
workflow_dispatch:
1718
schedule:
1819
- cron: '19 3 * * 5'
1920

Jenkinsfile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,21 @@ pipeline {
6060
YARN_CACHE_FOLDER = "${env.WORKSPACE}/yarn-cache"
6161
SPAWN_WRAP_SHIM_ROOT = "${env.WORKSPACE}"
6262
EMAIL_TO= "glsp-build@eclipse.org"
63-
MAVEN_VERSION = "3.9.14"
64-
6563
}
66-
64+
6765
stages {
6866
stage('Download & Setup Maven') {
6967
steps {
7068
container('ci') {
7169
sh '''
72-
curl -o maven.tar.gz -L https://downloads.apache.org/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz
70+
MAVEN_VERSION=$(curl -sf "https://dlcdn.apache.org/maven/maven-3/" | grep -o 'href="[0-9][^"]*"' | tr -dc '0-9.')
71+
curl -o maven.tar.gz -L "https://dlcdn.apache.org/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz"
7372
tar -xzf maven.tar.gz -C ${WORKSPACE}
7473
rm -f maven.tar.gz
74+
echo "${WORKSPACE}/apache-maven-${MAVEN_VERSION}" > ${WORKSPACE}/.maven_home
7575
'''
76-
// Set MAVEN_HOME manually
7776
script {
78-
env.MAVEN_HOME = "${env.WORKSPACE}/apache-maven-${env.MAVEN_VERSION}"
77+
env.MAVEN_HOME = sh(script: "cat ${env.WORKSPACE}/.maven_home", returnStdout: true).trim()
7978
env.PATH = "${env.MAVEN_HOME}/bin:${env.PATH}"
8079
}
8180
sh "echo 'MAVEN_HOME set to ${env.MAVEN_HOME}'"

0 commit comments

Comments
 (0)