Jenkins on PaaS

  • Upload
    iliemad

  • View
    241

  • Download
    2

Embed Size (px)

Citation preview

  • 7/30/2019 Jenkins on PaaS

    1/7

    DZone, Inc. | www.dzone.com

    By Mike Keit

    G

    etting

    Started

    with

    JPA2.0

    GetMoreRefcardz!Visitrefcardz.com

    27

    CONTENTS INCLUDE:

    n Whats New in JPA 2.0n JDBC Propertiesn Access Moden Mappingsn Shared Cachen Additional API and more...

    Getting Started withJPA 2.0

    THE JENKINS EXPERTSand your favorite Java Platform as a Service

    We really know Jenkins.Led by Kohsuke Kawaguchi, the founder and lead developer of the Jenkins

    project, our Jenkins development team works closely with the community

    to advance the open source project.

    We offer:

    3Jenkins support

    3OSS plugin support

    3Free plugins

    3Jenkins enterprise plugins

    3Jenkins in the Cloud

    Sign up for Continuous

    Information the Jenkins

    newsletter

    www.cloudbees.com/jenkins-

    newsletter.cb?DZone

    http://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.cloudbees.com/jenkins-newsletter.cb?DZonehttp://www.refcardz.com/http://www.dzone.com/http://www.refcardz.com/
  • 7/30/2019 Jenkins on PaaS

    2/7

    DZone, Inc. | www.dzone.com

    GetMoreRefcardz!Vis

    itrefcardz.com

    61

    J

    e

    s

    o

    aaS

    By Marcelo Gornstein with Harpreet Sin

    ABOUT THIS REFCARD

    In this Refcard you will nd information about Jenkins, the #1 open sourceCI server, including:

    Reviewofthemostusefulplugins Bestpractices TheCLIandhowtoachievedistributedbuildingsofyourprojects Security PublishingReports IntegrationtoanEnterpriseenvironment

    Other Related Refcardz

    ABOUT JENKINS

    Jenkins is an open source CI server written in Java. It is licensed underthe MIT license terms, and it is widely adopted throughout the worldfor different languages and environments. It also has an enormouscommunity that contributes plugins.

    JENKINS OR HUDSON?

    Initially, Jenkins was called Hudson, and was developed inside SunMicrosystems ofces. When Oracle purchased Sun (and inherited thecode base), they tried to change the way the project was managed. In early2011, tensions between Oracle and the community lead to a project fork,and Jenkins was born. The main difference is that Hudson is still managedby Oracle, and Jenkins by most of the original Hudson developers(including the founder Kohsuke Kawaguchi), focused on the communitysneeds.

    JENKINS RESOURCES

    Homepage:http://jenkins-ci.org

    GitHub:https://github.com/jenkinsci/jenkins

    Twitter:@jenkinsci

    IRCChannel:chat.freenode.netat#jenkinsand#jenkins-commit(forreal-timecommitalerts).

    Mailinglists:http://jenkins-ci.org/content/mailing-lists

    JenkinsUserConferences:Areheldmultipletimesayear,seehttp://www.cloudbees.com/juc2012.cb

    GETTING JENKINS

    You can download Jenkins from the homepage:http://jenkins-ci.org/.

    RUNNING IT

    Java Webstart (from the web)A great way to start playing around with Jenkins is to use its Java WebStart version, available at http://jenkins-ci.org/jenkins.jnlp. Just click on itand youll be ready to go. Your preferences and changes will be saved tothe directory .jenkins inside your home directory. When started, you canaccess Jenkins at http://localhost:8080/.

    WAR FILE STANDALONE

    Just run it from the command line, like:

    java -jar jenkins.war

    The war will be extracted and will serve Jenkins on port 8080 by default.Some useful command line arguments:

    If you want to change the listening port/address, or tweak more startupoptions, use the --help option to show the full list of available commandline arguments.

    War File From a Web ContainerLast but not least, you can opt to move the jenkins.war le in the webappsfolder of your web container of your choice (like Tomcat or Jetty, etc.) andmanage it from there.

    For the Jetty instructions, see: https://wiki.jenkins-ci.org/display/JENKINJetty.

    CONTENTS INCLUDE:

    nWar File Standalone

    nThe CLI

    nConfiguring the Tools

    nCreating Custom Plugins

    nFile Fingerprinting

    n

    and More!

    Jenkins on PaaContinuous Integration with Jenkins for Java Proje

    Jenkins Enterprise

    by CloudBeesDelivering enterprise-level management,

    efficiency and availability

    3Professional support

    3Higher availability &decreased downtime

    3Stronger securityand access control

    3Faster builds

    3Increased developerproductivity

    3Improved use of resources

    Learn more!

    www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZone

    [email protected]

    HotTip

    HotTip

    Most o the inormation you will fnd here will apply to Hudson andJenkins as well.

    You may want to also take a look at the ollowing related recards:#87 (CI: Servers and Tools), #84 (CI: Patterns and Anti-Patterns),#145 (Continuous Delivery Patterns and AntiPatterns in theSotware Liecycle).

    Brought to you b

    HotTip

    By deault, Jenkins will store its fles in the directory confgured in

    the environment variable JENKINS_HOME.

    http://www.dzone.com/http://www.refcardz.com/http://www.refcardz.com/http://www.refcardz.com/http://www.refcardz.com/http://www.refcardz.com/http://www.refcardz.com/http://www.refcardz.com/http://www.refcardz.com/http://www.refcardz.com/http://www.refcardz.com/http://www.refcardz.com/http://www.refcardz.com/http://jenkins-ci.org/http://jenkins-ci.org/https://github.com/jenkinsci/jenkinshttps://github.com/jenkinsci/jenkinshttp://twitter.com/jenkinscihttp://jenkins-ci.org/content/mailing-listshttp://www.cloudbees.com/juc2012.cbhttp://jenkins-ci.org/http://jenkins-ci.org/http://jenkins-ci.org/jenkins.jnlphttps://wiki.jenkins-ci.org/display/JENKINS/Jettyhttps://wiki.jenkins-ci.org/display/JENKINS/Jettyhttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttp://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonemailto:[email protected]:[email protected]://www.cloudbees.com/http://www.cloudbees.com/jenkins-enterprise-by-cloudbees.cb?DZonehttps://wiki.jenkins-ci.org/display/JENKINS/Jettyhttps://wiki.jenkins-ci.org/display/JENKINS/Jettyhttp://jenkins-ci.org/jenkins.jnlphttp://jenkins-ci.org/http://www.cloudbees.com/juc2012.cbhttp://jenkins-ci.org/content/mailing-listshttp://twitter.com/jenkinscihttps://github.com/jenkinsci/jenkinshttp://jenkins-ci.org/http://www.refcardz.com/http://www.dzone.com/http://www.refcardz.com/http://www.refcardz.com/
  • 7/30/2019 Jenkins on PaaS

    3/7

    2 Jenkins on PaaS

    DZone, Inc. | www.dzone.com

    For the Tomcat instructions see: https://wiki.jenkins-ci.org/display/JENKINS/Tomcat .

    When deploying on an application server, the path to access Jenkins maychange. By default you should be able to nd it at http://localhost:8080/

    jenkins.

    Run Jenkins in the Cloud with CloudBees DEV@cloudFor folks who dont want to install software, Jenkins is available in the cloudthrough CloudBees DEV@cloud. Sign up for CloudBees, enable Jenkins, anda Jenkins master will be set up for you.

    THE CLI

    Jenkins comes with a suitable command line interface. To access it, pointyour browser to http://ip:port/cli (replace ip:port with your own JenkinsURL) and follow the instructions. You can also nd more information at thewiki: http://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLI.

    Running the CLIjava -jar jenkins-cli.jar [-s JENKINS_URL] command [options...] [arguments...]

    Using CredentialsIf your Jenkins installation required authentication, it is possible that you

    wont be able to use the CLI properly. In this case, go to http://ip:port/me/congure and congure your SSH public key.

    You can then login with the cli by using the login command. This willautomatically load your SSH public key from your home directory and use itto authenticate with Jenkins.

    CONFIGURING

    With the GUIClicking on the Manage Jenkins option in the main menu will take you tothe Manage System screen. There you can tweak the system settings,read system information, logs, and statistics, and manage the plugins. TheCongure System option takes you to the full system options.

    Without using the GUIJenkins stores its conguration (and the jobs information) in plain lesinside the directory specied by JENKINS_HOME. If you happen to modifythese les manually and want the settings to take effect, click the ReloadConguration from Disk icon.

    CONFIGURING THE TOOLS (JDK/ANT/MAVEN)

    By default, Jenkins comes with support for Java projects without anyadditional plugins. So lets congure our Java tools (JDK, Apache Ant andMaven). Click on the Manage Jenkins -> Congure System option. Thetools have to be already installed in the same host where you are runningJenkins. For every tool, you can congure:

    Name:SinceyoucancongureanynumberofJDK/Maven/Antinstallations,youhavetogiveeachoneofthoseadistinctivename,

    soyoucanlaterassignaspecictooltoaspecicbuild.

    Home:Theinstallationpath.

    Automatically Installing JDK, Maven, Ant.If you dont have JDK and Apache Ant/Maven, you can make Jenkins installit automatically. Whenever you see the option Install automatically, youcan check it to tell Jenkins to download and install that tool automaticallyas soon as a project needs it. You can also download it yourself, and tellJenkins to use the le you want by clicking Add Installer and selecting theExtract *.zip/*.tar.gz option, and then giving the full path to the le.

    UPDATING

    To check for new versions, go to the Manage System screen. If theres anew version available, you will see a notice saying so and asking you toupgrade manually or automatically, or to read the changelog. If an upgradebreaks your installation, you can also downgrade your copy to the lastworking version from this menu.

    PLUGIN MANAGEMENT

    The vibrant Jenkins community has provided (and still continues providing)plugins to extend the Jenkins features. This has lead to Jenkins beingan incredible and versatile tool to manage software projects. Inside theCongure System menu, you will nd the Manage Plugins option.

    Clicking on it will take you to Plugin Manager, where you will nd anyavailable updates for the plugins installed, a list of new (not installed)plugins, and a list of the already installed plugins.

    The advanced tab lets you congure an HTTP Proxy, the Update Site(Jenkins connects to this URL to get updates and plugins). You canalso upload a custom plugin, packaged as a .jpi le. Jenkins plugins aredistributed in jpi les (hpi les are also supported), which are common jarles, with a custom tree layout. You can read more about Jenkins pluginshere: http://wiki.jenkins-ci.org/display/HUDSON/Plugin+structure

    For versions prior to 1.442, once you have installed new plugins, youneed to restart Jenkins for the changes to take effect. You can do this bychecking the Restart Jenkins when installation is complete and no jobs arerunning checkbox.

    CREATING CUSTOM PLUGINS

    Creating your own plugin is easy and powerful. You might want to createyour own plugins to integrate Jenkins with a specic tool, to add or modifybuild steps behavior, add reporting, change the GUI, add CLI commands,etc.

    For this, Jenkins provides Extension points. You can nd more about themhere: https://wiki.jenkins-ci.org/display/JENKINS/Extension+points

    A complete tutorial can be found at:https://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorial

    USEFUL PLUGINS

    Heres a list of the most used plugins. You might want to install someof these right away for your projects: http://wiki.cloudbees.com/bin/download/Jenkins+Enterprise/WebHome/CertiedPlugins.pdf. This listingtakes in a number of factors to score these plugins, including popularityand active contributions to the codebase.

    CHANGING THE LANGUAGE

    HotTip

    By deault, Jenkins will show up in the language o your browser. Iyou want a dierence language, change your browsers language.I, on the other hand, you want to show Jenkins always in the givenlanguage, use the Locale plugin (available through the PluginManager). When installed, you will fnd an extra option at theJenkins Management options, Locale -> Deault Language whereyou can defne the deault language and even instruct Jenkins tooverride the browsers language.

    http://www.dzone.com/https://wiki.jenkins-ci.org/display/JENKINS/Tomcathttps://wiki.jenkins-ci.org/display/JENKINS/Tomcathttps://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLIhttps://wiki.jenkins-ci.org/display/JENKINS/Plugin+structurehttps://wiki.jenkins-ci.org/display/JENKINS/Extension+pointshttps://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorialhttps://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorialhttps://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorialhttp://wiki.cloudbees.com/bin/download/Jenkins+Enterprise/WebHome/CertifiedPlugins.pdfhttp://wiki.cloudbees.com/bin/download/Jenkins+Enterprise/WebHome/CertifiedPlugins.pdfhttp://www.cloudbees.com/http://wiki.cloudbees.com/bin/download/Jenkins+Enterprise/WebHome/CertifiedPlugins.pdfhttp://wiki.cloudbees.com/bin/download/Jenkins+Enterprise/WebHome/CertifiedPlugins.pdfhttps://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorialhttps://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorialhttps://wiki.jenkins-ci.org/display/JENKINS/Extension+pointshttps://wiki.jenkins-ci.org/display/JENKINS/Plugin+structurehttps://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLIhttps://wiki.jenkins-ci.org/display/JENKINS/Tomcathttps://wiki.jenkins-ci.org/display/JENKINS/Tomcathttp://www.dzone.com/http://www.refcardz.com/http://www.refcardz.com/
  • 7/30/2019 Jenkins on PaaS

    4/7

    3 Jenkins on PaaS

    DZone, Inc. | www.dzone.com

    SMTP CONFIGURATION FOR E-MAIL

    NOTIFICATIONS

    Advanced Email NotificationsA useful plugin is Email-ext, which allows a ner-grainedcontrol over howand when emails are sent. Install this plugin from the Plugin Manager.

    This plugin adds a few more hooks that can be used to send e-mailnotications, such as when a build is about to be done, continues to fail, orbecomes unstable. You can also customize the emails you can chooseto send them to different people based on a specic list, or you can sendthem because they made the comments. You can also include the buildoutput.

    CONFIGURING A SOURCE VERSION CONTROL

    SYSTEM

    CVS and SubversionJenkins comes out of the box with support for CVS and SVN. For CVS,select the CVS option in the Job conguration.

    GitTo use GIT with Jenkins, you will need to install the GIT plugin from thePlugin Manager.

    TRIGGERING BUILDS

    ManuallyBuilds can be manually triggered by clicking the Play (Build Now) icon atthe left sidebar when inside a job. To congure when a build should be donefor a job, use the Build Triggers conguration.

    Scheduling a BuildYou can congure your job to be automatically built when a dependency isbuilt or when a specic job has been built. Also, the Build Periodically andPoll SCM options let you setup a crontab-like schedule, either to build the

    job or to poll the SCM for changes and trigger a build when changes arefound. The schedule consists of 5 columns: Minute, Hour, Day of month,Month, Day of the week. The complete format is available by clicking thehelp icon for this option.

    Another powerful option is Post-commit hooks for running builds. A buildgets triggered on a commit into the repository. This is more efcient thanperiodic builds or the poll SCM option.

    Establishing an Upstream-Downstream Relationship

    PUBLISHING REPORTS

    To publish the reports for your code metrics, see the Build Settings sectionof your job conguration. Some plugins will add a Post-build action, like theStatus Analysis Collector, so you might want to check those actions to ndnew publishing options.

    Thresholds On MetricsIn general, plugins that report on code metrics can be congured to setthresholds on those values in order to make a build stable, unstable, orfailed. You can congure these thresholds by clicking the Advanced button.

    PARAMETERIZED BUILDS

    To add a parameter, just click the Add Parameter button, and select fromthe dropdown menu the type of parameter you would like to use. When thebuild is triggered, Jenkins will ask for the values required.

    Accessing the Parameter ValuesOnce dened, you can access the parameters just as any otherenvironment variable. For example, from the shell (or when conguring your

    job build):

    echo ${VERSION} > version.txt

    Accessing variables from Ant

    Accessing variables from Maven

    ${VERSION}

    ..

    Triggering Other Builds with the Same ParametersSometimes it is useful to trigger the build of another job from aparameterized build, passing on the parameters used. In this case, use the

    Parameterized Trigger plugin.

    Once installed, you will nd a new option in your job conguration page:The Triggering parameterized builds on other projects option. On newerversions, you can access it from the Post Build Actions section of your jobconguration.

    Remember that the job should be parameterized as well. You can also mixother parameters or read them from a properties le.

    BUILD PROMOTION

    In order to promote the build, you can opt for a number of available criteria:

    Manual Buildcompleted Builtoneormoredownstreamprojects Oneormoreupstreamprojectsgetpromoted

    With a promoting condition congured, you can add actions to beperformed when the actual promotion occurs, by clicking the Add actiondropdown box.

    HotTip

    Jenkins can send e-mail alerts when a build breaks or goes backto normal. In order to do so, it needs to know the SMTP inormation,which you can confgure in the Manage System section. Then, inyour job confguration, check the Email notifcation option.

    HotTip

    You can build a project as soon as another project is built. Thisis useul when project B (downstream) depends on project A(upstream) and you want to make sure you build a new B versionor each new build o A. Check-mark the Build ater other projects arebuilt option. You can speciy more than one project by separatingthem with a comma.

    HotTip

    This is a very useul eature that will let you enter some parametervalues into the job either manually or by taking them rom otherjobs. In your job confguration, select This build is parameterized(i you dont see this option, try looking or the Parameterized Buildplugin in the Plugin Manager).

    Hot

    Tip

    Promotions are a great tool to add steps in the build process andalso mark builds according to a number o things. Promotionsare available through the Promoted Builds plugin. When installed,

    you will fnd a new option called Promote builds when in your jobconfguration.

    http://www.dzone.com/http://www.cloudbees.com/http://www.dzone.com/http://www.refcardz.com/http://www.refcardz.com/
  • 7/30/2019 Jenkins on PaaS

    5/7

    4 Jenkins on PaaS

    DZone, Inc. | www.dzone.com

    Promoting BuildsTo promote a build, click the Promotion Status link (either at the leftnavigation bar, or at the build page). The met and unmet qualications willappear from here, and you can do manual promotions. Promotions canalso be manually forced. Look for the Force Promotion button on the rightside of the page.

    USING THE MAVEN RELEASE PLUGIN

    You can have Jenkins execute the Maven Release Plugin and deploy to amaven repository by installing the M2 Release plugin. When installed, youwill notice a new option, too, in the left navigation bar. To make a release,click the Perform Maven Release link, and the release conguration will beshown.

    Configuring credentialsAt the Jenkins conguration page, you will nd a new optionallowing you tocongure your repository information and your credentials that will be usedby the M2 Release plugin to make the releases.

    MANAGING BUILD VERSION NUMBER

    By default, Jenkins increments the build version by 1. If you want to havea more custom version number (or string) for your job, use the VersionNumber plugin. When installed, a new version will show up in your jobconguration at the Build Environment section named Create a formattedversion number.

    This allows you to create an arbitrary version number string and set anenvironment variable with it, suitable to be used as any other environmentvariable. You can specify a number of variables to be used in the nal string(see the examples by clicking the help icon).

    Resetting the build numberIf you wish to set the next build number to an arbitrary number (ormaybe even reset it to 1), locate your job directory, and modify the lenextBuildNumber. For example, for a job named Jenkins, the path would be:

    $JENKINS_HOME/jobs/Jenkins/nextBuildNumber

    Afterwards, restart Jenkins or reload the conguration from disk from theManagement menu.

    CLAIMING A BROKEN BUILD

    From time to time, someone breaks the build. Its inevitable. When thishappens, someone needs to look into the build log and x the error. Jenkinshas a nice plugin for this exact situation. The Claim plugin, available fromthe Plugin Manager, hen installed, will add a new Post Build Action that youcan use in your job conguration.

    Claiming a broken build serves two purposes: one is to explain whathappened, and the other one is to take responsibility to x it, and then tolet others know about it. When you claim a build, the other developers willnotice it and they will expect you to x the build, so they will carry on withother tasks.

    When the plugin is enabled, and when your build breaks, it will show a newoption in the build menu.

    Clicking on the Claim link will display the text area where you can write yourexcuses about how the build was broken.

    FILE FINGERPRINTING

    File Fingerprinting will let you create an MD5 sum for all archived artifacts.Jenkins will automatically save into its db the ngerprint of all thegenerated artifacts.

    This is also useful for Jenkins so it can link downstream build jobs toupstream ones. To have Jenkins save the ngerprint of the generatedartifacts, look for the Record ngerprints of les to track usage optionsinside the Post build Actions.

    SECURING JENKINS

    Authentication Delegatetoservletcontainer:IfyouarerunningJenkinson

    Glasssh,Tomcat,oranotherservletcontainer,youhavetheoptiontoletitmanageyourusersauthenticationforyou.

    Jenkinsownuserdatabase:ThemostsimplewaytoauthenticateusersistoletJenkinshandleallthework.Userscanregisterthemselves(ifyouchecktheAllowuserstosignupcheckbox)andthenyoucandecidewhocandowhat.SometimesyouwillnoticeusersthatcantlogintoJenkinsbutstillshowupinthePeoplemenu.Thesearedisabledaccounts.Youcansetupapasswordforthembyclickingonthecongureoptiononceintheusercongurationscreen.NOTE:ItisrecommendedtousetheLDAPorActiveDirectorypluginstoconnectintotheenterpriseuserdatabaseoverthisoptioninanenterpriseenvironment.

    LDAP:LotsofcompaniesuseLDAPasanauthenticationbackend,mostlybecauseActiveDirectorycanalsouseit.Ifyouchoosethisoption,somemoredatawillbedisplayed,whereyouwillneedtoentertheLDAPserverinformationandDNinformation.

    Unixuser/groupdatabase:ThelastoptionwillletyouauthenticateyourusersagainstaPAMserviceinyourunixbox.Thishasadownside:youwillneedtocreatetheaccountsonyourunixmachinejusttolettheuserslogintoJenkins.

    AuthorizationOnce you authenticate your users, you need to authorize them to dowhatever they need to do. Right below the authentication options, you willnd the authorization settings.

    Anyonecandoanything:Thisisenoughformostinstallationswhereyoutrustyourusers.

    MatrixBased:Ifyouwanttonetunewhatuserscando,thisisthewaytodoit.First,setupanonymousandadministratorpermissions:

    The Anonymous user represents the users not logged in. You should createthe admin user with User/group to add. It represents your administratoruser, and should have access to do everything.

    Hot

    Tip

    Jenkins comes out o the box without any kind o security. This isOK or intranet installations, but on public projects you would wantto control who can edit your jobs confguration and/or trigger builds,

    etc. In the Jenkins confguration page, look or the Enable Securitycheckbox. Activating it will show more options.

    HotTip

    Dont Deploy Directly rom Promotions It might be tempting to makedeployments as actions or promotions, or example, by copyingartiacts. This is not recommended, because you should never trust

    the workspace content ater a build is done. Instead, make Jenkinsarchive the needed artiacts (and fngerprint them) and use aseparate job to make the deploy that will run when the promotionoccurs. In this way, you are relying on Jenkins to choose the correctfles to include in the build.

    HotTip

    HotTip

    HotTip

    You could also use the plugin Next Build Number to change thenext version number that Jenkins will use or a given job.

    Sometimes you will notice users that cant login to Jenkins but stillshow up in the People menu, these are disabled accounts. You canset up a password or them by clicking on the confgure option oncein the user confguration screen.

    At the let navigation bar, you will notice the option Check FileFingerprint, where you can give Jenkins a fle and ask it to returnthe corresponding job and version that generated it.

    http://www.dzone.com/http://www.cloudbees.com/http://www.dzone.com/http://www.refcardz.com/http://www.refcardz.com/http://www.refcardz.com/
  • 7/30/2019 Jenkins on PaaS

    6/7

    5 Jenkins on PaaS

    DZone, Inc. | www.dzone.com

    Project-Based Matrix configurationIt might be desirable to give permissions based on the project. In thiscase, select the Project-based Matrix Authorization Strategy. You can thendene the generic permissions that will be overriden with the permissionsyou dene in the job conguration page, where you will nd a new option:Enable project-based security. This will show a new matrix that will overridewhatever you have congured in the Jenkins conguration page.

    Lost your password?

    CloudBees Roles-Based Access Control PluginThis is the most sophisticated (and simple) plugin for authorization. Itallows users to set up roles, assign groups to roles and assign users to thegroups (Roles -> (Groups*) -> (Users*).

    RBAC can use external groups (such as through LDAP) or it can let adminscreate custom groups for Jenkins (admins do not need to go to an ITadministrator to set up groups).

    A matrix of checkboxes can be used to grant permissions for specic rolesto jobs or folders. Permissions can be additive or subtractive on the folderor jobs within those folders.

    DISTRIBUTED BUILDS

    If you have lots of jobs in your Jenkins installation, you might want todistribute the work it takes to build them.

    Use the cloud

    Delivery of software products is spiky by nature. Commits and buildactivities peak during the release phase of the product. Thus, more slavescan be kicked off during peak usage. Teams can also use the Amazon EC2plugin to offload their builds into the Amazon IaaS. With this setup, teamsare responsible for management of masters and slaves in the cloud.

    Creating a NodeClick on the Manage Nodes option of the conguration page. You willnotice the New Node option on the left sidebar. Click on it to create a newnode, and enter the information for the new node, mainly the name. Next,congure the node settings:

    #ofExecutors:Howmanyjobscanbebuiltonthisnodeatthesametime.

    RemoveFSroot:WheretheJenkinsleswillbestoredintheremotenode,analogoustoJENKINS_HOME.

    Labels:Customlabelsthatyouwanttoassigntothisnodeandothers,tocreategroupsofnodessuitabletobuildsomespecicjobs.

    Usage:Youcansetthisnodetobuildanyjobsoronlytheonesspecicallytiedtoit.

    Launching the Slave agent via SSHJenkins has an embedded SSH client, which is very useful (in this particularcase) to make it connect to the target machine, by providing the connectioninformation and credentials, and run the slave agent automatically.

    Select the Launch slave agents on Unix machines via SSH option, and ll inthe required information.

    The node should then start right away as soon as you save the nodeconguration.

    Launching the Slave agent via Java Web StartAnother option is to run the slave agent manually, via Java Web Start.Select the Launch slave agents via the Java Web Start option. Then log into the target machine, and use this command line:

    javaws http://ip:port/computer/nodename/slave-agent.jnlpReplace ip:port with the location of the master Jenkins node, and replacenodename with the name of the node youve created (in this case, forexample, it would be My new Node with spaces and without the quotes).

    Launching the Slave agent headlesslyYou can also run the slave agent without a GUI, suitable to make itautomatically run at system startup, by downloading:http://ip:port/jnlpJars/slave.jar

    and then running:

    java -jar slave.jar -jnlpUrl

    http://ip:port/computer/nodename/slave-agent.jnlp

    Configuring environment variablesYou can set any environment variables needed in the slave node by settingthe node properties, these will help you customize the build and maybedynamically generate les or reports.

    Configuring the slave node Java toolsIf the path for Maven, Ant, and the JDK is different from the ones in themaster node, you can set these in the Tool Locations section.Once the node is congured and connected, you should see the new nodeQueue Status right below the main build queue.

    Restricting where jobs are builtYou can set (restrict) where a job can be built right in your job congurationby choosing the Restrict where this project can be run. A label expressionthat allows boolean operators can be set, describing which nodes canhandle this job. To see the complete list of available boolean operators,click the help icon at the right.

    ENVIRONMENT VARIABLES

    Note that plugins can add their own variables, so you might want tocheck the documentation for each one of them if you are interested. Anofcial list can be found at: https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project

    Accessing variables from Ant

    Accessing variables from Maven

    ${JOB_URL}

    BEST PRACTICES WITH JENKINS: USING

    ENTERPRISE PLUGINS

    You can nd an ofcial list of best practices at: https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Best+PracticesSecure Jenkins

    HotTip

    HotTip

    I you happen to lose your password and need to reset it, thereis a solution. Open the fle confg.xml inside the Jenkins homedirectory (specifed by JENKINS_HOME), and edit it, changinguseSecurityrom true, to alse. Then restart Jenkins. You should beable to confgure it without logging in. Change your password (and/or security settings) as quick as possible and restart.

    Jenkins nodes can be arranged in a master/slave ashion, where themaster can delegate some builds to the slave nodes, allowing you toscale in the number o jobs confgured in a given installation.

    HotTip

    A more advanced option is to use CloudBees DEV@cloud service andlet CloudBees manage Jenkins masters and slaves, so teams canjust ocus on development.

    HotTip

    Jenkins has a number o environment variables very useul tocustomize the generated build and output build inormation. You canuse these directly rom your own job and reporting tools.

    http://www.dzone.com/https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+projecthttps://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+projecthttps://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Best+Practiceshttps://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Best+Practiceshttp://www.cloudbees.com/https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Best+Practiceshttps://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Best+Practiceshttps://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+projecthttps://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+projecthttp://www.dzone.com/http://www.refcardz.com/http://www.refcardz.com/
  • 7/30/2019 Jenkins on PaaS

    7/7

    Browse our collection of over 150 Free Cheat SheUpcoming Refcardz

    Free PDF

    6 Jenkins on PaaS

    DZone, Inc.

    150 Preston Executive Dr.

    Suite 201

    Cary, NC 27513

    888.678.0399

    919.678.0300

    Refcardz Feedback Welcome

    [email protected]

    Sponsorship Opportunities

    [email protected]

    Copyright 2012 DZone, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval

    system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without priorwritten permission of the publisher. Version 1

    DZone communities deliver over 6 million pages each month to

    more than 3.3 million software developers, architects and decision

    makers. DZone offers something for everyone, including news,

    tutorials, cheat sheets, blogs, feature articles, source code and more.

    "DZone is a developer's dream", says PC Magazine.

    Securing JenkinsSecuring Jenkins starts with the assessment of who should accessthe Jenkins master. The second step is to choose the right underlyingauthentication mechanism (discussed earlier).

    Last, is to secure the right roles, groups and users. This usually involvessettling on a flexible administration topology where secure projects aresecure, can be spun off easily and can administer themselves without toomuch intervention from a uber-administrator.

    Backup JenkinsBacking up and restoring is as easy as to copy to/from the directoryspecied in JENKINS_HOME

    With the CloudBees Backup plugin, creating a backup is as simple ascreating a new job in Jenkins. Backups can be local or to a sftp server.

    Organize JobsUse the CloudBees folder to organize jobs into folders. The plugin allowsyou to create nested hierarchies of namespace aware jobs. Tie this withCloudBees RBAC plugin and you can set sophisticated permissions onfolders. .

    Capture best practices with the CloudBeesTemplates pluginA signicant part of a Jenkins administrators time is spent onboarding

    projects. Most jobs differ by small number of parameters that ideallyshould be templatized. These templates capture sameness of jobsacross projects and can be used to easily on-board new projects, jobs.Furthermore, a change in a template is automatically and instantlypropagated into all jobs.

    Shield repository from failures: Makebuilds unbreakableThe validated merges (works with Git) or the unbreakable builds featureallows only good commits to make through to the repository. Commits aremade to an intermediate repository maintained by Jenkins, who takes theonus of merging code with upstream branch, run tests, and do the nalpush to the main repository. The developer just res and forgets.

    Eliminate Jenkins downtimeThe High Availability feature, offered within Jenkins Enterprise by

    CloudBees, eliminates downtime due to master failures. Multiple Jenkinsmasters act as backups waiting for a primary master failure. Once a failureis detected, a backup master automatically boots up and acts as a failover.

    Ensure plugin and binary complianceTeams often end up working with different versions of plugins or binaries.This version mismatch results in subtle failures in the application that arediscovered late in the development cycle. The Custom Update Centersplugin offered by CloudBees, allows administrators to create their ownupdate centers, so they can upload plugins, specify the version of the pluginthat is available to downstream Jenkins instances, and more.

    REFERENCES

    Jenkins, the denitive guide book: http://www.dzone.com/links/free_ebook_jenkins_the_denitive_guide_continuou.html

    Jenkins with PHP Projects with Phing: http://marcelog.github.com/articles/ci_jenkins_hudson_continuous_integration_php_phing.html

    CloudBees Jenkins Enterprise User Guide: http://wiki.cloudbees.com/bin/view/Jenkins+Enterprise/Jenkins+User+Guide+and+Release+Notes

    MarceloGornstein is a software developer by heart anda self learner, with more than 15 years of experience (intotal) in different languages, ranging from Assembly toJava, C, Php, Ecmascript, Erlang, and Ruby. Hes the authorof different open source software projects (mostly related

    to VoIP) available at github and very passionate aboutbest practices, and new technologies. He has been asystem administrator, a software developer, lead developer,architect, and now a product owner. In his free time helikes to read a lot, play with his cats qwerty and dvorak,

    learn new stuff, and develop more open source software (and from time to time,write an article). You can nd more about him (his projects and articles) at hispersonal homepage:http://marcelog.github.com/

    HarpreetSingh has 12 years of experience in the softwareindustry in various roles. He came to CloudBees fromOracle where he was a Senior Product Manager in theApplication Grid group - he helped onboard GlassFishinto Oracle. He was at Sun Microsystems for 10 years in

    various roles such as Group Product Marketing Managerleading marketing efforts for Java EE 6, GlassFish 3.1 andmonetization program for GlassFish Portfolio. He was

    also the Product Manager for Hudson and launched it as a supported productwithin Suns GlassFish Portfolio. In his prior life, he was an engineer in the JavaEE RI, GlassFish teams and was the technical lead for GlassFish 2.1. He has anMS degree in Computer Science from University of Cincinnati and an MBA fromSanta Clara University. He lives in the San Francisco Bay area with his wife andtheir puppy.

    ABOUT THE AUTHORS

    Scala CollectionsJavaFX 2.0AndroidData Warehousing

    http://www.dzone.com/mailto:[email protected]:[email protected]://www.dzone.com/links/free_ebook_jenkins_the_definitive_guide_continuou.htmlhttp://www.dzone.com/links/free_ebook_jenkins_the_definitive_guide_continuou.htmlhttp://marcelog.github.com/articles/ci_jenkins_hudson_continuous_integration_php_phing.htmlhttp://marcelog.github.com/articles/ci_jenkins_hudson_continuous_integration_php_phing.htmlhttp://wiki.cloudbees.com/bin/view/Jenkins+Enterprise/Jenkins+User+Guide+and+Release+Noteshttp://wiki.cloudbees.com/bin/view/Jenkins+Enterprise/Jenkins+User+Guide+and+Release+Noteshttp://marcelog.github.com/http://marcelog.github.com/http://www.amazon.com/Jenkins-Definitive-John-Ferguson-Smart/dp/1449305350http://www.amazon.com/Jenkins-Definitive-John-Ferguson-Smart/dp/1449305350http://www.amazon.com/Jenkins-Definitive-John-Ferguson-Smart/dp/1449305350http://www.amazon.com/Jenkins-Definitive-John-Ferguson-Smart/dp/1449305350http://www.amazon.com/Jenkins-Definitive-John-Ferguson-Smart/dp/1449305350http://www.amazon.com/Jenkins-Definitive-John-Ferguson-Smart/dp/1449305350http://www.amazon.com/Jenkins-Definitive-John-Ferguson-Smart/dp/1449305350http://www.cloudbees.com/http://www.amazon.com/Jenkins-Definitive-John-Ferguson-Smart/dp/1449305350http://marcelog.github.com/http://wiki.cloudbees.com/bin/view/Jenkins+Enterprise/Jenkins+User+Guide+and+Release+Noteshttp://wiki.cloudbees.com/bin/view/Jenkins+Enterprise/Jenkins+User+Guide+and+Release+Noteshttp://marcelog.github.com/articles/ci_jenkins_hudson_continuous_integration_php_phing.htmlhttp://marcelog.github.com/articles/ci_jenkins_hudson_continuous_integration_php_phing.htmlhttp://www.dzone.com/links/free_ebook_jenkins_the_definitive_guide_continuou.htmlhttp://www.dzone.com/links/free_ebook_jenkins_the_definitive_guide_continuou.htmlmailto:[email protected]:[email protected]://www.dzone.com/http://www.dzone.com/http://www.refcardz.com/http://www.refcardz.com/