rpa*_*ani 7 angularjs gruntjs gitlab-ci
我有一个GitLab CI运行器,每次我在我的分支中推送代码时都会运行.问题是:我使用npm + bower来获得我需要的所有依赖项,但我不想为每个测试下载所有依赖项:这是浪费网络和时间.
所以我想出了这个脚本.它有意义吗?
touch ~/.bash_profile
npm config set prefix ~/npm
export PATH="~/npm/bin:$PATH"
source ~/.bash_profile
npm install
rm -f ~/bower/bower.json
cp bower.json ~/bower
pushd ~/bower
bower update
bower install
popd
mkdir bower_components
cp -r ~/bower/bower_components bower_components
grunt test
Run Code Online (Sandbox Code Playgroud)
无论如何,我面临的一个问题是它总是与凉亭一起超时:
bower angular-cookies#1.2.16 ECMDERR Failed to execute "git ls-remote --tags --heads git://github.com/angular/bower-angular-cookies.git", exit code of #128 fatal: unable to connect to github.com: github.com[0: 192.30.252.128]: errno=Connection timed out
Run Code Online (Sandbox Code Playgroud)
此外,它没有完成一次,所以我不确定,但它似乎每次重新下载所有包.
我试图在网上搜索,但我没有找到任何东西.有一种方法可以实现我想要实现的目标吗?(还有一个完全不同的策略.我也有ssh访问跑步者)
rpa*_*ani 15
2016年更新
GitLab运行程序现在使用支持缓存的.gitlab-ci.yml.
这是我们的脚本:
image: *****/frontend
stages:
- test
- deploy
before_script:
- npm prune
- npm install
- bower prune --allow-root
- bower install --allow-root
cache:
paths:
- node_modules/
- bower_components/
key: "$CI_BUILD_REPO"
sample_test:
stage: test
script:
- grunt build
- grunt test
- grunt jscs --force
- grunt jshint --force
sample_deploy:
stage: deploy
only:
- master
- development
script:
- grunt build babel uglify:dist
artifacts:
paths:
- dist/
Run Code Online (Sandbox Code Playgroud)
现在,有趣的是key: "$CI_BUILD_REPO"在缓存部分 - 这将设置缓存与repo中的所有构建相同.这就是为什么我们使用npm prune和bower prune- 确保我们真正需要的模块最终都在构建中
原始答案
所以,最后我使用这个脚本:
rm -f ~/bower/bower.json
rm -f ~/bower/package.json
cp bower.json ~/bower
cp package.json ~/bower
pushd ~/bower
npm install
bower install
popd
cp -r ~/bower/bower_components .
cp -r ~/bower/node_modules .
grunt build
grunt test
Run Code Online (Sandbox Code Playgroud)
另外,为了避免从github超时,我使用https而不是git来下载代码,使用该命令
git config --global url."https://".insteadOf git://
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3922 次 |
| 最近记录: |