blob: 687ebb600985dcbfe594f3111f1ace26e049e9ef [file] [log] [blame]
// Define global variables
// When the parameters change, this should be increased so that the build does nothing other than update the parameters used for the next build.
def pipelineVersion = '1'
def justjURL = 'https://download.eclipse.org/justj'
def testPrefix = "jres-test"
def testExtraPrefix = "archive/jres-test"
def defaultPrefix = "jres"
def java11 = [
label: 'Java 11',
BUILD_DESCRIPTION: 'Build jdk.java.net Java 11',
PUBLISH_LOCATION_PREFIX: "${defaultPrefix}",
JUSTJ_MANIFEST_URL: "${justjURL}/${defaultPrefix}/11/downloads/latest/justj.manifest",
JDK_URLS_WINDOWS: '''
https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_windows-x64_bin.zip
''',
JDK_URLS_MACOS: '''
https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_osx-x64_bin.tar.gz
''',
JDK_URLS_LINUX: '''
https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz
''',
JDK_URLS_LINUX_AARCH64: '''
''',
BUILD_TYPE: 'nightly',
PROMOTE: 'true'
]
def java14 = [
label: 'Java 14 (test)',
BUILD_DESCRIPTION: 'Build jdk.java.net Java 14 (-test)',
PUBLISH_LOCATION_PREFIX: "${testPrefix}",
JUSTJ_MANIFEST_URL: "${justjURL}/${testPrefix}/14/downloads/latest/justj.manifest",
JDK_URLS_WINDOWS: '''
https://download.java.net/java/GA/jdk14.0.2/205943a0976c4ed48cb16f1043c5c647/12/GPL/openjdk-14.0.2_windows-x64_bin.zip
''',
JDK_URLS_MACOS: '''
https://download.java.net/java/GA/jdk14.0.2/205943a0976c4ed48cb16f1043c5c647/12/GPL/openjdk-14.0.2_osx-x64_bin.tar.gz
''',
JDK_URLS_LINUX: '''
https://download.java.net/java/GA/jdk14.0.2/205943a0976c4ed48cb16f1043c5c647/12/GPL/openjdk-14.0.2_linux-x64_bin.tar.gz
''',
JDK_URLS_LINUX_AARCH64: '''
''',
BUILD_TYPE: 'nightly',
PROMOTE: 'true'
]
def java14Extra = [
label: 'Java 14 (++test)',
BUILD_DESCRIPTION: 'Build jdk.java.net and adoptopenjdk.net Java 14 (++test)',
PUBLISH_LOCATION_PREFIX: "${testExtraPrefix}",
JUSTJ_MANIFEST_URL: "${justjURL}/${testExtraPrefix}/14/downloads/latest/justj.manifest",
JDK_URLS_WINDOWS: '''
https://download.java.net/java/GA/jdk14.0.2/205943a0976c4ed48cb16f1043c5c647/12/GPL/openjdk-14.0.2_windows-x64_bin.zip
https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14.0.1+7.1/OpenJDK14U-jdk_x64_windows_hotspot_14.0.1_7.zip
https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14.0.1+7.1_openj9-0.20.0/OpenJDK14U-jdk_x64_windows_openj9_14.0.1_7_openj9-0.20.0.zip
''',
JDK_URLS_MACOS: '''
https://download.java.net/java/GA/jdk14.0.2/205943a0976c4ed48cb16f1043c5c647/12/GPL/openjdk-14.0.2_osx-x64_bin.tar.gz
https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14.0.1+7/OpenJDK14U-jdk_x64_mac_hotspot_14.0.1_7.tar.gz
https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14.0.1+7.2_openj9-0.20.0/OpenJDK14U-jdk_x64_mac_openj9_14.0.1_7_openj9-0.20.0.tar.gz
''',
JDK_URLS_LINUX: '''
https://download.java.net/java/GA/jdk14.0.2/205943a0976c4ed48cb16f1043c5c647/12/GPL/openjdk-14.0.2_linux-x64_bin.tar.gz
https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14.0.1+7/OpenJDK14U-jdk_x64_linux_hotspot_14.0.1_7.tar.gz
https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14.0.1+7_openj9-0.20.0/OpenJDK14U-jdk_x64_linux_openj9_14.0.1_7_openj9-0.20.0.tar.gz
''',
JDK_URLS_LINUX_AARCH64: '''
''',
BUILD_TYPE: 'nightly',
PROMOTE: 'true'
]
def java11Extra = [
label: 'Java 11 (++test)',
BUILD_DESCRIPTION: 'Build jdk.java.net and adoptopenjdk.net Java 11 (++test)',
PUBLISH_LOCATION_PREFIX: "${testExtraPrefix}",
JUSTJ_MANIFEST_URL: "${justjURL}/${testExtraPrefix}/11/downloads/latest/justj.manifest",
JDK_URLS_WINDOWS: '''
https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_windows-x64_bin.zip
https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7+10.2/OpenJDK11U-jdk_x64_windows_hotspot_11.0.7_10.zip
https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7+10.1_openj9-0.20.0/OpenJDK11U-jdk_x64_windows_openj9_11.0.7_10_openj9-0.20.0.zip
''',
JDK_URLS_MACOS: '''
https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_osx-x64_bin.tar.gz
https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7+10/OpenJDK11U-jdk_x64_mac_hotspot_11.0.7_10.tar.gz
https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7+10.2_openj9-0.20.0/OpenJDK11U-jdk_x64_mac_openj9_11.0.7_10_openj9-0.20.0.tar.gz
''',
JDK_URLS_LINUX: '''
https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz
https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7+10/OpenJDK11U-jdk_x64_linux_hotspot_11.0.7_10.tar.gz
https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7+10_openj9-0.20.0/OpenJDK11U-jdk_x64_linux_openj9_11.0.7_10_openj9-0.20.0.tar.gz
''',
JDK_URLS_LINUX_AARCH64: '''
''',
BUILD_TYPE: 'nightly',
PROMOTE: 'true'
]
def java15 = [
label: 'Java 15 (test)',
BUILD_DESCRIPTION: 'Build jdk.java.net Java 15 (-test)',
PUBLISH_LOCATION_PREFIX: "${testPrefix}",
JUSTJ_MANIFEST_URL: "${justjURL}/${testPrefix}/15/downloads/latest/justj.manifest",
JDK_URLS_WINDOWS: '''
https://download.java.net/java/GA/jdk15.0.2/0d1cfde4252546c6931946de8db48ee2/7/GPL/openjdk-15.0.2_windows-x64_bin.zip
''',
JDK_URLS_MACOS: '''
https://download.java.net/java/GA/jdk15.0.2/0d1cfde4252546c6931946de8db48ee2/7/GPL/openjdk-15.0.2_osx-x64_bin.tar.gz
''',
JDK_URLS_LINUX: '''
https://download.java.net/java/GA/jdk15.0.2/0d1cfde4252546c6931946de8db48ee2/7/GPL/openjdk-15.0.2_linux-x64_bin.tar.gz
''',
JDK_URLS_LINUX_AARCH64: '''
https://download.java.net/java/GA/jdk15.0.2/0d1cfde4252546c6931946de8db48ee2/7/GPL/openjdk-15.0.2_linux-aarch64_bin.tar.gz
''',
BUILD_TYPE: 'nightly',
PROMOTE: 'true'
]
def java16 = [
label: 'Java 16 (test)',
BUILD_DESCRIPTION: 'Build jdk.java.net Java 16 (-test)',
PUBLISH_LOCATION_PREFIX: "${testPrefix}",
JUSTJ_MANIFEST_URL: "${justjURL}/${testPrefix}/16/downloads/latest/justj.manifest",
JDK_URLS_WINDOWS: '''
https://download.java.net/java/GA/jdk16.0.2/d4a915d82b4c4fbb9bde534da945d746/7/GPL/openjdk-16.0.2_windows-x64_bin.zip
''',
JDK_URLS_MACOS: '''
https://download.java.net/java/GA/jdk16.0.2/d4a915d82b4c4fbb9bde534da945d746/7/GPL/openjdk-16.0.2_osx-x64_bin.tar.gz
''',
JDK_URLS_LINUX: '''
https://download.java.net/java/GA/jdk16.0.2/d4a915d82b4c4fbb9bde534da945d746/7/GPL/openjdk-16.0.2_linux-x64_bin.tar.gz
''',
JDK_URLS_LINUX_AARCH64: '''
https://download.java.net/java/GA/jdk16.0.2/d4a915d82b4c4fbb9bde534da945d746/7/GPL/openjdk-16.0.2_linux-aarch64_bin.tar.gz
''',
BUILD_TYPE: 'nightly',
PROMOTE: 'true'
]
def parambuilds = [
java11,
java11Extra,
java14,
java14Extra,
java15,
java16
]
def javaDefault = update(java16, [
BUILD_DESCRIPTION: 'Build jdk.java.net Java 16',
PUBLISH_LOCATION_PREFIX: "${defaultPrefix}",
JUSTJ_MANIFEST_URL: "${justjURL}/${defaultPrefix}/16/downloads/latest/justj.manifest"
])
// Use declarative syntax to run commands inside a Groovy sand-box container.
pipeline {
agent { label 'migration' }
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
disableConcurrentBuilds()
}
tools {
maven 'apache-maven-latest'
jdk 'oracle-jdk8-latest'
}
environment {
JUSTJ_BUILD_TIME_STAMP = sh(returnStdout: true, script: 'date +%Y%m%d_%H%M').trim()
JUSTJ_URL = "${justjURL}"
JUSTJ_STORAGE_LOCATION = '/home/data/httpd/download.eclipse.org/justj'
}
parameters {
string(
name: 'PIPELINE_VERSION',
defaultValue: "${pipelineVersion}",
description: """${pretty(
'''
If the parameter definitions have changed, this version will be out-dated.
The script will run but will do nothing other than updating the parameter definitions of the job as a side-effect.
'''
)}""")
string(
name: 'BUILD_DESCRIPTION',
defaultValue: 'Build jdk.java.net Java 16',
description: """${pretty(
"Use one of the following links to reconfigure the other parameters below.<br/>${buttons(parambuilds)}"
)}""")
string(
name: 'PUBLISH_LOCATION_PREFIX',
defaultValue: "${javaDefault.PUBLISH_LOCATION_PREFIX}",
description: """${pretty(
'''
The location under <a href="''' + justjURL + '''/" target="jres">''' + justjURL + '''/${PUBLISH_LOCATION_PREFIX}/${java.version}/downloads/</a> where to publish the results.
<br/>
Generally just use the default unless you plan to delete the results after the promotion.
'''
)}""")
string(
name: 'JUSTJ_MANIFEST_URL',
defaultValue: "${javaDefault.JUSTJ_MANIFEST_URL}",
description: """${pretty(
'''
Reuse an existing build of the JREs rather than building new ones.
In general, copy a justj.manifest link from an existing <a href="''' + "${justjURL}/${defaultPrefix}" + '''" target="jres">jres/${java.version}/downloads/latest/justj.manifest</a>.
The JDK URLs specified below will be ignored in this case.
<b>To build new JREs, clear this parameter field!<b>
<b>To do a release build, ensure that this field specifies the ${java.version} to be released.<b>
'''
)}""")
text(
name: 'JDK_URLS_WINDOWS',
defaultValue: "${pretty(javaDefault.JDK_URLS_WINDOWS)}",
description: 'One or more URLs to a Windows zip of a JDK, e.g., from <a href="https://jdk.java.net/" target="jdk">https://jdk.java.net/</a>.')
text(
name: 'JDK_URLS_MACOS',
defaultValue: "${pretty(javaDefault.JDK_URLS_MACOS)}",
description: 'One or more URLs to a MacOS tar.gz of a JDK, e.g., from <a href="https://jdk.java.net/" target="jdk">https://jdk.java.net/</a>.')
text(
name: 'JDK_URLS_LINUX',
defaultValue: "${pretty(javaDefault.JDK_URLS_LINUX)}",
description: 'One or more URLs to a Linux tar.gz of a JDK for x86_64, e.g., from <a href="https://jdk.java.net/" target="jdk">https://jdk.java.net/</a>.')
text(
name: 'JDK_URLS_LINUX_AARCH64',
defaultValue: "${pretty(javaDefault.JDK_URLS_LINUX_AARCH64)}",
description: 'One or more URLs to a Linux tar.gz of a JDK for aarch64, e.g., from <a href="https://jdk.java.net/" target="jdk">https://jdk.java.net/</a>.')
choice(
name: 'BUILD_TYPE',
choices: ['nightly', 'milestone', 'release'],
description: """${pretty(
'''
The type of build to produce.
A release build will not do a new build but rather will promote the most recent milestone build.
None of the values specified above are therefore relevant in this case, <b>except that the Java version of the JUSTJ_MANIFEST_URL determines which update site will be released</b>.
'''
)}""")
booleanParam(
name: 'PROMOTE',
defaultValue: false,
description: 'Whether to promote the p2 repository to the download server.'
)
}
stages {
stage('Setup Environment') {
when {
environment name: 'PIPELINE_VERSION', value: pipelineVersion
not { environment name: 'BUILD_NUMBER', value: '1' }
}
steps {
sh '''
echo 'Setting up environment...'
ls -R releng
chmod +x releng/org.eclipse.justj.releng/*.sh
'''
stash includes: 'releng/org.eclipse.justj.releng/**', name: 'releng-stash'
script {
env.PIPELINE_VERSION = params.PIPELINE_VERSION
env.PUBLISH_LOCATION_PREFIX = params.PUBLISH_LOCATION_PREFIX
env.JUSTJ_MANIFEST_URL = params.JUSTJ_MANIFEST_URL
env.JDK_URLS_WINDOWS = pretty(params.JDK_URLS_WINDOWS)
env.JDK_URLS_MACOS = pretty(params.JDK_URLS_MACOS)
env.JDK_URLS_LINUX = pretty(params.JDK_URLS_LINUX)
env.JDK_URLS_LINUX_AARCH64 = pretty(params.JDK_URLS_LINUX_AARCH64)
env.BUILD_TYPE = params.BUILD_TYPE
env.PROMOTE = params.PROMOTE
if (params.JUSTJ_MANIFEST_URL != '') {
env.JAVA_MAJOR_VERSION = sh(returnStdout: true, script: 'echo $(basename $(dirname $(dirname $(dirname $JUSTJ_MANIFEST_URL))))').trim()
env.JUSTJ_PUBLISH_LOCATION = "${env.PUBLISH_LOCATION_PREFIX}/${env.JAVA_MAJOR_VERSION}"
}
}
}
}
stage('Build JREs') {
when {
environment name: 'JUSTJ_MANIFEST_URL', value: ''
not {environment name: 'BUILD_TYPE', value: 'release' }
environment name: 'PIPELINE_VERSION', value: pipelineVersion
not { environment name: 'BUILD_NUMBER', value: '1' }
}
parallel {
stage('Build Linux JRES') {
when {
not { environment name: 'JDK_URLS_LINUX', value: '' }
}
steps {
sh '''
releng/org.eclipse.justj.releng/build-jre.sh
'''
}
}
stage('Build Linux JRES AArch64') {
agent {
label 'aarch64'
}
when {
beforeAgent true
not { environment name: 'JDK_URLS_LINUX_AARCH64', value: '' }
}
options { skipDefaultCheckout true }
steps {
cleanWs()
unstash 'releng-stash'
sh '''
releng/org.eclipse.justj.releng/build-jre.sh
'''
stash includes: '*org.eclipse.justj.*.tar.gz', name: 'linux-aarch64-stash'
}
}
stage('Build Windows JREs') {
agent {
label 'windows'
}
when {
beforeAgent true
not { environment name: 'JDK_URLS_WINDOWS', value: '' }
}
options { skipDefaultCheckout true }
steps {
cleanWs()
unstash 'releng-stash'
bat '''
bash -ex releng/org.eclipse.justj.releng/build-jre.sh
'''
stash includes: '*org.eclipse.justj.*.tar.gz', name: 'win-stash'
}
}
stage('Build MacOS JREs') {
agent {
label 'macos'
}
when {
beforeAgent true
not { environment name: 'JDK_URLS_MACOS', value: '' }
}
options { skipDefaultCheckout true }
steps {
cleanWs()
unstash 'releng-stash'
sh '''
releng/org.eclipse.justj.releng/build-jre.sh
'''
stash includes: 'org.eclipse.justj.*.tar.gz', name: 'mac-stash'
}
}
}
}
stage('Compose JREs') {
when {
environment name: 'JUSTJ_MANIFEST_URL', value: ''
not {environment name: 'BUILD_TYPE', value: 'release' }
environment name: 'PIPELINE_VERSION', value: pipelineVersion
not { environment name: 'BUILD_NUMBER', value: '1' }
}
steps {
script {
if (env.JDK_URLS_MACOS != '') {
unstash 'mac-stash'
}
if (env.JDK_URLS_WINDOWS != '') {
unstash 'win-stash'
}
if (env.JDK_URLS_LINUX_AARCH64 != '') {
unstash 'linux-aarch64-stash'
}
// Look for the java.version property in each JRE's properties file, extract out just the major version, and boil those down to unique values.
env.JAVA_MAJOR_VERSION = sh(returnStdout: true, script: 'echo $(for i in org.eclipse.justj.*.tar.gz; do tar -xOzf $i org.eclipse.justj.properties | grep "java.version=" | sed "s/^java.version=//g; s/[^0-9].*$//g"; done | sort -u)').trim()
env.JUSTJ_PUBLISH_LOCATION = "${env.PUBLISH_LOCATION_PREFIX}/${env.JAVA_MAJOR_VERSION}"
env.JUSTJ_JRE_PUBLISH_LOCATION = "${env.JUSTJ_PUBLISH_LOCATION}/downloads/${env.JUSTJ_BUILD_TIME_STAMP}"
}
sh '''
# Check that there is only one major version present.
echo "JAVA_MAJOR_VERSION='$JAVA_MAJOR_VERSION'"
echo "JUSTJ_PUBLISH_LOCATION='$JUSTJ_PUBLISH_LOCATION'"
echo "JUSTJ_JRE_PUBLISH_LOCATION='$JUSTJ_JRE_PUBLISH_LOCATION'"
if [[ $(echo $JAVA_MAJOR_VERSION | wc -w) == 1 ]]; then
echo "One Java major version."
else
echo "Inconsistent Java major versions."
exit 1
fi
'''
sh 'ls org.eclipse.justj.*.tar.gz > justj.manifest'
dir('releng/org.eclipse.justj.releng/index') {
sh '''
mvn --no-transfer-progress -Djustj.manifest.location=../../../justj.manifest -Djustj.manifest.url=$JUSTJ_URL/$JUSTJ_JRE_PUBLISH_LOCATION/justj.manifest clean verify
'''
}
archiveArtifacts 'org.eclipse.justj.*.tar.gz'
archiveArtifacts 'justj.manifest'
archiveArtifacts 'index.html'
sshagent(['projects-storage.eclipse.org-bot-ssh']) {
sh '''
ssh genie.justj@projects-storage.eclipse.org "
mkdir -p $JUSTJ_STORAGE_LOCATION/$JUSTJ_JRE_PUBLISH_LOCATION
"
scp index.html justj.manifest org.eclipse.justj.*.tar.gz genie.justj@projects-storage.eclipse.org:$JUSTJ_STORAGE_LOCATION/$JUSTJ_JRE_PUBLISH_LOCATION
ssh genie.justj@projects-storage.eclipse.org "
mkdir -p $JUSTJ_STORAGE_LOCATION/$JUSTJ_PUBLISH_LOCATION/downloads/latest
cd $JUSTJ_STORAGE_LOCATION/$JUSTJ_PUBLISH_LOCATION/downloads/latest
ls ../$JUSTJ_BUILD_TIME_STAMP/org.eclipse.justj.*.tar.gz > justj.manifest
cp ../$JUSTJ_BUILD_TIME_STAMP/index.html .
"
'''
}
}
}
// Even if we are doing a release build, we must generate the infrastructure needed to publish the release.
//
stage('Reconcile/Generate JRE Model') {
when {
environment name: 'PIPELINE_VERSION', value: pipelineVersion
not { environment name: 'BUILD_NUMBER', value: '1' }
}
steps {
dir('model/org.eclipse.justj.model') {
sh '''
# Use the one we built just now or the one that was specified in the parameters.
if [[ "$JUSTJ_MANIFEST_URL" == "" ]]; then
sed 's%source=".*[.]manifest"%source="'$JUSTJ_URL/$JUSTJ_JRE_PUBLISH_LOCATION'/justj.manifest"%g' < justj.jregen > justj-transformed.jregen
else
sed 's%source=".*[.]manifest"%source="'$JUSTJ_MANIFEST_URL'"%g' < justj.jregen > justj-transformed.jregen
fi
cat justj-transformed.jregen
mv justj-transformed.jregen justj.jregen
mvn --no-transfer-progress clean verify
'''
archiveArtifacts 'justj.jregen,*-gen/'
}
}
}
stage('Build JRE p2 Repository') {
when {
environment name: 'PIPELINE_VERSION', value: pipelineVersion
not { environment name: 'BUILD_NUMBER', value: '1' }
}
steps {
sshagent(['projects-storage.eclipse.org-bot-ssh']) {
dir('model/org.eclipse.justj.model/jre-gen') {
sh '''
if [[ $PROMOTE == false ]]; then
promotion_argument='-Dorg.eclipse.justj.p2.manager.args='
fi
if [[ $BUILD_TYPE == 'release' ]]; then
extra_argument='-DMAVEN_BUILD=false'
fi
mvn --no-transfer-progress $promotion_argument $extra_argument -Dorg.eclipse.justj.p2.manager.extra.args="-super $PUBLISH_LOCATION_PREFIX" -DPACK_AND_SIGN=true -Dorg.eclipse.justj.p2.manager.build.url=$JOB_URL -Dorg.eclipse.justj.p2.manager.relative=$JUSTJ_PUBLISH_LOCATION/updates -Dbuild.type=$BUILD_TYPE -Dgit.commit=$GIT_COMMIT -Dbuild.id=$BUILD_NUMBER clean verify
'''
script {
if (params.BUILD_TYPE != 'release') {
dir('releng/org.eclipse.justj.site/target') {
archiveArtifacts 'repository/,org.eclipse.justj.site*.zip'
}
}
}
}
}
}
}
}
post {
failure {
mail to: 'ed.merks@gmail.com',
subject: "[JustJ CI] Build Failure ${currentBuild.fullDisplayName}",
mimeType: 'text/html',
body: "Project: ${env.JOB_NAME}<br/>Build Number: ${env.BUILD_NUMBER}<br/>Build URL: ${env.BUILD_URL}<br/>Console: ${env.BUILD_URL}/console"
}
fixed {
mail to: 'ed.merks@gmail.com',
subject: "[JustJ CI] Back to normal ${currentBuild.fullDisplayName}",
mimeType: 'text/html',
body: "Project: ${env.JOB_NAME}<br/>Build Number: ${env.BUILD_NUMBER}<br/>Build URL: ${env.BUILD_URL}<br/>Console: ${env.BUILD_URL}/console"
}
cleanup {
deleteDir()
}
}
}
def pretty(string) {
return string.replaceAll("^\r?\n", "").replaceAll("\r?\n\$", "").replace("\r", "").stripIndent()
}
def update(map1, map2) {
def result = map1.clone()
result.putAll(map2)
return result
}
def buttons(list) {
// Styling links as buttons.
//
def buttonStyle = '''
margin-left: 2em;
margin-top: 1ex;
margin-bottom: 1ex;
font-weight: bold;
border: 1px solid Chocolate;
background-color: DarkOrange;
color: white;
padding: 0.25ex 0.25em;
text-align: center;
text-decoration: none;
display: inline-block;
'''.replaceAll("\\s+", " ").trim()
def result = ""
list.each {
result += "\n<a href='parambuild?${parambuild(it)}' style='${buttonStyle}'>${it.label}</a>"
}
return result
}
def parambuild(arguments) {
def result = ""
arguments.each { entry ->
// Ignore lower case entries
if (entry.key.matches("[A-Z0-9_]+")) {
if (!result.isEmpty()) {
result += "&"
}
result += entry.key
result += "="
result += encode(entry.value);
}
}
return result
}
def encode(string) {
return string.replace("\r", "").replaceAll("^\n", "").replaceAll("\\s+\$", "").stripIndent().replace("\r", "").replace("%", "%25").replace("&", "%26").replace("\n", "%0A").replace("+", "%2B").replace(" ", "+")
}