Skip to content

Instantly share code, notes, and snippets.

@lacostej
Created May 21, 2015 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lacostej/96ba8cf0c1eb7b44b86a to your computer and use it in GitHub Desktop.
Save lacostej/96ba8cf0c1eb7b44b86a to your computer and use it in GitHub Desktop.
patches jenkins.war with a new supplied remoting.jar
# patches jenkins.war with a new supplied remoting.jar
if [ $# -ne 2 ]; then
echo "ERROR arguments missing"
echo "USAGE: $0 jenkins.war newremoting.jar"
exit -1
fi
jenkins=$1
remoting=$2
target=jenkins-new.war
echo "Patching $jenkins with $remoting"
ls -la $jenkins
cp $jenkins $target
if [ -d tmp ]; then
echo "ERROR: tmp dir exists"
exit -1
fi
if [ -d WEB-INF ]; then
echo "ERROR: WEB-INF dir exists"
exit -1
fi
mkdir -p WEB-INF/lib/
jar xvf $target WEB-INF/slave.jar
jar tf $target | grep remoting | xargs -L1 cp $remoting
mkdir tmp
cp WEB-INF/slave.jar tmp/slaveold.jar
cp $remoting tmp/remoting.jar
cd tmp
mkdir slavetmp
(cd slavetmp; jar -xf ../slaveold.jar)
(cd slavetmp; rm -r ./org/jenkinsci/remoting ./hudson/remoting)
(cd slavetmp; jar -xf ../remoting.jar)
jar -cvf slave.jar -C slavetmp .
cd ..
cp tmp/slave.jar WEB-INF/
jar uvf $target WEB-INF/
rm -r tmp WEB-INF
echo "Jenkins patched:"
ls -la $jenkins $target
jar tvf $jenkins > 1.log
jar tvf $target > 2.log
diff -u 1.log 2.log
rm 1.log 2.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment