Ejecutar el comando grunt build en Travis CI
Estoy usando Travis CI para probar y construir mi proyecto y como parte de él quiero que travis ejecute grunt build
he intentado lo siguiente, pero no he tenido suerte.
script: "grunt build"
script: "./node_modules/grunt build"
script: "./node_modules/grunt/grunt build"
script: "./node_modules/grunt/grunt.js build"
4 answers
¿Se ha asegurado de instalar grunt-cli
globalmente en su nodo Travis?
Mi configuración de Travis CI se ve así:
language: node_js
node_js:
- "0.8"
before_install: npm install -g grunt-cli
install: npm install
before_script: grunt build
Y mi paquete.json:
{
...
"scripts": {
"test": "grunt test"
},
...
}
Voy a explicar el flujo de pasos que Travis ejecutará:
- El primer paso a ser ejecutado es el
before_install
. Mi único prerrequisito (además de nodo.js) esgrunt-cli
así que utilizo este paso para instalarlo. - El siguiente paso es
install
, en mi caso esto simplemente instalará mis módulos npm - El
before script
es entonces ejecutado, corriendogrunt build
- Por último Travis buscará scripts en el paquete.json, allí indiqué que el paso de prueba debe ejecutarse
grunt test
Me gustaría señalar que esta es mi propia opinión sobre cómo configurar Travis. Ciertamente no estoy inclinado a que uses exactamente el mismo enfoque.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-11-28 20:48:19
Es probable que se pierda en su travis.archivo yml:
before_script:
- npm install -g grunt-cli
Entonces "grunt whatever" debería ejecutarse ok (suponiendo que requieras grunt en tus devDependencies en tu paquete.json).
(véase http://www.mattgoldspink.co.uk/2013/02/10/using-travis-ci-with-grunt-0-4-x/)
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-01-15 09:30:45
Asegúrate de tener grunt como parte de tus devDependencies. Aquí hay un archivo de ejemplo: https://github.com/fraxedas/raspi-cloud/blob/master/package.json
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-jshint": "^0.11.2",
"grunt-contrib-watch": "^0.6.1"
}
Travis-ci instalará grunt en el paso de instalación:
npm install
...
[email protected] node_modules/grunt
...
En mi caso quería ejecutar jshint con grunt. Aquí está mi travis.archivo yml: https://github.com/fraxedas/raspi-cloud/blob/master/.travis.yml
Para integrar a grunt todo lo que necesitaba era:
before_script: grunt jshint
Puede cambiar jshint por otra orden.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-05-21 11:33:25
My .travis.yml se ve así:
Se ejecuta mucho más rápido que npm
como NodeJS
gestor de paquetes, estoy usando Yarn
en este ejemplo. Se instala yarn
, grunt cli
, ruby
y sass
.
Espero que ayude.
language: node_js
node_js:
- "7.1.0"
before_install:
- npm install -g yarn
- yarn add global ruby
- gem install sass
install:
- yarn add global sass
- yarn add global grunt-cli
- yarn add yarn install
before_script: grunt
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-01-14 04:01:57