【发布时间】:2021-06-08 20:42:18
【问题描述】:
我有一个 Angular 应用程序,我正在尝试通过 Jenkins 进行部署。标准的 DEV 构建工作正常,但是当我执行 ng build --prod 时,它显示“ng: command not found”。
当使用npm run ng build -- --prod 运行命令时,它会显示“line 1: 6910 Killed”,然后是失败的命令
上周,我可以成功完成 prod 构建,但没有获取 environment.prod.ts 文件。今天,我遇到了上述两个错误之一。
我尝试了以下构建命令:
sh "ng build --prod"
sh "npm run ng build -- --configuration=production"
sh "npm run ng build -- --configuration production"
sh "npm run ng build -- --configuration=production --target=production --environment=prod"
sh "npm run ng build --configuration=production --target=production --environment=prod"
sh "npm run ng build -- --prod"
sh "npm run ng build -- --configuration prod"
sh "npm run ng build -- --configuration production"
sh "npm run ng build myCoolProjectName --prod --configuration=production"
sh "npm run ng build myCoolProjectName --prod --configuration production"
sh "npm run ng build --prod --configuration=production"
sh "npm run ng build --prod --configuration production"
sh "npm run ng build --configuration=production"
我在我的 Jenkins 服务器的 AWS EC2 实例上运行以下版本: 角 CLI:12.0.3, 节点:16.2.0, 包管理器:npm 7.13.0, 操作系统:linux x64
这是我的 Jenkinsfile 的重要部分:
tools {
//nodejs 'NodeJS 12.18.1'
nodejs 'NodeJS 16.2.0'
}
stage('npm install') {
steps {
sh 'npm install'
}
}
stage('Build') {
steps {
script{
if("${ENVIRO}" == "prod") {
PROFILE = "my-prod"
sh "npm run ng build -- --prod"
} else if("${ENVIRO}" == "qa"){
PROFILE = "my-qa"
sh "npm run ng build -- --configuration production"
}
else {
PROFILE = "my-dev"
sh "npm run ng build"
}
}
}
}
编辑: 我添加了内存使用情况的屏幕截图。红线末尾的摆动是我进行构建时(它失败了)。它似乎有很多可用的。
任何帮助将不胜感激,我很乐意提供更多信息。
干杯,
安迪
【问题讨论】: