Skip to content

Commit

Permalink
[Build] Use Maven-Daemon to speed up Maven artifact publication
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesWell committed Jan 5, 2025
1 parent 459446b commit b04cfa5
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions JenkinsJobs/Releng/publishToMaven.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ pipeline {
}
environment {
REPO = "${WORKSPACE}/repo"
PATH = "${installMavenDaemon('1.0.2')}/bin:${PATH}"
// Folder ~/.m2 is not writable for builds, ensure mvnd metadata are written within the workspace.
// prevent jline warning about inability to create a system terminal and increase keep-alive timeouts to increase stability in concurrent usage
MVND = "mvnd -Dmvnd.daemonStorage=${WORKSPACE}/tools/mvnd -Dorg.jline.terminal.type=dumb -Dmvnd.keepAlive=1000 -Dmvnd.maxLostKeepAlive=100 --no-transfer-progress"
}
// parameters declared in the definition of the invoking job
stages {
Expand Down Expand Up @@ -64,7 +68,7 @@ pipeline {
# Get each artifact and all its transitive dependencies from the Mavenized repository.
set -x
for i in $(cat coordinates.txt); do
mvn dependency:get --no-transfer-progress -Dosgi.platform=gtk.linux.x86_64 -Dartifact=$i -DremoteRepositories=file://${REPO}
${MVND} dependency:get -Dosgi.platform=gtk.linux.x86_64 -Dartifact=$i -DremoteRepositories=file://${REPO}
done
'''
}
Expand Down Expand Up @@ -160,7 +164,7 @@ pipeline {
fi
set -x

mvn -f "${configurationPom}" -s ${SETTINGS} --no-transfer-progress \\
${MVND} -f "${configurationPom}" -s ${SETTINGS} \\
gpg:sign-and-deploy-file -Dgpg.key.id=${GPG_KEY_ID} \\
-Durl=${URL} -DrepositoryId=${MAVEN_REPO} \\
-DpomFile=${pomFile} -Dfile=${file} \\
Expand All @@ -186,4 +190,15 @@ pipeline {
to: '[email protected]', from:'[email protected]'
}
}
}
}

def installMavenDaemon(String version){
return install('mvnd', "https://downloads.apache.org/maven/mvnd/${version}/maven-mvnd-${version}-linux-amd64.tar.gz")
}

def install(String toolType, String url) {
dir("${WORKSPACE}/tools/${toolType}") {
sh "curl -L ${url} | tar -xzf -"
return "${pwd()}/" + sh(script: 'ls', returnStdout: true).strip()
}
}

0 comments on commit b04cfa5

Please sign in to comment.