Jenkins integration with Grunt

前端 未结 5 918
离开以前
离开以前 2020-12-09 09:40

I\'ve setup Jenkins v1.550 on Windows Server 2008 R2. It runs as a service at http://localhost:8080 for now. I\'m logged into the machine as an Administrator. I

相关标签:
5条回答
  • 2020-12-09 10:20

    Had the same issue on Windows. When I manually installed node and ran npm install -g grunt-cli from command line, jenkins could not recognize the grunt command. So uninstall node, reinstall it but dont run npm install. Then restart the jenkins slave. Then from the jenkins job that runs on your specific jenkins slave, make it run a Windows batch command that runs npm install -g grunt-cli After that again restart the jenkins service. Then from the job run npm install. Then everything worked for me. If issues still persist, then uninstall the slave, and reinstall it, then everything works fine immediately.

    0 讨论(0)
  • 2020-12-09 10:25

    I have grunt doing some tasks for me in Jenkins, but I went the npm script route. Grunt and grunt-cli are dev dependencies, and I have the following defined in my package.json file:

    "scripts": {
        "test": "node node_modules/grunt-cli/bin/grunt test"
    },
    

    In Jenkins (running on Windows), I added two post-build tasks:

    npm install
    
    npm test
    

    We just installed NodeJs normally on the Jenkins server.

    0 讨论(0)
  • 2020-12-09 10:32

    for nice easy to configure self-installed nodejs on the machine, i have to recommend the excellent -> http://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin

    it will install nodejs and grunt on the machine, through easy to use web front end no shell required

    jenkins jobs can then simply run nodejs build steps, hey presto

    steps involved :

    a) install this on your jenkins instance -> http://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin

    b) create a nodejs installation on jenkins

    go to

    http://URL_OF_JENKINS/jenkins/configure
    
    • NodeJS- > NodeJS installations -> Add NodeJS -> Name = "NodeJS 0.11.10", tick "Install automatically", select "Install from nodejs.org", add "grunt-cli" to globally installed packages

    c) create a job with "execute NodeJS script" build task

    var sys = require('sys');
    sys.puts('NodeJS Test');
    sys.puts('***************');
    sys.puts('helloworld');
    

    volia :)

    run the job and see the nodejs script run,

    from their the world is your oyster you can use grunt by ticking "Provide Node/npm bin folder to PATH" and running a "execute shell" build task

    npm update
    grunt
    grunt --force reporting
    
    0 讨论(0)
  • 2020-12-09 10:32

    You will need to restart the Jenkins service after installing node, presumably to cause it to refresh its cached copy of your PATH environment variable

    0 讨论(0)
  • 2020-12-09 10:44

    Another solution that worked for me on Windows is to use the full path to the grunt exec file, which can be found by writing "where grunt" in the command shell. I used the full path in the regular bat-file.

    0 讨论(0)
提交回复
热议问题