Table of Contents generated with DocToc
- Enable Continuous Integration on Apigee Edge
- Install Virtual Box
- Install Jenkins Vagrant Box - Optional - Jenkins on Cloudbees
- Install Jenkins Plugins - Install Plugins with install-jenkins-plugins.sh - Hide passwords and sensitive data
- Install Maven
- Create a new job
- Notifications
- Jenkins CLI
- Node.js Plugin and Grunt API Plugin
- Jenkins on EC2
- Jenkins Pull Request Plugin Setup
- Contributing
The purpose of this repo is to provide a step-by-step guide to enable Apigee Edge bundle deployment on Jenkins for Continuous Integration and Deployment.
Download Virtual Box. This step is required to run Vagrant.
run vagrant up
to download and install vagrant box. This box will also execute bootstrap.sh, which contains the command to install git, JRE, JDK and Jenkins.
An alternative to install Jenkins on a Virtual Machine is to leverage services from a cloud provider such as Cloudbees. You can signup for free for 200 build minutes. This environment has been tested successfuly so far.
after running vagrant ssh
install Jenkins plugins by running install-jenkins-plugins.sh. This script leverages jenkins-cli, which leverages Jenkins API to install Jenkins plugins from Jenkins dependency management. Plugins include: performance, github, github oauth, jira, email extension, mask-passwords, and node.js.
cd /vagrant
./install-jenkins-plugins.sh
Mask Passwords Plugin has been installed as part of install-jenkins-plugins.sh. To setup got to Manage Jenkins > Configure System > Mask Passwords - Parameters to automatically mask, Add global passwords. In this case add ae_username and ae_password. These variables will be used from Grunt.js Deploy plugins to deploy bundles to Apigee Edge. Unfortunately, at this point Maven for Jenkins doesn't support Mask Passwords. Alternative solution described below.
Point your browser to https://127.0.0.1:8088 on the host OS, Go to Manage Jenkins > Configure System > Maven and pick Maven 3.0.5. Make sure Install Automatically checkbox is ticked.
Name the job as "forecastweather-v1-test" Go to New Item > Build a maven project > Select Git under Source Code Management > Set URL as "https://github.com/dzuluagaapigee/apigee-ci-jenkins-git-maven-jmeter.git". Since this is a public repo, there's no need to set any credentials. In case you need to connect to a private repository, you'll need to setup ssh keys generated from you Virtual Box to be added to the private repo.
For simplicity, setup Jenkins to poll for changes every 15 minutes under Build Triggers
H/15 * * * *
Enable Mask passwords under Build Environment
Set Root POM as apiproxies/forecastweatherapi/pom.xml
Set Goals and Options as install -P test -D username=$ae_username -D password=$ae_password
. username and password can reside under settings.xml. settings.xml file can be found under this folder /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.0.5/conf/settings.xml. Sample settings.xml file included in this repo under Vagrant folder.
A quick and dirty solution is to add Global Properties under Manage Jenkins > Configure System. Be aware that this won't prevent from including them in the console output.
Go back to Job and click "Build Now"
Configure forecastweatherapi Job and under Add post-build action pick Publish Performance test result report, add a new JMeter report and provide the path under the workspace as apiproxies/forecastweatherapi/target/jmeter/results/*.jtl. Under Relative Thresholds for build comparison, set Unstable % Range negative as 80 and positive as 100. Set Failed % Range negative as 90 and positive as 100. Save and run this job. The next time this job is executed, performance reports will be generated.
Setup email from Manage Jenkins > Configure System > E-mail Notification For a small test, GMail SMTP settings can be setup. Also make sure to create an App password
Email notification leverages Email-ext Jenkins Plugin. Edit Job configuration and "Add Post Build Action" (make sure to click advanced and pick the proper trigger e.g. Always, Fail, Success, etc.)
Jenkins CLI commands are available under Manage Jenkins.
Run vagrant ssh
and java -jar ./jenkins/jenkins-cli.jar -s http://localhost:8080/ get-job forecastweather-v1-test > forecastweather-v1-test.xml
. You should see an export of the job created in previous steps.
Go to Manage Jenkins > Configure System > NodeJS, click on Add NodeJS, pick latest version and include grunt-cli@~0.1.13
under Global npm packages to install.
More info about NodeJS Plugin for Jenkins Here.
This job will allow execution of grunt-cli throughcommand line. Name this job "forecastweather-grunt-test".
Point SCM to this repo.
This will leverage the two variables (ae_username and ae_password) created in step above.
Set shell this step to execute the following commands:
echo $PATH
node --version
grunt --version
npm install
grunt --env=test --debug --username=${ae_username} --password=${ae_password}
For additional directions on enabling a job with Node.js, see this section here.
Bitnami Jenkins is a pre-configured, ready to run image for running Jenkins on Amazon EC2. Amazon EC2 Bitnami.
This plugin is useful to trigger the execution of a Job when a pull request is created. WIP
If you would like to contribute, simply fork the repository, push your changes to a branch and send a pull request.
Typo fixes, improvements to grammar or readability, it's all welcome.