1+ pipeline {
2+ options {
3+ disableConcurrentBuilds() // prevent concurrent updates of the same repository
4+ timestamps()
5+ skipDefaultCheckout()
6+ timeout(time: 15, unit: 'MINUTES')
7+ buildDiscarder(logRotator(numToKeepStr:'5'))
8+ }
9+ agent {
10+ label 'ubuntu-2404'
11+ }
12+ tools {
13+ jdk 'temurin-jdk21-latest'
14+ }
15+ environment {
16+ ECLIPSE_EXE = installLatestReleasedEclipsePlatformProduct()
17+ }
18+ stages {
19+ stage('Check Composites Validity') {
20+ steps {
21+ sh '''
22+ for repo in ${add//,/ }; do
23+ if [[ $repo != http* ]]; then
24+ repo="https://download.eclipse.org/${repositoryPath}/${repo}"
25+ fi
26+ echo "Validate content consistency of: ${repo}"
27+ ${ECLIPSE_EXE} -nosplash -consolelog --launcher.suppressErrors -application org.eclipse.equinox.p2.director -repository "${repo}" -list
28+ done
29+ '''
30+ }
31+ }
32+ stage('Update composite repository') {
33+ environment {
34+ ANT_TASK_NAME = 'modifyComposite'
35+ OUTPUT_PATH = 'output-repository'
36+ }
37+ steps {
38+ script {
39+ sh "curl -o compositeArtifacts.jar https://download.eclipse.org/${repositoryPath}/compositeArtifacts.jar"
40+ def childenXPathSet = sh(script: '''#!/bin/sh +xe
41+ unzip -p compositeArtifacts.jar compositeArtifacts.xml |\
42+ xmllint - --xpath '/repository/children/child/@location'
43+ exit 0
44+ ''', returnStdout: true).trim()
45+ def compositeChildren = 'XPath set is empty' == childenXPathSet ? []
46+ : parseList(childenXPathSet, '\\s+')
47+ .collect{c -> c.startsWith('location="') && c.endsWith('"') ? c.substring(10, c.length() - 1) : null}
48+ .findAll{c -> c != null}
49+
50+ echo "Current children: ${compositeChildren}"
51+ def toAdd = parseList(params.add, ',').unique()
52+ def toRemove = parseList(params.remove, ',').unique()
53+ toRemove = toRemove.findAll{e -> compositeChildren.contains(e)}
54+
55+ if (params.sizeLimit) {
56+ def sizeRestrictionRemovals = compositeChildren.size() + toAdd.size() - toRemove.size() - Integer.parseInt(params.sizeLimit)
57+ if (sizeRestrictionRemovals > 0) {
58+ toRemove += compositeChildren.subList(0, sizeRestrictionRemovals)
59+ }
60+ }
61+ echo "Children added: ${toAdd}"
62+ echo "Children removed: ${toRemove}"
63+ if (compositeChildren.size() + toAdd.size() - toRemove.size() == 0) {
64+ error('All children are removed and composite repository becomes empty.')
65+ }
66+ def modifyComposite_xml = """\
67+ <?xml version="1.0" encoding="UTF-8"?>
68+ <project default="${ANT_TASK_NAME}" basedir=".">
69+ <target name="${ANT_TASK_NAME}">
70+ <p2.composite.repository>
71+ <source location="https://download.eclipse.org/${repositoryPath}" />
72+ <repository location="${OUTPUT_PATH}" />
73+ """.stripIndent()
74+ for (child in toAdd) {
75+ modifyComposite_xml += """ <add><repository location="${child}"/></add>\n"""
76+ }
77+ for (child in toRemove) {
78+ modifyComposite_xml += """ <remove><repository location="${child}"/></remove>\n"""
79+ }
80+ modifyComposite_xml+= '''\
81+ </p2.composite.repository>
82+ </target>
83+ </project>
84+ '''.stripIndent()
85+ writeFile(file: "${ANT_TASK_NAME}.xml", text: modifyComposite_xml)
86+
87+ sh '''
88+ ${ECLIPSE_EXE} -nosplash -consolelog --launcher.suppressErrors -debug -data ./eclipse-ws \
89+ -application org.eclipse.ant.core.antRunner -file "${ANT_TASK_NAME}.xml" "${ANT_TASK_NAME}"
90+ '''
91+ sshagent(['projects-storage.eclipse.org-bot-ssh']) {
92+ sh '''
93+ epDownloadsDir='/home/data/httpd/download.eclipse.org'
94+ scp -r ${OUTPUT_PATH}/* "genie.releng@projects-storage.eclipse.org:${epDownloadsDir}/${repositoryPath}"
95+ '''
96+ }
97+ }
98+ }
99+ }
100+ }
101+ post {
102+ always {
103+ archiveArtifacts allowEmptyArchive: true, artifacts: '**/*', excludes: 'tools/**/*'
104+ }
105+ }
106+ }
107+
108+ @NonCPS
109+ def parseList(String str, String delimiterPattern) {
110+ return str !=null && !str.trim().isEmpty() ? str.trim().split(delimiterPattern).collect{c -> c.trim()} : []
111+ }
112+
113+ def installLatestReleasedEclipsePlatformProduct() {
114+ sh 'curl -o buildproperties.txt https://download.eclipse.org/eclipse/relengScripts/cje-production/buildproperties.txt'
115+ def eclipseURL = sh(script: '''#!/bin/sh +xe
116+ source ./buildproperties.txt
117+ #TODO: Remove this after the next release!
118+ PREVIOUS_RELEASE_ID='S-4.37M1-202507031800'
119+ PREVIOUS_RELEASE_VER='4.37M1'
120+ echo "https://download.eclipse.org/eclipse/downloads/drops4/${PREVIOUS_RELEASE_ID}/eclipse-platform-${PREVIOUS_RELEASE_VER}-linux-gtk-x86_64.tar.gz"
121+ ''', returnStdout: true).trim()
122+ return install('eclipse-platform', eclipseURL) + '/eclipse'
123+ }
124+
125+ def install(String toolType, String url) {
126+ dir("${WORKSPACE}/tools/${toolType}") {
127+ sh "curl -L ${url} | tar -xzf -"
128+ return "${pwd()}/" + sh(script: 'ls', returnStdout: true).trim()
129+ }
130+ }
0 commit comments