Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Commit

Permalink
[eclipse/xtext#1505] Add recreation of composite update sites
Browse files Browse the repository at this point in the history
In addition, this commit moves some duplicated scripts from Jenkinsfile to
external files

Signed-off-by: Nico Prediger <mail@nicoprediger.de>
  • Loading branch information
NicoPrediger committed Jul 10, 2019
1 parent a50f460 commit 5e48302
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 42 deletions.
59 changes: 17 additions & 42 deletions releng/jenkins/sign-and-deploy/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ spec:
environment {
DOWNLOAD_AREA = '/home/data/httpd/download.eclipse.org/modeling/tmf/xtext/downloads/drops'
KEYRING = credentials('252495d7-34e5-49de-8db4-bce7afae2da4')
SCRIPTS = "$WORKSPACE/releng/jenkins/sign-and-deploy/scripts"
}

stages {
Expand Down Expand Up @@ -138,31 +139,12 @@ spec:
// this has to run in the xtext-devenv container, since jnlp container does not have a 'zip' command installed
container ('xtext-buildenv') {
sh '''
# TODO move function to external shell script
# $1 path to .properties file
# $2 property name
# @return property value
get_property () {
if [ ! -f "$1" ]; then
echo "File not found: $1" >&2
return -1
fi
VALUE=$(grep "^$2" $1 |awk -F= '{print $2}')
if [ -z "$VALUE" ]; then
echo "Could not get property value" >&2
return -2
fi
echo $VALUE
}
#
# STEP 1: Get property values from publisher.properties/promote.properties
#
VERSION=$(get_property build-result/publisher.properties version)
BUILD_ID=$(get_property build-result/promote.properties build.id)
# BUILD_TYPE: N=Nightly, S=Stable, R=Release
BUILD_TYPE=$(echo $BUILD_ID |cut -c 1)
VERSION=$($SCRIPTS/get_property.sh build-result/publisher.properties version)
BUILD_ID=$($SCRIPTS/get_property.sh build-result/promote.properties build.id)
BUILD_TYPE=$($SCRIPTS/get_build_type.sh $BUILD_ID)
case "$BUILD_TYPE" in
N) ZIP_NAME=tmf-xtext-Update-$BUILD_ID.zip ;;
S|R) ZIP_NAME=tmf-xtext-Update-$VERSION.zip ;;
Expand All @@ -183,26 +165,9 @@ spec:
sshagent(['projects-storage.eclipse.org-bot-ssh']) {
container ('jnlp') {
sh '''
# TODO move function to external shell script
# $1 path to .properties file
# $2 property name
# @return property value
get_property () {
if [ ! -f "$1" ]; then
echo "File not found: $1" >&2
return -1
fi
VALUE=$(grep "^$2" $1 |awk -F= '{print $2}')
if [ -z "$VALUE" ]; then
echo "Could not get property value" >&2
return -2
fi
echo $VALUE
}
VERSION=$(get_property build-result/publisher.properties version)
BUILD_ID=$(get_property build-result/promote.properties build.id)
# BUILD_TYPE: N=Nightly, S=Stable, R=Release
BUILD_TYPE=$(echo $BUILD_ID |cut -c 1)
VERSION=$($SCRIPTS/get_property.sh build-result/publisher.properties version)
BUILD_ID=$($SCRIPTS/get_property.sh build-result/promote.properties build.id)
BUILD_TYPE=$($SCRIPTS/get_build_type.sh $BUILD_ID)
case "$BUILD_TYPE" in
N) ZIP_NAME=tmf-xtext-Update-$BUILD_ID.zip ;;
S|R) ZIP_NAME=tmf-xtext-Update-$VERSION.zip ;;
Expand Down Expand Up @@ -231,6 +196,16 @@ spec:
REPOSITORY_PATH="/home/data/httpd/download.eclipse.org/modeling/tmf/xtext/updates/releases/$VERSION"
ssh genie.xtext@projects-storage.eclipse.org "mkdir $REPOSITORY_PATH && unzip -d $REPOSITORY_PATH $TARGET_DROP_PATH/$ZIP_NAME" ;;
esac
#
# STEP 5: Recreate compositeArtifacts.xml & compositeContent.xml
#
case "$BUILD_TYPE" in
S) # Stable
ssh genie.xtext@projects-storage.eclipse.org 'cat | /bin/bash /dev/stdin' "milestones" < $SCRIPTS/create_composite_update_site.sh ;;
R) # Release
ssh genie.xtext@projects-storage.eclipse.org 'cat | /bin/bash /dev/stdin' "releases" < $SCRIPTS/create_composite_update_site.sh ;;
esac
'''
} // END container
} // END sshagent
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/sh

if [ "$1" == "milestones" ]; then
REPO_NAME="TMF Xtext Update Site (Milestones)"
elif [ "$1" == "releases" ]; then
REPO_NAME="TMF Xtext Update Site (Releases)"
else
echo "Error: Missing Repository Path!"
exit 1
fi

cd /home/data/httpd/download.eclipse.org/modeling/tmf/xtext/updates/$1

TIMESTAMP=$(date +%s000)
UPDATE_SITES=$(find . -regex '.*/content.\(xml\|jar\|xz\)' -printf "%h\n" | cut -c 3- | sort -u)
NUMBER_UPDATE_SITES=$(echo "$UPDATE_SITES" | wc -l)

CONTENTXML="<?xml version='1.0' encoding='UTF-8'?>
<?compositeMetadataRepository version='1.0.0'?>
<repository name='$REPO_NAME'
type='org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository'
version='1.0.0'>
<properties size='1'>
<property name='p2.timestamp' value='${TIMESTAMP}'/>
</properties>
<children size='${NUMBER_UPDATE_SITES}'>
$(
for site in $UPDATE_SITES
do
printf " <child location='${site}'/>\n"
done
)
</children>
</repository>
"

echo "$CONTENTXML" > ./compositeContent.xml

ARTIFACTXML="<?xml version='1.0' encoding='UTF-8'?>
<?compositeArtifactRepository version='1.0.0'?>
<repository name='${REPO_NAME}'
type='org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository'
version='1.0.0'>
<properties size='1'>
<property name='p2.timestamp' value='${TIMESTAMP}'/>
</properties>
<children size='${NUMBER_UPDATE_SITES}'>
$(
for site in $UPDATE_SITES
do
printf " <child location='${site}'/>\n"
done
)
</children>
</repository>
"

echo "$ARTIFACTXML" > ./compositeArtifacts.xml
21 changes: 21 additions & 0 deletions releng/jenkins/sign-and-deploy/scripts/get_build_type.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#/bin/bash

# Returns BUILD_TYPE based on BUILD_ID
#
# $1 BUILD_ID
#
# BUILD_TYPE N=Nightly, S=Stable, R=Release

if [ ! "$1" ]; then
echo "Error: No BUILD_ID provided" >&2
exit 1
fi

BUILD_TYPE=$(echo $1 |cut -c 1)

if [ ! "$BUILD_TYPE" == "N" ] && [ ! "$BUILD_TYPE" == "S" ] && [ ! "$BUILD_TYPE" == "R" ]; then
echo "Invalid BUILD_ID provided" >&2
exit 1
fi

echo $BUILD_TYPE
15 changes: 15 additions & 0 deletions releng/jenkins/sign-and-deploy/scripts/get_property.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#/bin/bash

# $1 path to .properties file
# $2 property name

if [ ! -f "$1" ]; then
echo "File not found: $1" >&2
exit 1
fi
VALUE=$(grep "^$2" $1 |awk -F= '{print $2}')
if [ -z "$VALUE" ]; then
echo "Could not get property value" >&2
exit 1
fi
echo $VALUE

0 comments on commit 5e48302

Please sign in to comment.