Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Jenkins All the Things

Jenkins All the Things

Continuous Integration, Delivery, and Deployment are now viewed as a precondition to successful software development much like version control, build tools,... But often the question remains: "How?!"
This talk gives an overview how we build and deploy all the things with Jenkins:
* Continuous Deployment of our (static) website to a webserver and schemas to Amazon S3.
* Continuous Deployment of our Java applications to the development infrastructure on AWS.
* Continuous Delivery to the production infrastructure with a manual promotion step.

Additionally, we discuss what the preconditions and common problems are as well as best practices we have come to appreciate — like how to secure your credentials.

Philipp Krenn

November 17, 2015
Tweet

More Decks by Philipp Krenn

Other Decks in Programming

Transcript

  1. Conferences Booster Bergen • CodeMotion Rome • ConFESS Vienna •

    Linuxwochen Vienna • PHP Tour Luxembourg • GeeCON Krakow • JavaDay Minsk • JEEConf Kiev • nosql matters Dublin • Dev Talks Bucharest • Devoxx Poland Krakow • distributed matters Berlin • code.talks Hamburg • JavaDay Charkiv • WebCamp Zagreb • SilverStripe Europe London • Devoxx Antwerp • Devoxx Marocco Casablanca • BSides Vienna • IT-Tage Frankfurt
  2. Execute shell find . -type f -exec sed -i '/XMLSpy/d'

    {} \; if [[ ! -d s3cmd/ ]] then wget https://github.com/s3tools/s3cmd/releases/download/v1.5.2/s3cmd-1.5.2.tar.gz tar -xzvf s3cmd-1.5.2.tar.gz mv s3cmd-1.5.2/ s3cmd/ fi virtualenv --distribute DEV DEV/bin/pip install python-dateutil source DEV/bin/activate s3cmd/s3cmd del --config=/private/<myuser>/s3cfg --verbose --recursive s3://schemas.ecosio.com/erpel-1p0/ s3cmd/s3cmd put --config=/private/<myuser>/s3cfg --verbose --recursive --acl-public external/* s3://schemas.ecosio.com/erpel-1p0/
  3. Execute shell curl -s -o use-ruby https://repository-cloudbees.forge.cloudbees.com/distributions/ci-addons/ruby/use-ruby RUBY_VERSION=1.9.3-p448 . ./use-ruby

    curl -s -o use-node https://repository-cloudbees.forge.cloudbees.com/distributions/ci-addons/node/use-node NODE_VERSION=0.11.8 . ./use-node gem install --conservative --no-ri --no-rdoc bundler middleman cd $WORKSPACE bundle install bundle exec middleman build --clean --verbose
  4. Check URL #!/bin/bash URLS=( "http://ecosio.com" "https://ecosio.com" "http://ecosio.com/de" ) echo -e

    "\x1B[0mPositive tests" for URL in "${URLS[@]}" do if curl --output /dev/null --silent --head --fail "$URL" then echo -e "\x1B[0;32mURL exists: $URL" else echo -e "\x1B[0;31mURL does not exist: $URL" STATUS=1 fi done echo -e "\x1B[0mExit code $STATUS" exit $STATUS
  5. Execute shell rm -fR $JAVA_HOME cp -Lr /opt/jdk/openjdk7.latest/ $JAVA_HOME cp

    -f /private/<myuser>/jce7/* $JAVA_HOME/jre/lib/security/ FILE=app.version rm -f "$FILE" echo ${BUILD_ID} > "$FILE" echo `git rev-parse HEAD` >> "$FILE" echo ${POM_VERSION} >> "$FILE" echo ${BUILD_NUMBER} >> "$FILE" echo "master" >> "$FILE"
  6. Blessing ! Promote the build on Jenkins $ mvn package

    -Dspring.profiles.active=development Copy the artifact to S3 Fetch it during the deployment
  7. What You Bless Is not What You Package Changed snapshot

    dependencies Always packages the latest build MissingProjectException
  8. in the cloud, no one can hear you scream —

    @sadserver, https://twitter.com/sadserver/ status/641960756678889472
  9. Execute shell cp -f ${BUILD_TAG}/target/*.zip ${BUILD_TAG}/target/ftp-latest-app.zip if [[ ! -d

    s3cmd/ ]] then wget https://github.com/s3tools/s3cmd/releases/download/v1.5.2/s3cmd-1.5.2.tar.gz tar -xzvf s3cmd-1.5.2.tar.gz mv s3cmd-1.5.2/ s3cmd/ fi virtualenv --distribute DEV DEV/bin/pip install python-dateutil source DEV/bin/activate sudo /opt/jenkins/sbin/mount-webdav https://repository-<myuser>.forge.cloudbees.com/private <myuser> s3cmd/s3cmd put --config=/private/<myuser>/s3cfg ${BUILD_TAG}/target/*.zip s3://com.ecosio.artifacts/prod/ftp/
  10. #!/bin/sh FILE=$1 FILENAME=$(basename "$FILE") DIRECTORY=$(dirname "$FILE") EXTENSION="${FILENAME##*.}" NAME="${FILENAME%.*}" if [[

    "$EXTENSION" != "aes256" ]] then echo "Encrypting $FILENAME and removing the plaintext file" openssl aes-256-cbc -e -a -in $DIRECTORY/$FILENAME -out $DIRECTORY/${FILENAME}.aes256 rm $DIRECTORY/$FILENAME else then echo "Decrypting $FILENAME" openssl aes-256-cbc -d -a -in $DIRECTORY/$FILENAME -out $DIRECTORY/$NAME fi