Protractor & Jasmine Configuration on Jenkins

五迷三道 提交于 2019-12-13 21:32:49

问题


I am trying to configure Protractor on Jenkins for CTI.... I have already setup Protractor along with Jasmine and trying to get it integrated with Jenkins.

I have gone through several links & blogs on internet but none seem to be helpful in providing detailed information on how to get the Protractor configured with Jenkins.

Any help or pointing towards the right blog or video will be really appreciated. Thanks


回答1:


@Vishal

Please find the below snippet you can add as grunt task.

'use strict';

module.exports = function (grunt) {
    grunt.initConfig({
        exec: {
            protractorRunAppsTest: {
                cmd: 'C:\\Program Files\\nodejs\\node.exe C:\\Users\\Administrator\\AppData\\Roaming\\npm\\node_modules\\protractor\\built\\cli.js C:\\Jenkins\\workspace\\test\\conf.js'
                }
        },
        server: {
            port:3000,
            base: ['app']
        },
    });

    grunt.loadNpmTasks('grunt-contrib-connect'); 
    grunt.loadNpmTasks('grunt-protractor-runner');
    grunt.loadNpmTasks('grunt-run');
    grunt.loadNpmTasks('grunt-exec');

    grunt.registerTask('server', 'Start node server', function() {
        grunt.log.writeln('Started server on port 3000');
        require('./app.js');
    });
    grunt.registerTask('runAppsTest', ['exec:protractorRunAppsTest']);

};

Save the above code as Gruntfile.js

Make sure this is in the workspace folder for jenkins.

In Jenkins job add the 'Build' Section (i am assuming Jenkins is windows server)

add "Execute Windows Batch Command" and add the below content to the text field there.

cd %WORKSPACE%
grunt server runAppsData || exit 0

I hope this would work for you. Please try and let me know. Consider rating my answer.




回答2:


@Vishal try to use grunt for doing the same. So that you can easily integrate the Jenkins job with grunt task details.

Just configure and register task with grunt. Then use the grunt task to run in jenkins.

If you want i can provide more details.



来源:https://stackoverflow.com/questions/42157923/protractor-jasmine-configuration-on-jenkins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!