jenkins - 无法在 Jenkins 中将文件 'xxx-dist.tar' 添加到 TAR 'xxx-dist.tar'
问题描述
我用 java 编写了一个 web 应用程序项目(比如 frs)。它由 frs-core 和 frs-ui 模块组成。core 由gradle 构建,ui 由node v9.5.0工具构建。之后,maven统一了两个模块并转换为 TAR 格式。但是当它最终想将它们连接在一起时,出现了以下错误:
The build folder is ready to be deployed. You may serve it with a static server:
yarn global add serve serve -s build
Find out more about deployment here:
http://bitttttttt
:frs-ui:distTar FAILED
FAILURE: Build failed with an exception.
* What went wrong: Execution failed for task ':frs-ui:distTar'.
> Could not add file '/home/samat/workspace/ttbank_frs-2.Build/frs-ui/build/distributions/frs-ui-1.0.0-9dcad410730dbec6f401254f464582e2fa8cd838-build.tar' to TAR '/home/samat/workspace/ttbank_frs-2.Build/frs-ui/build/distributions/frs-ui-1.0.0-9dcad410730dbec6f401254f464582e2fa8cd838-build.tar'.
这是我的build.gradle配置
> group = 'ir.samatco.frs'
> version = '1.0.0'
>
> apply from: "$rootDir/gradle/ci.gradle" }
>
> ext {
> javaProjects = [':frs-core', ':frs-gateway'].collect { project it }
> webProjects = [':frs-ui'].collect { project it } }
>
> subprojects {
> if (project in javaProjects) {
> apply plugin: 'java'
> sourceCompatibility = 1.7
> targetCompatibility = 1.7
> [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
> }
>
> if (project in webProjects) {
> task npmBuild(type: Exec) {
> workingDir projectDir
> executable 'npm'
> args 'run', 'build'
> }
> task distTar(type: Tar) {
> dependsOn npmBuild
> baseName = "${project.name}-${project.version}"
> compression 'gzip'
> extension 'tar'
> destinationDir = "$buildDir/distributions" as File
> from('dist') { into('/') }
> }
> idea {
> module { // excludeDirs = [".tmp", "bower_components", "dist", "node_modules"].collect {
> file("$projectDir/$it") }
> excludeDirs = ["dist", "node_modules"].collect { file("$projectDir/$it") }
> sourceDirs = [file("$projectDir/src")]
> }
> }
> }
>
> apply plugin: 'maven-publish'
>
> publishing {
> publications {
> maven(MavenPublication) {
> artifact distTar {
> classifier 'dist'
> }
> }
> }
> repositories {
> maven() {
> credentials {
> username project.nexus_user
> password project.nexus_pass
> }
> url "http://nexus.devsamat.ir/content/repositories/test/"
> }
> }
> } }
>
> task stage {
> dependsOn subprojects*.publish }
引起“无法将文件...添加到 TAR ... ”的原因是什么,谢谢百万。
解决方案
我找到了解决方案!故障模块是frs-ui,它与 build.gradle 文件中的webProject块有关。所以你应该根据以下更改 build.gradle:
if (project in webProjects) {
task npmBuild(type: Exec) {
logging.captureStandardOutput LogLevel.INFO
logging.captureStandardError LogLevel.INFO
inputs.dir "src"
outputs.dir "build"
if(Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'cmd', '/c', 'npm', 'run', 'build'
} else {
commandLine 'npm', 'run', 'build'
}
}
task distTar(type: Tar) {
dependsOn npmBuild
baseName = "${project.name}-${project.version}"
compression 'gzip'
extension 'tar'
destinationDir = "$buildDir/distributions" as File
from('dist') { into('/') }
}
idea {
module {
excludeDirs = [".tmp", "dist", "node_modules"].collect { file("$projectDir/$it") }
sourceDirs = [file("$projectDir/src")]
}
}
}
推荐阅读
- javascript - 我正在尝试使用 this.history.push 重定向到另一个页面,但它不起作用
- java - Java Haversine 公式实现问题
- javascript - 在反应模块中将 prop-types 标记为对等依赖项是否安全
- aes - 我应该使用 aes ctr 模式吗?
- python - 有时我可以单击按钮,有时不起作用
- python - 异步执行之前的多处理池映射/星图启动?
- python - 在 Sagemaker 中用测试集拟合模型时,有没有办法接收测试集的预测?
- kotlin - 如何在 Android 和 JVM 目标之间共享 Java 代码(使用 Kotlin Multiplatform)?
- windows-subsystem-for-linux - 如何删除我在 Win10 Ubuntu 中意外创建的文件夹?
- azure - 将管理员添加到互联工厂解决方案加速器