Drupal Continuous Integration With Jenkins – Deploy

Slides:



Advertisements
Similar presentations
Jump to Contents Instructor Tutorial essignments.com Paperless assignment submission system.
Advertisements

1. XP 2 * The Web is a collection of files that reside on computers, called Web servers. * Web servers are connected to each other through the Internet.
Support.ebsco.com EBSCOadmin Branding Tutorial. Welcome to the EBSCOadmin Skinning and Branding tutorial, where you will learn how to customize EBSCOhost.
Secure File Transfer Protocol (SFTP) With Secure Copy (SC) What is a Secure File Transfer Protocol with Secure Copy???
HERMES TUTORIAL version 1.0 Published 24th July 2007 This tutorial version is based on the actual deployed version of Hermes, as of the date of publication.
©2011 Quest Software, Inc. All rights reserved.. Andrei Polevoi, Tatiana Golubovich Program Management Group ActiveRoles Add-on Manager Overview.
1 NatQuery 3/05 An End-User Perspective On Using NatQuery To Extract Data From ADABAS Presented by Treehouse Software, Inc.
Lecture 10 Sharing Resources. Basics of File Sharing The core component of any server is its ability to share files. In fact, the Server service in all.
For Details Visit : or For any Help Contact the Librarian EBSCOhost 2.0.
ADABAS to RDBMS UsingNatQuery. The following session will provide a high-level overview of NatQuerys ability to automatically extract ADABAS data from.
Centre de Compétence BtoB – Internet/Intranet FileConnect Training FileConnect Welcome Agenda Summary Training Summary TrainingWebsite access Welcome Method.
1 Welcome to JCCAA Data base presentation Click box to see the DEMO 1.JCCAA Web Site 2. Member Login 3. My Acount 4. School DBA The end.
XP New Perspectives on Browser and Basics Tutorial 1 1 Browser and Basics Tutorial 1.
® Microsoft Office 2010 Browser and Basics.
Services Course Windows Live SkyDrive Participant Guide.
MySQL Installation Guide. MySQL Downloading MySQL Installer.
Tutorial EBSCOadmin User Groups support.ebsco.com.
SAM 2007 v4 The Student Experience Including SAM Projects, SAM Exams and SAM Training.
Introduction to Online Data Collection (OLDC) Community Based Abstinence Education September, 2009.
1 of 4 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2007 Microsoft Corporation.
1 of 7 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2007 Microsoft Corporation.
Browser and Basics Tutorial 1. Learn about Web browser software and Web pages The Web is a collection of files that reside on computers, called.
Administrator’s Guide
How to Establish a Blog. What is a Blog A blog is a collection of informational articles/ideas intended to update a viewer on new information associated.
SET UP COMPUTER ** PLEASE BE AWARE SCREENSHOTS MAY NOT MATCH **
Working with SharePoint Document Libraries. What are document libraries? Document libraries are collections of files that you can share with team members.
#RefreshCache CI - Daily Builds w/Jenkins – an Open Source Continuous Integration Server Nick Airdo Community Developer Advocate Central Christian Church.
Deployment Management The following screens demonstrate how to: 1. Access and view deployments 2. Create a new local deployment 3. Create and modify a.
Snippet Management The following screens demonstrate how to: 1. Access and view snippets 2. Create a local standard snippet, or a local class snippet 3.
1 of 5 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2007 Microsoft Corporation.
A detailed guide on how to set-up your printing storefront. Please Note: Storefronts are compatible with all browsers, however for optimal use of the admin.
Eucalyptus Virtual Machines Running Maven, Tomcat, and Mysql.
MCTS Guide to Microsoft Windows Server 2008 Applications Infrastructure Configuration (Exam # ) Chapter Two Deploying Windows Servers.
MagicInfo Pro Server Software All control, content, and scheduling is performed within the MagicInfo Pro Server software previously installed. Before.
® IBM Software Group © 2009 IBM Corporation Rational Publishing Engine RQM Multi Level Report Tutorial David Rennie, IBM Rational Services A/NZ
| | Tel: | | Computer Training & Personal Development Microsoft Office PowerPoint 2007 Expert.
XP New Perspectives on Browser and Basics Tutorial 1 1 Browser and Basics Tutorial 1.
Introduction Purpose This course describes the process of installing the KPIT GNU toolchain on your PC. Objective Learn how easy it is to get information.
MAE Continuous Integration Administration guide July 8th, 2013.
VistA Imaging Capture via Scanning. October VistA Imaging Capture via Scanning The information in this documentation includes only new and updated.
Security Planning and Administrative Delegation Lesson 6.
Overview of the Automated Build & Deployment Process Johnita Beasley Tuesday, April 29, 2008.
L.T.E :: Learning Through Experimenting Using google-svn for MtM Docs Development Denis Thibault Version 3.2 Mar 12 th, 2009.
SQL SERVER 2008 Installation Guide A Step by Step Guide Prepared by Hassan Tariq.
ALSMS Upgrade Configuration Example Alcatel-Lucent Security Products Configuration Example Series.
3M Partners and Suppliers Click to edit Master title style USER GUIDE Supplier eInvoicing USER GUIDE The 3M beX environment: Day-to-day use.
Business Objects XIr2 Windows NT Authentication Single Sign-on 18 August 2006.
NX Documentation Using Windows IIS (Internet Information Services) as a http server for NX documentation.
CACI Proprietary Information | Date 1 PD² v4.2 Increment 2 SR13 and FPDS Engine v3.5 Database Upgrade Name: Semarria Rosemond Title: Systems Analyst, Lead.
Joomla Awdhesh Kumar Singsys Pte Ltd. What is Joomla? Joomla is an award-winning content management system (CMS), which enables you to build Web sites.
Git A distributed version control system Powerpoint credited to University of PA And modified by Pepper 28-Jun-16.
© 2013 IBM Corporation IBM UrbanCode Deploy v6.0 Support Enablement Training Jenkins plug-in 1 November 2013.
How to use Drupal Awdhesh Kumar (Team Leader) Presentation Topic.
CACI Proprietary Information | Date 1 Upgrading to webMethods Product Suite Name: Semarria Rosemond Title: Systems Analyst, Lead Date: December 8,
Installing RMS 3.0 Contractor Mode
Installation The Intercompany Integration Solution for SAP Business One Version 2.0 for SAP Business One 9.1 Welcome to the course on the installation.
Development Environment
SECTION 1: Add-ons to PowerPoint
WikID installation/training
Configuring ALSMS Remote Navigation
Gadgets and Dashboards
Installation The Intercompany Integration Solution for SAP Business One Version 2.0 for SAP Business One 9.1 Welcome to the course on the installation.
Cloud Connect Seamlessly
Multi-host Internet Access Portal (MIAP) Enhancement Guide
Getting Started with Git and Bitbucket
Optimizing Efficiency + Funding
Getting Started: Amazon AWS Account Creation
JENKINS TIPS Ideas for making your life with Jenkins easier
Rational Publishing Engine RQM Multi Level Report Tutorial
Administrator’s Manual
Presentation transcript:

Drupal Continuous Integration With Jenkins – Deploy Classic Graphics – Charlotte, NC By: John W Smith License: Creative Commons CC0

Description / Purpose In the following slides, we will be describing simple Jenkins jobs that can be used to automate the deployment your git repository based code (not specific to Drupal, although that is our purpose) to your Demo, Live, Staging and/or Testing environments. First, we will configure a Jenkins job that has the simple task of deploying code to a single server / environment. Although this is not optimal, as it requires a separate Jenkins job for each site / server / environment, it is simple to setup and requires only basic scripting. Second, we will introduce a couple of scripts that will allow deploying multiple repositories to their corresponding servers based on parameters passed to the Jenkins job. This goes back to our original recommendation to name your repositories, servers, Jenkins jobs, etc using a common simple format. We assume you have already followed the previously released document “Drupal Continuous Integration with Jenkins” describing the Basic install, setup and configuration of Jenkins for Drupal Continuous Integration.

Disclaimer This document does NOT go into the complexities of securing your system from internal or external attackers, please ensure your system is secure whether or not it is accessible from the internet. Also, please consult with your organizations security and system administrators before making any changes to existing systems configuration or authentication models, and before introducing new systems into the development and / or production server environments.

System Requirements Java JDK/JRE 1.x MySQL 5.x PHP 5.x 2GHz+ Multi-Core CPU 4GB+ RAM 250GB or more depending on the number of concurrent builds, and build history, artifacts, etc that you will keeping around for review. Software needed: Jenkins 1.xxx (I used 1.433.x) Java JDK/JRE 1.x MySQL 5.x PHP 5.x Drush (latest version) Drupal 6.x Core SimpleTest patch file (included with SimpleTest Drupal Module)

References Points of Contact The Points of Contact (POC) for this documentation are: Technical Lead: David Norman (davidn@knowclassic.com) Project Lead: John Smith (johns@knowclassic.com) or (JSmith@i1Technologies.com)

Welcome! Jenkins is here to help. Specifically, Jenkins is an "extensible continuous integration (CI) server". From a 10,000ft view, Jenkins is a tool for offloading the deployment and automated testing of a software application. You write your code, push it into version control, and Jenkins will take over the task of grabbing that code, running an installation / deployment process, testing the application (if you provide it with a test environment), and reporting back to you those test results. ~ (http://thinkshout.com/blog/2010/09/sean/beginners-guide-using-hudson-continuous-integration-drupal) There are a number of different CI tools out there, but we (Classic Graphics) have chosen Jenkins, as it seems to be the leader in the Drupal world. Jenkins, for us, provides a web-based user interface, easy integration via LDAP to our Windows AD Domain, a friendly way to run scripts, integration with CVS / Subversion / Git repositories, and of course it works seamlessly with multiple projects / builds simultaneously. Also, as an added bonus, Jenkins has a Debian repository that we can use to install it on our Ubuntu servers without worrying about clobbering other libraries and avoid any dependency nightmares.

Create a Server Specific Deployment Job Here, we will be creating a simple server specific deployment job for our Drupal environment, this job could then be used as the base for other deployment sites / servers. Since every shops environment, testing and verification requirements will differ, we leave the advanced deployment scripting to the user of this document. The Jenkins job setup in this tutorial makes a few assumptions: You have setup pub-key based auth over ssh to your git repository and possibly the destination web servers, depending on your configuration this type of setup may or may not work for you. You have Drupal core, all required modules, and all custom modules located within your git repository. However, the script could be easily modified to retrieve the latest released version of Drupal and any other required modules using Drush if this is not the case in your organization. Access to deployment account private and public keys (if required) and / or the accounts password. Deployment account MUST have SSH access to the destination web server(s) AND write permission to each sites “DocumentRoot” directory. Obviously this type of setup has security implications, please consult with your systems security officer / administrator.

First, open up your favorite browser and point it to the Jenkins server (http://jenkins.ourdomain.com:8080). Click the “log in” link in the upper right-hand corner of the browser window. Enter your login credentials and click “log in”.

For this job, we will need an additional plugin installed and enabled For this job, we will need an additional plugin installed and enabled. Click the “Manage Jenkins” link on the left. Click the “Manage Plugins” link. Scroll down to find the “SSH Plugin”, click the check box to enable it. Scroll to the bottom of the page and click “Install without restart”. Click the “Return to Dashboard” link in the left menu to return to the Jenkins Dashboard once the plugin has been installed.

Click the “Manage Jenkins” link in the menu. Click the “Configure System” link. Scroll down to the SSH section, and add the appropriate information for your destination server. We have the SSH Server advanced view shown in this screen shot which allows entry of server login / password information for the SSH account to be used. Add as many entries as needed. You will need one for each server you plan to use as a destination. Click “Save” when done.

Click the “New Job” link in the menu Click the “New Job” link in the menu. Enter “Deployment Test” and select “Build a free-style software project”. Click “Ok” when done. NOTE: When creating these jobs, in order to simplify the creation of the “git” post-receive bash script to launch a build remotely, you should consider naming your jobs the same as the name of your repository/repo-directory name. So, if you have your repos on your git server in the /var/git/reponame.git directory,then this job would be called reponame. As we progress through this tutorial, it will become apparent why this makes things easier.

Now let’s configure this simple job. Scroll down to the Build Environment and we’ll enable the “Send files or execute commands over SSH after the build runs” option. Select the server you will be deploying to from the Drop down list. Enter the following text in the “Exec Command” text area without the quotes. “git-update.sh user.account branch” where: git-update.sh – is a script defined later in this document user.account – is the user the script will use to retrieve the git repository code (should be the same account as the SSH account in a perfect world) branch – the repository branch you want to deploy with this script (most likely master in all instances except the test server environment) Enable the “Exec in pty” option. Click “Save”.

Create a Generic Deployment Job Here, we will be creating a generic deployment job for our deployment environment. Since every shops environment, testing and verification requirements will differ, we leave the advanced deployment scripting to the user of this document. The Jenkins job setup in this tutorial makes a few assumptions: You have setup pub-key based auth over ssh to your git repository and the destination web servers, depending on your configuration this type of setup may or may not work for you. Alternately, you could use an expect script to enter the login credentials for you, however this is somewhat insecure as the password would be available in the expect script. You have code (Drupal core, all required modules, and all custom modules) located within your git repository. However, the script could be easily modified to retrieve the latest released version of Drupal and any other required modules using Drush if this is not the case in your organization. Access to the deployment account private and public keys (if required) and / or the accounts password. Deployment account MUST have SSH access to the destination web server(s) AND write permission to each sites “DocumentRoot” directory. Obviously this type of setup has security implications, please consult with your systems security officer / administrator.

First, open up your favorite browser and point it to the Jenkins server (http://jenkins.ourdomain.com:8080). Click the “log in” link in the upper right-hand corner of the browser window. Enter your login credentials and click “log in”.

Click the “New Job” link in the menu Click the “New Job” link in the menu. Enter “Deployment Test” and select “Build a free-style software project”. Click “Ok” when done. NOTE: When creating these jobs, in order to simplify the creation of the “git” post-receive bash script to launch a build remotely, you should consider naming your jobs the same as the name of your repository/repo-directory name. So, if you have your repos on your git server in the /var/git/reponame.git directory,then this job would be called reponame. As we progress through this tutorial, it will become apparent why this makes things easier.

Now we need to fill in some basic configuration for our newly created Deploy-Test job as shown in the following screenshots. Enter a description for our job (not required) If you would like to setup automatic deletion of old builds, check the “Discard Old Builds” checkbox (not needed for this build, as nothing will be downloaded or created in this deployment scenario). You will probably want to leave project based security enabled, add any additional users and set permissions as required.

We will configure 3 build parameters for this build. The first parameter is “REPO” and will be used to select the git repository to deploy. The second parameter is “BRANCH” and will determine the branch of the given repository to deploy. The “BRANCH” parameter should default to master in most cases. The third parameter is “SRVENV” and will contain the server enviroment we want to deploy the git repository to (in our shop we use [test, demo, staging, and live environments] ).

Check the “Execute concurrent builds if necessary” option. No Source Code Management needed for deployment jobs. Check “Trigger Builds remotely” option, and enter a token that can be used to deploy the sites. For security reasons, only persons designated to deploy code to the production environment should be given this token. Check the “Color ANSI Console Output” option. (not required)

#!/bin/bash -x ###### ## This script is an example ONLY and should be customized for the site/modules you are working on... # This is pretty straight forward actually, and can be accomplished a couple of different ways. This # script is designed to be used inside the Jenkins environment, with a job that can deploy a repository # to a matching server environment. # # Requirements: # SSH Keys setup for the Jenkins user account # SSH authorized_keys on destination servers must contain the jenkins account pub key in the # destination servers deployment account # The generic version of git-update.sh script included with this job script. # The deployment account on each destination server needs to have SSH keys setup to allow read- # only access to the git repository server. This will enable the deployment account to retrieve the # appropriate repository and branch to deploy without the need for human interaction. # Jenkins job parameters: # REPO = GIT Repository to deploy # BRANCH = GIT Repostiry branch to deploy # SRVENV = Should be one of the following for CG's environment / configuration. Your setup may # differ. # test - test server environment # staging - staging environment for final QA # demo - demonstration server environment # live - production server environment ### Configuration Variables ### # Your deployment user account DEPLOY_ACCOUNT="deploy_user" # The base domain for all your servers in your test/production environment this could also be moved # up to the Jenkins job parameters section if you need to deploy to several different domains DOMAIN="exampledomain.com" # set the deployment server based on supplied information if [ "x"${SRVENV%live} = "x" ]; then # deploying to the live / production environment DEPLOY_SERVER="${REPO,,*}.${DOMAIN,,*}" else # deploying to an environment other than live / production DEPLOY_SERVER="${REPO,,*}-${SRVENV,,*}.${DOMAIN,,*}" fi # now we'll simply execute the git-update.sh script (installed on the deployment # destination server) with the appropriate parameters ssh ${DEPLOY_ACCOUNT}@${DEPLOY_SERVER} git-update.sh ${DEPLOY_ACCOUNT} ${BRANCH} Now we’ll add a BASH script to our job, shown to the right here. This will get you started, and can be expanded upon depending on your requirements. That’s it for Jenkins using this deployment method. Scroll down to the bottom of the job creation screen and click “Save”. We’ll now move on to the server side script that will be used with both of the above Jenkins deployment jobs.

Generic git Deployment Script #!/bin/bash script=`basename $0`; usage=$(cat <<EOF_USAGE USAGE: $script <cgnum> [branch] EOF_USAGE); if [[ $1 == '' ]]; then echo $usage >&2; exit 1; fi gitconfig=$(cat <<EOF_USAGE You need to configure your git identity and try again.\n This information is required once for identifying who is\n responsible for each tag this script creates during a deploy.\n \n Example:\n $ git config --global user.name “Git User"\n $ git config --global user.email “guser@ourdomain.com"\n Templates to copy/paste:\n git config --global user.name\n git config --global user.email\n if [ ! -e "$HOME/.git/config" ]; then echo -e $gitconfig >&2; Fi HOSTNAME=`hostname` if [ ${HOSTNAME:(-8)} == "-staging" ]; then REPO=${HOSTNAME%-staging} ENVIRON="staging“ elif [ ${HOSTNAME:(-5)} == "-test" ]; then REPO=${HOSTNAME%-test} ENVIRON="test" The following script will need to be placed on each server that will be used as a destination for one of our Jenkins deployment jobs, and should be placed within the path and accessible / executable by the deployment account.

elif [ ${HOSTNAME:(-5)} == "-demo" ]; then REPO=${HOSTNAME%-demo} ENVIRON="demo“ else REPO=${HOSTNAME} ENVIRON="live“ fi if [[ $2 == '' ]]; then BRANCH=“master” BRANCH=$2 if [ -d "/tmp/clone/" ]; then echo "Removing clone directory...“ rm -rf "/tmp/clone/“ echo "Cloning $BRANCH...“ mkdir "/tmp/clone/“ git clone -b "$BRANCH" ssh://$1@code.cgraphics.com/var/git/$REPO.git/ /tmp/clone/ cd "/tmp/clone/“ TAG=`date +%Y-%m-%d-%H-%M` HASH=`git log "$BRANCH" -n 1 --pretty=format:%h` echo "Tagging local clone...“ git tag -a -m "$BRANCH $HASH to $ENVIRON by $1" "$ENVIRON-$TAG“ echo "Pushing tag to origin...“ git push origin "$ENVIRON-$TAG“ echo "Syncing the $BRANCH clone to public_html...“ rsync -rl --exclude=private --exclude=".git" --exclude=".gitignore" /tmp/clone/ /var/www/ rm -rf /tmp/clone/ echo "Launch complete!“ echo "Template for pasting to a related issue:“ echo "Deployed $HASH with tag $ENVIRON-$TAG."

That’s it, just place this script in the path, setup one of the previous Jenkins jobs modified appropriately for your environment, and you will be on your way to automated deployment of your code via your Jenkins CI Server.

Drupal Continuous Integration with Jenkins - Deploy Enjoy, and feel free to contact us with any suggestions, corrections or mistakes we may have made or that inadvertently slipped between the cracks. John W Smith (johns@knowclassic.com) or (Jsmith@i1Technologies.com)