Skip to content

Instantly share code, notes, and snippets.

@nikicat
Last active January 6, 2016 10:34
Show Gist options
  • Save nikicat/b03b4529cd1b1ebe3087 to your computer and use it in GitHub Desktop.
Save nikicat/b03b4529cd1b1ebe3087 to your computer and use it in GitHub Desktop.
Shell build script to handle .travis.yml inside Jenkins
#!/bin/bash -exv
function getvalue() {
shyaml get-value $1 < .travis.yml
}
function getencvalue() {
shyaml get-value $1.secure < .travis.yml | base64 -d | openssl rsautl -decrypt -inkey .jenkins.pem
}
function getvalues() {
shyaml get-values $1 < .travis.yml
}
if [ -z "$JENKINSKEY" ]; then
echo "JENKINSKEY must be set to base64-encoded RSA key in PEM format"
exit 2
fi
echo "$JENKINSKEY" | base64 -d > .jenkins.pem
DEBIAN_FRONTEND=noninteractive apt-get install -y python3-pip build-essential zlib1g-dev libxslt1-dev libxml2-dev
pip3 install shyaml
if [ "`getvalue language`" != "python" ]; then
echo "only python is currently supported"
exit 1
fi
if [ "`getvalue python.0`" != "3.4" ]; then
echo "only python3.4 is currently supported"
exit 1
fi
mkdir -p ~/.ssh
cat > ~/.ssh/config <<EOF
UserKnownHostsFile=/dev/null
StrictHostKeyChecking=no
EOF
function pip() {
pip3 $@
}
function python() {
python3 $@
}
export `getencvalue env.global`
getvalues install | while read install; do
$install
done
getvalues env.matrix | while read env; do
export $env
`getvalue script`
deploycond=`getvalue deploy.on.condition`
if eval "[ $deploycond ]"; then
getvalues before_deploy | while read cmd; do
eval "$cmd"
done
provider=`getvalue deploy.provider`
if [ "$provider" = "pypi" ]; then
cat > ~/.pypirc <<EOF
[distutils]
index-servers =
local
[local]
repository: `getvalue deploy.server`
username: `getvalue deploy.user`
password: `getencvalue deploy.password`
EOF
cat ~/.pypirc
python setup.py `getvalue deploy.distributions` upload -r local
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment