CliQr is now part of Cisco Learn More About Cisco

Jenkins Integration

Overview

For pre-modeled Jenkins projects (for example, Maven, to fetch the source code from Git/SVN), you can integrate with CloudCenter using the CloudCenter Jenkins plugin.

You do not need to manually copy this file, CloudCenter provides a download URL to make this plugin available to Jenkins users. Contact CloudCenter Support to obtain the download location.

The CloudCenter Jenkins Plugin

The CloudCenter Jenkins plugin provides complete integration between Jenkins and CloudCenter by allowing users to directly launch deployments on any Supported Cloud from a Jenkins server.  

Additionally, users can upgrade an existing deployment by specifying upgrade scripts for each tier.

Prerequisites

  • If you are new to Jenkins, setup a maven project on Jenkins with Github as its source repository. See http://www.youtube.com/watch?v=lTQGi5jzjvo for additional details.
  • The supported Jenkins versions value must be >=1.624 to use the CloudCenter Jenkins plugin.
  • The required Java version for the Jenkins server must be Java 7.
  • You must set the default cloud settings in the Deployment Environments so the Jenkins Plugin can fetch and use those cloud settings when you deploy the application.
  • The Jenkins plugin for CloudCenter 4.6.x requires the APIs associated with CloudCenter 4.6.x (for example, the Jenkins plugin uses v2 CloudCenter APIs for job deployment and the v2 APIs are only available in CloudCenter 4.6.x).

Install the CloudCenter Jenkins Plugin

To install the CloudCenter Jenkins plugin, follow this procedure:

  1. Contact CloudCenter Support to obtain the download link for the CloudCenter Jenkins plugin. 
  2. Log into CCM using your admin credentials.
  3. Generate the API Management (Access) Key for the Jenkins user.
  4. Model the Application so this user can access artifacts from the Jenkins build server.
  5. In Jenkins, go to Manage Jenkins > Manage Plugins > Advanced > Upload Plugin to upload and install the CloudCenter Jenkins Plugin.




  6. After you install theCliQrJenkinsPlugin, go to your existing/new project to configure post-build step and fetch the source code from the Git/SVN using a Maven project into the Jenkins Build.
  • Configure the CloudCenter Application Deployment Client in Jenkins for continuous integration from build system and deployment (new or upgrade on an existing node).

    The parameters for the CloudCenter Application Deployment Client page are listed in the following table:

    ParameterDescription
    Cisco CloudCenter
    CCM URL
    The the IP address of the CCM server. Verify that trusted certificates (see Certificate Authentication for additional context), are added to the CCM server (not self-signed certificates).
    UsernameUsername listed in the Manage Access Key section (see API Authentication for additional context).
    AccessKeyThe API Management Key for the user listed in the he Manage Access Key section (see API Management Key for additional context).
    Deploy to ProjectUse this flag to deploy to a project, instead of a general deployment environment (see Projects and Phases for additional context).
    Project NameIf you select the Deploy to Project flag, this parameter is displayed and the list of projects are fetched from the CCM server. Based on this parameter value, only applications associated with this project are filtered out in the Application Version field.
    Project PhaseBased on the project name, a dropdown list of all Phases in that project are displayed. Use this value in the Deployment Environment field to filter the project.
    Application Name

    From the dropdown list of applications listed in the CCM UI, select the required application to deploy.

    Icon

    After entering your credentials, be prepare to wait for some time as the Application Management APIs APIs may take a while to load.

    Application VersionBased on your application, select the application version from this dropdown list.
    Deployment EnvironmentSelect the required deployment environment to deploy your application. Be sure to verify and check all default settings like default cloud, default instance type, and so forth as CloudCenter uses these default settings for each deployment.
    Cloud Type

    Select one cloud type from this dropdown list of cloud types that are present in your deployment environment.

    Cloud AccountThe cloud account with which you deploy the application.
    Instance Type

    Select a single instance type as the default instance type.

    TagsA comma-separated list of tags associated with this job.
    AppParameters

    A comma-separated list of key-value pairs to pass as global parameters. For example:
    abcd=wow, cdef=cliqrRocks

    CloudCenter includes the $BUILD_ID, $BUILD_NUMBER, $BUILD_TAG, $JOB_NAME, and if available, $BUILD_TIMESTAMP from other plugins.

    You can add a variable in this section to fetch parameters that are shared by other jobs. For example:
    abc=${BUILD_PARENT_NUMBER} or abc=$BUILD_PARENT_NUMBER

    You also have the option to retrieve parameters from the $WORKSPACE/appParams file that contains multiple lines of key-value parameter pairs. You can then uses these parameters to pass passwords or other sensitive information without displaying them in the CCM UI.

    Choose the binaries to be CopiedIdentifies if the files must be copied to an external location
    • Copy Binaries to External Location – all your binaries will be available under /tmp/app1/latest
    • Don't copy Binaries – the binaries will not be copied to any other location
    Choose the Deployment Behavior

    You can only do this once for deployments.

    • Create a new Deployment on every Build: This option creates a brand new deployment for every build.
    • Stop Old Deployment if exists: This option creates a brand new deployment for every build and stops the older deployment if it exisits.
    • Update Existing Deployment (Create new if doesn't Exist):
      • Updates a previous deployment that was launched from the CloudCenter Jenkins plugin during a previous build for the same project.
      • If the previous deployment is still in progress (job) and is not yet in the Running state, the CloudCenter Jenkins plugin waits till the deployment is in the running state before triggering an update (see Deployment and VM States for additional context).
      • If the previous deployments ends up as an error or if that deployment is stopped or cancelled from the CCM server, the CloudCenter Jenkins plugin launches a new deployment as part of the Update process.
      • If this is the first build, the CloudCenter Jenkins plugin creates a new Deployment and from the next successful build it uses the existing deployment.
      • UpdateScripts: A comma separated list of tierName:scriptToExecute scripts that are executed in the order mentioned here. For example:
        AppCluster:/shared/app/petclinic/update.sh,Database:/shared/app/updatemysql.sh, AppCluster:/shared/app/startServer.sh
    • Wait For Deployment And Export Details: Waits for Deployment to enter the Running state and exports the Job Details to the $WORKSPACE/userenv file

The jenkinsBuildId Macro

In Update Scripts, $BUILD_ID or %jenkinsBuildId% can be passed as an argument to point the Binaries to be Copied during an update deployment.

Icon

The %jenkinsBuildId% macro is not an applications-specific macro. This CloudCenter-defined macro applies to deployments that are launched using the Jenkins plugin.

The jenkinsBuildId macro is mainly used to pass the Jenkins Build ID to the userenv of the app deployment. Any deployment triggered by the Jenkins plugin will automatically have jenkinsBuildId in the userenv and will be used to point to the right binaries in repo/storage. For example, if a web server has a previous war file path set to /shared/app/petclinic/latest/, then this war file (petclinic.war) can now use this macro to point to /shared/app/petclinic/%jenkinsBuildId%/petclinic.war.

In update deployment scenarios, the jenkinsBuildId macro changes the value that should be passed to existing deployments as userenv has old the jenkinsBuildId value during the deployment.

The folder name that CloudCenter creates in the target location will now use the jenkinsBuildId value instead of the random timestamp value.

Create a New Deployment on Every Build

This option creates a Brand new deployment on every build.

Update an Existing Deployment 

When you update an existing deployment:

  • It updates a previous deployment that is launched from the Jenkins plugin during the previous builds of the same project.
  • If the previous deployment job is still in progress and is not in the Running state, the plugin waits till it enters the running state and then triggers an update.
  • If the previous deployments ends in an error or if that deployment is stopped/cancelled from the CCM, the plugin launches a fresh deployment as part of update.
  • If it is the first build, this plugin creates a new deployment and for the next successful build it uses the existing deployment.
  • If you receive a security group error, be sure to verify if more than one system is accessing the same account.

 


  • No labels