Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 18 additions & 123 deletions JenkinsJobs/Releng/modifyP2CompositeRepository.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,152 +7,47 @@ pipeline {
buildDiscarder(logRotator(numToKeepStr:'5'))
}
agent {
label 'ubuntu-2404'
label 'basic'
}
tools {
jdk 'temurin-jdk21-latest'
}
environment {
ECLIPSE_EXE = installLatestReleasedEclipsePlatformProduct()
maven 'apache-maven-latest'
}
stages {
stage('Check Composites Validity') {
steps {
sh '''
for repo in ${add//,/ }; do
if [[ $repo != http* ]]; then
repo="https://download.eclipse.org/${repositoryPath}/${repo}"
fi
echo "Validate content consistency of: ${repo}"
${ECLIPSE_EXE} -application org.eclipse.equinox.p2.director -repository "${repo}" -list
done
'''
// The resulting composite repository is not tested as it might not exist yet.
}
}
stage('Update composite repository') {
environment {
ANT_TASK_NAME = 'modifyComposite'
OUTPUT_PATH = 'output-repository'
}
steps {
script {
def boolean sourceRepositoryExists = sh(script: "curl --fail -o compositeArtifacts.jar https://download.eclipse.org/${repositoryPath}/compositeArtifacts.jar", returnStatus: true) == 0
def compositeChildren = []
if (sourceRepositoryExists) {
def childenXPathSet = sh(script: '''#!/bin/sh +xe
unzip -p compositeArtifacts.jar compositeArtifacts.xml |\
xmllint - --xpath '/repository/children/child/@location'
exit 0
''', returnStdout: true).trim()
compositeChildren = 'XPath set is empty' == childenXPathSet ? []
: parseList(childenXPathSet, '\\s+')
.collect{c -> c.startsWith('location="') && c.endsWith('"') ? c.substring(10, c.length() - 1) : null}
.findAll{c -> c != null}
}

echo "Current children: ${compositeChildren}"
def toAdd = parseList(params.add, ',').unique()
def toRemove = parseList(params.remove, ',').unique()
toRemove = toRemove.findAll{e -> compositeChildren.contains(e)}
def repositoryName = params.repositoryName.trim()
sh """
git clone --depth=1 --filter=tree:0 --no-checkout --branch=${scm.branches[0].name} ${scm.userRemoteConfigs[0].url} repository
pushd repository
git sparse-checkout set --no-cone eclipse-platform-parent/pom.xml
git checkout
popd

if (params.sizeLimit) {
def sizeRestrictionRemovals = compositeChildren.size() + toAdd.size() - toRemove.size() - Integer.parseInt(params.sizeLimit)
if (sizeRestrictionRemovals > 0) {
toRemove += compositeChildren.subList(0, sizeRestrictionRemovals)
}
}
echo "Children added: ${toAdd}"
echo "Children removed: ${toRemove}"
if (!toRemove.isEmpty() && compositeChildren.size() + toAdd.size() - toRemove.size() == 0) {
error('All children are removed and composite repository becomes empty.')
}
def modifyComposite_xml = """\
<?xml version="1.0" encoding="UTF-8"?>
<project default="${ANT_TASK_NAME}" basedir=".">
<target name="${ANT_TASK_NAME}">
<p2.composite.repository>
<repository location="${OUTPUT_PATH}" ${repositoryName ? ('name="' + repositoryName + '"') :''}/>
""".stripIndent()
if (sourceRepositoryExists) {
modifyComposite_xml +=""" <source location="https://download.eclipse.org/${repositoryPath}" />"""
}
for (child in toAdd) {
modifyComposite_xml += """ <add><repository location="${child}"/></add>\n"""
}
for (child in toRemove) {
modifyComposite_xml += """ <remove><repository location="${child}"/></remove>\n"""
}
modifyComposite_xml+= '''\
</p2.composite.repository>
</target>
</project>
'''.stripIndent()
writeFile(file: "${ANT_TASK_NAME}.xml", text: modifyComposite_xml)

sh '''
${ECLIPSE_EXE} -debug -data ./eclipse-ws \
-application org.eclipse.ant.core.antRunner -file "${ANT_TASK_NAME}.xml" "${ANT_TASK_NAME}"
'''
//TODO: Let p2 produce p2.index file
writeFile(file: "${OUTPUT_PATH}/p2.index", text: """\
#${new Date()}
version=1
metadata.repository.factory.order=compositeContent.xml,\\!
artifact.repository.factory.order=compositeArtifacts.xml,\\!
""".stripIndent())

// The composite files are somehow not compressed if the repository is empty...
sh '''
cd "${OUTPUT_PATH}"
if [[ -f compositeArtifacts.xml ]]; then
zip compositeArtifacts.jar compositeArtifacts.xml
rm compositeArtifacts.xml
fi
if [[ -f compositeContent.xml ]]; then
zip compositeContent.jar compositeContent.xml
rm compositeContent.xml
fi
'''
mvn tycho-p2-repository:modify-composite-repository -Pp2-repository-modification \\
--file ${WORKSPACE}/repository/eclipse-platform-parent/pom.xml \\
-Dp2.repository.location=https://download.eclipse.org/${params.repositoryPath}/ \\
-Dp2.repository.output=${WORKSPACE}/${OUTPUT_PATH} \\
-Dp2.composite.children.add=${params.add} \\
-Dp2.composite.children.remove=${params.remove} \\
-Dp2.composite.children.limit=${params.sizeLimit ?: 0} \\
${params.repositoryName ? ("-Dp2.repository.name='" + params.repositoryName + "'") : ''} \\
"""
sshagent(['projects-storage.eclipse.org-bot-ssh']) {
sh '''
epDownloadsDir='/home/data/httpd/download.eclipse.org'
ssh [email protected] mkdir -p "${epDownloadsDir}/${repositoryPath}"
scp -r ${OUTPUT_PATH}/* "[email protected]:${epDownloadsDir}/${repositoryPath}"
'''
}
}
}
}
}
post {
always {
archiveArtifacts allowEmptyArchive: true, artifacts: '**/*', excludes: 'tools/**/*'
archiveArtifacts allowEmptyArchive: true, artifacts: '**/*'
}
}
}

@NonCPS
def parseList(String str, String delimiterPattern) {
return str !=null && !str.trim().isEmpty() ? str.trim().split(delimiterPattern).collect{c -> c.trim()} : []
}

def installLatestReleasedEclipsePlatformProduct() {
sh 'curl -o buildproperties.txt https://download.eclipse.org/eclipse/relengScripts/cje-production/buildproperties.txt'
def eclipseURL = sh(script: '''#!/bin/sh +xe
source ./buildproperties.txt
#TODO: Remove this after the next release!
PREVIOUS_RELEASE_ID='S-4.37M3-202508141800'
PREVIOUS_RELEASE_VER='4.37M3'
echo "https://download.eclipse.org/eclipse/downloads/drops4/${PREVIOUS_RELEASE_ID}/eclipse-platform-${PREVIOUS_RELEASE_VER}-linux-gtk-x86_64.tar.gz"
''', returnStdout: true).trim()
return install('eclipse-platform', eclipseURL) + '/eclipse -nosplash --launcher.suppressErrors -consolelog'
}

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