Skip to content

Instantly share code, notes, and snippets.

@kohsuke

kohsuke/reincrementalify.sh Secret

Last active Sep 30, 2019
Embed
What would you like to do?
#!/bin/bash -ex
mvn io.jenkins.tools.incrementals:incrementals-maven-plugin:reincrementalify
git commit -m "mvn incrementals:reincrementalify" pom.xml */pom.xml
#!/bin/bash -ex
#
# Kohsuke's automated release script
#
set -o pipefail
date
# this is the main module
if [ -z "$1" ]; then
echo "./release.sh path/to/jenkins/ws"
exit 1
fi
ws=$(cd "$1"; pwd)
# figure out where the release scripts are
pushd "$(dirname "$0")"
bin="$PWD"
popd
umask 022 # we'll transfer files created during builds to Apache, where go=rx for directories are expected
xmlstarlet --version > /dev/null
if [ $? != 0 ]; then
echo xmlstarlet is not installed
exit -1
fi
export JAVA_HOME=/usr/local/java8
cd "$ws"
# if left-over jenkins.war for Debian build from the last time, delete it.
rm jenkins.war || true
if [ "$SKIP_MAVEN" = "" ]; then
mvn help:evaluate -Dexpression=project.version -Doutput=v
tag=jenkins-$(cat v | sed -e "s/-SNAPSHOT//g")
export MAVEN_OPTS=-XX:MaxPermSize=160m
mvn -B -Dtag=$tag -DskipTests -DpreparationGoals="-Dconcurrency=1 clean verify" release:prepare || mvn -B -Dtag=$tag -DskipTests install release:prepare || true
mvn -DskipTests install
# first time around release:perform appears to fail with some artifact missing error
mvn release:perform || ( pushd target/checkout; mvn -DskipTests install; popd; mvn release:perform )
pushd ~/ws/jenkins/packaging
rm -rf target || true
popd
$bin/reincrementalify.sh
fi
war=$PWD/target/checkout/war/target/jenkins.war
id=$(show-pom-version target/checkout/pom.xml)
tag=jenkins-$(echo $id | sed -e "s/-SNAPSHOT//g")
case $id in
*-SNAPSHOT)
echo Trying to release a SNAPSHOT
exit 1
;;
esac
# push the changes to upstream. When that fails, that's usually because someone else pushed the new master in the mean time,
# so try to merge it. if that results in conflict, then that fails
if [ "$SKIP_PUSH" = "" ]; then
git push origin master $tag || (git pull origin && git push origin master $tag)
fi
# push changes to the maven repository
# ruby $bin/deploy-plugin-pom.rb $id plugins
# update index
#pushd target/checkout
# $bin/javadocReverseIndex.groovy > .htaccess
# scp .htaccess www-data@javadoc.jenkins-ci.org:~/javadoc.jenkins-ci.org/byShortName
# rsync -az target/site/apidocs/ www-data@javadoc.jenkins-ci.org:~/javadoc.jenkins-ci.org/
#popd
# sorcerer
#pushd target/checkout
# mvn -P sorcerer sorcerer:aggregate
# rsync -az target/site/sorcerer/ www-data@hudson-labs.org:~/sorcerer.jenkins-ci.org/
#popd
# push bits
if [ "$SKIP_BIN" = "" ]; then
pushd ~/ws/jenkins/packaging
git fetch origin
git checkout origin/$(cat $ws/packaging-ref.txt)
make WAR=${war} JENKINS_URL=http://jenkins.local/ BRAND=$PWD/branding/jenkins.mk BUILDENV=$PWD/env/release.mk CREDENTIAL=~/ws/jenkins/signing-keys/kohsuke.mk publish
popd
fi
# kick off relevant Jenkins jobs
# TODO: this is no-op until UC gen runs
# have jenkins.io show this latest version
# ssh trusted.ci.jenkins.io build jenkins.io/master
# from /srv/releases/jenkins to OSOL
ssh mirrorbrain@mirrors.jenkins.io /srv/releases/sync.sh "" | sed -e 's/^/[sync.sh] /'
echo success
date
#!/bin/sh
cygwin=false;
darwin=false;
case "`uname`" in
CYGWIN*) cygwin=true ;;
esac
for i in "$@"
do
if $cygwin ; then
i="$(cygpath -w $i)"
fi
if [ -d "$i" ]; then
i="$i/pom.xml"
fi
g=$(xmlstarlet sel -N pom=http://maven.apache.org/POM/4.0.0 -t -v "/project/version|/pom:project/pom:version" "$i" | tr -d '\r')
if [ "$g" = "" ]; then
g=$(xmlstarlet sel -N pom=http://maven.apache.org/POM/4.0.0 -t -v "/project/parent/version|/pom:project/pom:parent/pom:version" "$i" | tr -d '\r')
fi
echo $g
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment