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+ repository="https://download.eclipse.org/${repositoryPath}"
23+ echo "Validate consistency of content at: ${repository}"
24+ ${ECLIPSE_EXE} -nosplash -consolelog --launcher.suppressErrors -application org.eclipse.equinox.p2.director -repository "${repository}" -list
25+ '''
26+ }
27+ }
28+ stage('Update composite repository') {
29+ environment {
30+ ANT_TASK_NAME = 'modifyComposite'
31+ OUTPUT_PATH = './output-repository'
32+ }
33+ steps {
34+ script {
35+ //TODO: test this with the empty template repository
36+ //TODO: copy this via SSH to avoid caching issues.
37+ sh "curl -o compositeArtifacts.jar https://download.eclipse.org/${repositoryPath}/compositeArtifacts.jar"
38+ def childenXPathSet = sh(script: '''#!/bin/sh +xe
39+ unzip -p compositeArtifacts.jar compositeArtifacts.xml |\
40+ xmllint - --xpath '/repository/children/child/@location'
41+ exit 0
42+ ''', returnStdout: true).trim()
43+ def compositeChildren = 'XPath set is empty' == childenXPathSet ? []
44+ : parseList(childenXPathSet, '\\s+')
45+ .collect{c -> c.startsWith('location="') && c.endsWith('"') ? c.substring(10, c.length() - 1) : null}
46+ .findAll{c -> c != null}
47+
48+ echo "Current children: ${compositeChildren}"
49+ def toAdd = parseList(params.add, ',').unique()
50+ def toRemove = parseList(params.remove, ',').unique()
51+ toRemove = toRemove.findAll{e -> compositeChildren.contains(e)}
52+
53+ if (params.sizeLimit) {
54+ def sizeRestrictionRemovals = compositeChildren.size() + toAdd.size() - toRemove.size() - Integer.parseInt(params.sizeLimit)
55+ if (sizeRestrictionRemovals > 0) {
56+ toRemove += compositeChildren.subList(0, sizeRestrictionRemovals)
57+ }
58+ }
59+ echo "Children added: ${toAdd}"
60+ echo "Children removed: ${toRemove}"
61+ if (compositeChildren.size() + toAdd.size() - toRemove.size() == 0) {
62+ error('All children are removed and composite repository becomes empty.')
63+ }
64+ def modifyComposite_xml = """\
65+ <?xml version="1.0" encoding="UTF-8"?>
66+ <project default="${ANT_TASK_NAME}" basedir=".">
67+ <target name="${ANT_TASK_NAME}">
68+ <p2.composite.repository>
69+ <source location="https://download.eclipse.org/${repositoryPath}" />
70+ <repository location="${OUTPUT_PATH}" />
71+ """.stripIndent()
72+ for (child in toAdd) {
73+ modifyComposite_xml += """ <add><repository location="${child}"/></add>\n"""
74+ }
75+ for (child in toRemove) {
76+ modifyComposite_xml += """ <remove><repository location="${child}"/></remove>\n"""
77+ }
78+ modifyComposite_xml+= '''\
79+ </p2.composite.repository>
80+ </target>
81+ </project>
82+ '''.stripIndent()
83+ writeFile(file: "${ANT_TASK_NAME}.xml", text: modifyComposite_xml)
84+
85+ sh '''
86+ ${ECLIPSE_EXE} -nosplash -consolelog --launcher.suppressErrors -debug -data ./eclipse-ws \
87+ -application org.eclipse.ant.core.antRunner -file "${ANT_TASK_NAME}.xml" "${ANT_TASK_NAME}"
88+ '''
89+ sshagent(['projects-storage.eclipse.org-bot-ssh']) {
90+ sh '''
91+ epDownloadsDir='/home/data/httpd/download.eclipse.org'
92+ echo -r "${OUTPUT_PATH}" "
[email protected] :${epDownloadsDir}/${repositoryPath}"
93+ #TODO: activate copying
94+ #scp -r "${OUTPUT_PATH}" "
[email protected] :${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='I20250630-1800'
119+ PREVIOUS_RELEASE_VER='I20250630-1800'
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