我的 grunt build
任务创建一个 /dist/
我的项目所依赖的。我不想在我的存储库中包含构建文件。我宁愿使用 Jenkins 来允许在我的项目上构建持续集成。这就是我的 .openshift/action_hooks/build
中的内容,我不确定它为什么没有运行:
echo " >>>>>>>>> Building with grunt..."
grunt build
echo " >>>>>>>>> Finished building with grunt..."
我知道它没有运行,因为我没有在 Jenkins 构建日志或应用程序日志 ( rhc tail <app-name>
) 中看到这些回显行。
此外,当我通过 ssh 进入服务器并尝试运行 grunt build
时手动,它无法找到 grunt 命令,所以这让我想知道这是否可能......
我是否应该只将构建的文件包含在我的存储库中?如果是这样,OpenShift 什么时候会解决这个问题? :)
如果我做错了什么,请告诉我。谢谢!
最佳答案
这里的根本问题是 openshift-origin-cartridge-nodejs还有npm_global_module_list在全局 npm 模块中不包含 grunt/grunt-cli。
我打开了openshift/origin-server/issues/4069作为 RFE 将其放入默认墨盒。
与此同时,我一直在研究 engineersamuel/openshift-origin-cartridge-nodejs其中包括 Bower 和 Grunt 支持。
如果找到 Gruntfile.js,我的卡带会运行 grunt prod
。默认情况下,grunt 不在路径中,这可以通过在命令前加上 node_modules 轻松解决。
# If there is a grunt file, run $ grunt prod
if [ -f "${OPENSHIFT_REPO_DIR}"/Gruntfile.js ]; then
(cd "${OPENSHIFT_REPO_DIR}"; node_modules/grunt-cli/bin/grunt prod)
fi
./bin/control
还会检查 bower.json 文件并安装相应的包。
您可以使用以下命令使用墨盒反射器快速轻松地测试此自定义墨盒:
rhc create-app nodejstest "http://cartreflect-claytondev.rhcloud.com/reflect?github=engineersamuel/openshift-origin-cartridge-nodejs"
关于git - 在 OpenShift 构建之前运行 Grunt 构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19474796/