Ottomata has submitted this change and it was merged.
Change subject: Add script for jenkins to commit latest source jars to artifacts
......................................................................
Add script for jenkins to commit latest source jars to artifacts
This replaces the old download jars script
Bug: T130123
Change-Id: I231361b4a2919089200e78ad7b7e13bd3a2befdd
---
D bin/download-refinery-source-jars
A bin/update-refinery-source-jars
2 files changed, 108 insertions(+), 37 deletions(-)
Approvals:
Ottomata: Verified; Looks good to me, approved
Joal: Checked; Looks good to me, but someone else must approve
diff --git a/bin/download-refinery-source-jars
b/bin/download-refinery-source-jars
deleted file mode 100755
index eea6458..0000000
--- a/bin/download-refinery-source-jars
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash
-
-# Silly little script to assist with refinery-source .jar updates.
-# Example:
-# ./bin/download-refinery-source-jars 0.0.26
-# This will download all refinery 0.0.26 version jars from archiva,
-# symlink them in ./artifacts/, and output a git command that you
-# can run (if you wish) to add and commit jars.
-#
-
-version="${1}"
-archiva_base_uri="https://archiva.wikimedia.org/repository/releases/org/wikimedia/analytics/refinery"
-
-if [ -z "${version}" ]; then
- echo "Usage: $0 <version>"
- exit 1
-fi
-
-# TODO: make this smarter
-if [ $(basename $(pwd)) != 'refinery' ]; then
- echo "Must run from refinery repository root. (pwd is $(pwd))"
- exit 1
-fi
-
-
-for j in camus core job cassandra hive; do
- (wget
"${archiva_base_uri}/$j/refinery-$j/$version/refinery-$j-$version.jar" \
- -O
./artifacts/org/wikimedia/analytics/refinery/refinery-$j-$version.jar \
- && ln -sfv org/wikimedia/analytics/refinery/refinery-$j-$version.jar
./artifacts/refinery-$j.jar) &
-done
-
-wait
-
-echo "Done!"
-ls -l artifacts/refinery*.jar
-echo "Don't forget to git add jars and commit!"
-echo "git add ./artifacts/refinery-*.jar
./artifacts/org/wikimedia/analytics/refinery/refinery-*-$version.jar && git
commit"
diff --git a/bin/update-refinery-source-jars b/bin/update-refinery-source-jars
new file mode 100755
index 0000000..74699b5
--- /dev/null
+++ b/bin/update-refinery-source-jars
@@ -0,0 +1,108 @@
+#!/bin/bash
+
+# Script to assist with refinery-source .jar updates.
+# Will be used by jenkins to commit refinery-source jars after release.
+# Usage:
+# ./bin/update-refinery-source-jars -v <version> -u <gerrit_user> [-b
<branch> -m <mode>]
+# This will download all refinery <version> jars from archiva,
+# symlink them in ./artifacts/, and add and commit jars to git
+#
+
+#Initialize variables to default values.
+VERSION=
+BRANCH="master"
+GERRIT_USER=
+MODE="dry-run"
+
+SCRIPT_NAME=$(basename $0)
+
+function HELP {
+ echo "Usage: ${SCRIPT_NAME} -v <version> -u <gerrit_user> [-b <branch> -m
<mode>]"
+ echo "Always run this script from refinery root"
+ echo "-v -- Refinery source version for which jars are to be updated. Eg.
0.0.26. Required"
+ echo "-u -- Gerrit user making the jar update commit. Required"
+ echo "-b -- Git branch in refinery to which the jar update commit should be
pushed to. Default is master"
+ echo "-m -- Mode for sending updates to git remote. Values can be review,
push, or dry-run. Default is dry-run"
+ echo "-h -- Display help text"
+}
+
+NUMARGS=$#
+if [ $NUMARGS -eq 0 ]; then
+ HELP
+fi
+
+while getopts :v:u:b:m:h OPT; do
+ case $OPT in
+ v) #set Version
+ VERSION=$OPTARG
+ ;;
+ u) #set Gerrit User
+ GERRIT_USER=$OPTARG
+ ;;
+ b) #set branch
+ BRANCH=$OPTARG
+ ;;
+ m) #set mode
+ MODE=$OPTARG
+ ;;
+ h) #show help
+ HELP
+ exit 0
+ ;;
+ \?) #unrecognized option - show help
+ echo "Option -$OPTARG not recognized."
+ echo "See ${SCRIPT_NAME} -h for help"
+ exit 1
+ ;;
+ esac
+done
+
+if [ -z "${VERSION}" ] || [ -z "${GERRIT_USER}" ] ; then
+ echo "Missing required parameters for VERSION(-v) or GERRIT_USER(-u)"
+ echo "See ${SCRIPT_NAME} -h for help"
+ exit 1
+fi
+
+if [ "${MODE}" != "push" ] && [ "${MODE}" != "review" ] && [ "${MODE}" !=
"dry-run"]; then
+ echo "Value for mode parameter (-m) can only be push, review or dry-run"
+ echo "See ${SCRIPT_NAME} -h for help"
+ exit 1
+fi
+
+archiva_base_uri="https://archiva.wikimedia.org/repository/releases/org/wikimedia/analytics/refinery"
+
+# This list is hardcoded now. TODO: Make this configurable
+for j in camus core job cassandra hive; do
+ (wget
"${archiva_base_uri}/$j/refinery-$j/$VERSION/refinery-$j-$VERSION.jar" \
+ -O
./artifacts/org/wikimedia/analytics/refinery/refinery-$j-${VERSION}.jar \
+ && ln -sfv org/wikimedia/analytics/refinery/refinery-$j-${VERSION}.jar
./artifacts/refinery-$j.jar) &
+done
+
+wait
+
+ADD_COMMAND="git add ./artifacts/refinery-*.jar
./artifacts/org/wikimedia/analytics/refinery/refinery-*-${VERSION}.jar"
+COMMIT_COMMAND="git commit -m 'Add refinery-source jars for v${VERSION} to
artifacts'"
+
+# If this is a dry run, just print the git commands to run and exit
+if [ "${MODE}" = "dry-run" ] ; then
+ echo "Run the following commands to commit the new jars"
+ echo $ADD_COMMAND
+ echo $COMMIT_COMMAND
+ exit 0
+fi
+
+# Set up git fat and gerrit commit message hook
+git fat init
+gitdir=$(git rev-parse --git-dir)
+scp -p -P 29418 ${GERRIT_USER}@gerrit.wikimedia.org:hooks/commit-msg
${gitdir}/hooks/
+
+# Run the git add and commit commands
+eval $ADD_COMMAND
+eval $COMMIT_COMMAND
+
+# Push to the remote git branch if on push mode, else submit for gerrit review
+if [ "${MODE}" = "push" ] ; then
+ git push origin ${BRANCH}
+elif [ "${MODE}" = "review" ] ; then
+ git push origin HEAD:refs/for/${BRANCH}
+fi
--
To view, visit https://gerrit.wikimedia.org/r/290639
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I231361b4a2919089200e78ad7b7e13bd3a2befdd
Gerrit-PatchSet: 8
Gerrit-Project: analytics/refinery
Gerrit-Branch: master
Gerrit-Owner: Madhuvishy <[email protected]>
Gerrit-Reviewer: Joal <[email protected]>
Gerrit-Reviewer: Madhuvishy <[email protected]>
Gerrit-Reviewer: Ottomata <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits