[英]Build and deploy node app to Openshift using Gitlab CI
Just mount a Gitlab in digitalocean to keep track of versions of some projects, but now I've read a little about Gitlab I wonder if you can set Gitlab CI so that each time you do a commit automatically make a build of application and if the build is successful can do a deploy to OpenShift. 只需在digitalocean中安装一个Gitlab来跟踪某些项目的版本,但是现在我对Gitlab有了一些了解,我想知道是否可以设置Gitlab CI,以便每次执行提交时都会自动构建应用程序,并且是否构建成功可以部署到OpenShift。
I think my .gitlab-ci.yml should look something like this: 我认为.gitlab-ci.yml应该看起来像这样:
stages:
- build
- deploy
before_script:
- npm install
job_build:
stage: build
script:
- grunt build
job_deploy:
stage: deploy
But I really do not know if this is as valid and neither tell Gitlab CI must only make a git push
to OpenShift repository. 但是我真的不知道这是否有效,也没有告诉Gitlab CI必须将git push
到OpenShift存储库。
After much reading and searching finally found documentation about this [1], in the end I have resolved some file using the following .gitlab-ci.yml 经过大量的阅读和搜索,最终找到了有关此文档的文档[1],最后,我使用以下.gitlab-ci.yml解决了一些文件
stages:
- build
- deploy
job_build:
stage: build
script:
- npm install -g grunt-cli
- npm rebuild node-sass
- npm install
- grunt build
job_deploy:
stage: deploy
script:
- apt-get update -yq
- apt-get install -y ruby-dev rubygems
- gem install dpl
- dpl --provider=openshift --user=$OPENSHIFT_USER --password=$OPENSHIFT_PASS --domain=mydomain --app=example
only:
- master
The magic happens with a Travis library call dpl [2] that supports a lot of providers [3] Travis库调用dpl [2](支持许多提供程序[3])使魔术发生了变化
[1] http://doc.gitlab.com/ce/ci/deployment/README.html [1] http://doc.gitlab.com/ce/ci/deployment/README.html
[2] https://github.com/travis-ci/dpl [2] https://github.com/travis-ci/dpl
[3] https://github.com/travis-ci/dpl#supported-providers [3] https://github.com/travis-ci/dpl#supported-providers
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.