I am writing automation test scripts using Protractor and now I need to set up the CI for this using Jenkins.
Tasks it needs to perform are:
Can anyone help in this regard?
The main part of Continuous deployment is to ensure that the entire process which is shown above is automated. Jenkins achieves all of this via various plugins, one of them being the “Deploy to container Plugin” which was seen in the earlier lessons.
Jenkins is a free and open source continuous integration tool. It provides continuous integration services for software development by automating the build, artifact management, and deployment processes.
Continuous Integration Server (Jenkins, Bamboo, CruiseControl, TeamCity, and others) Source Control Tool (e.g., CVS, SVN, GIT, Mercurial, Perforce, ClearCase and others) Build tool (Make, ANT, Maven, Ivy, Gradle, and others) Automation testing framework (Selenium, Appium, TestComplete, UFT, and others)
I created a small bash script to do this.
# start selenium ./node_modules/protractor/bin/webdriver-manager start > /dev/null 2>&1 & # wait until selenium is up while ! curl http://localhost:4444/wd/hub/status &>/dev/null; do :; done # run the build grunt cibuild --force # stop selenium curl -s -L http://localhost:4444/selenium-server/driver?cmd=shutDownSeleniumServer > /dev/null 2>&1
This script is invoked from a free-style project in jenkins (Build > Execute shell)
Then the test result report is generated by reading the protractor test results. Hence, you have to produce junit reports from protractor, (look here) :
onPrepare: function() { // The require statement must be down here, since jasmine-reporters // needs jasmine to be in the global and protractor does not guarantee // this until inside the onPrepare function. require('jasmine-reporters'); jasmine.getEnv().addReporter( new jasmine.JUnitXmlReporter('xmloutput', true, true)); },
To make the report visible in jenkins i add a post build action in the job: Publish JUnit test result report
:
Alternatively, you could run this as a Grunt Task. First install grunt on Jenkins. Install the NPM packages for protractor_webdriver and protractor. Setup the configuration file to point the the node_module path and config file paths.
http://sideroad.secret.jp/articles/grunt-on-jenkins/
Then install protractor node modules. The Gruntfile would look similar to this. I created a test directory where the conf and spec files would be located.
module.exports = function (grunt) { grunt.initConfig({ protractor_webdriver: { your_target: { options: { path: 'node_modules/protractor/bin/', command: 'webdriver-manager start' } } }, protractor: { options: { configFile: "node_modules/protractor/referenceConf.js", // Default config file keepAlive: true, // If false, the grunt process stops when the test fails. noColor: false, // If true, protractor will not use colors in its output. args: { // Arguments passed to the command } }, your_target: { options: { configFile: "test/conf.js", // Target-specific config file args: {} // Target-specific arguments } } } }); grunt.registerTask('p:test', [ 'protractor_webdriver', 'protractor' ]); });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With