Jenkins CI在配置构建中集成了NodeJS和Github的问题 [英] Jenkins CI integrate with NodeJS and Github problems in configuring build

查看:833
本文介绍了Jenkins CI在配置构建中集成了NodeJS和Github的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经构建了我们的第一个Nodejs应用程序,并且我想集成Jenkins作为持续集成,我们在Nginx之后运行节点服务器作为Gitlab中的代理和源代码控制。我需要示例配置或步骤。
我在这里找到任何文档或wiki链接,或者如果你能指向正确的方向将是有帮助
我有CentOS服务器,并管理安装和配置Jenkins,但没有得到正确的方式连接我Gitlab服务器。我需要在每次构建之后运行npm命令。



感谢

解决方案

您的问题仍然模糊,但我会尽力在这里为您提供如何使用Gitlab集成完成Jenkins NodeJ。我有CentOS 6并经过测试。



步骤



b
$ b



以jenkins登录




  • sudo -s -H -u jenkins



现在在文件夹/var/lib/jenkins/.ssh中生成ssh密钥,键到gitlab




  • ssh-keygen


  • 安装




您将通过在浏览器中访问jenkins来创建一个项目
创建项目后,去配置(左侧菜单)项目页面
有很多选项是自解释 - 设置Git repo url
和设置邮件git浏览器url。




  • 在jenkins中创建一个新项目并添加git repo url并在生成触发器中
    select将更改推送到GitLab时生成。 GitLab CI服务网址:



构建触发器

检查选项




  • 当更改推送到GitLab时构建


  • 将该网址粘贴到您的gitlab仓库的webhooks中




这是在构建后运行npm命令



有一个部分SSH Publisher



在exec命令部分(我已经把我的例子你可以写你的命令)

  cd project_dir 
rm -rf public server package.json
tar -xvf projectname.tgz
ls
npm install - 生产
export NODE_ENV = production
forever restartall
jasmine-node spec / api / frisbyapi_spec.js
rm -rf projectname.tgz

我写了大部分的步骤,我用来设置jenkins nodejs和gitlab。
我可能忘了任何步骤。如果你面对任何错误,请张贴。以及。


We have build our first Nodejs app and I want to integrate Jenkins as continuous integration we are running node server behind Nginx as proxy and source control in Gitlab. I need example configurations or steps. I am looking here any doc or wiki link or if you can point me into right direction it will be helpful I have CentOS server and managed to install and configure Jenkins but not getting the proper way to connect my Gitlab server. I need to run npm commands after each build. If any one already has done that please let me know.

Thanks

解决方案

Your question is still vague but I will try to provide you here how I had done Jenkins NodeJs with Gitlab integration. I have CentOS 6 and tested.

Steps

Open Java should be installed prior.

Login as jenkins

  • sudo -s -H -u jenkins

Now generate the ssh key in the folder /var/lib/jenkins/.ssh and copy that key to gitlab

  • ssh-keygen

  • Install Gitlab Hook Plugin and GitLab Plugin in jenkins.

As you will create a project by accessing your jenkins in browser After creating the project go to configure (left side menu) project page There lots of options are self explanatory - setup Git repo url and setup mail git browser url.

  • Create a new item in jenkins and add the git repo url and in build triggers select Build when a change is pushed to GitLab. GitLab CI Service URL:

Build Triggers
check the option

  • Build when a change is pushed to GitLab

  • Paste that url in your gitlab repo's webhooks in settings.

This is to run npm commands after build

There is one section SSH Publisher

In exec commands section (I have put my example you can write your commands)

    cd project_dir
    rm -rf public server package.json
    tar -xvf projectname.tgz 
    ls
    npm install --production
    export NODE_ENV=production 
    forever restartall
    jasmine-node spec/api/frisbyapi_spec.js 
    rm -rf projectname.tgz 

I have written most the steps that I took to setup jenkins nodejs and gitlab. I might have forgot any step. If you face any error please post that as well.

这篇关于Jenkins CI在配置构建中集成了NodeJS和Github的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆