英文:
How to ignore SNAPSHOTs on Maven versions:set?
问题
I would like to have Maven build Java projects on our Jenkins server. The version should be set correctly in the pom.xml. For this I use in the PreBuild Step:
mvn build-helper:parse-version versions:set -DnewVersion=${parsedVersion.majorVersion}.${parsedVersion.minorVersion}${parsedVersion.qualifier?}.##JenkinsBuildNumber##
0.3.12
0.5.56 etc.
It will now build the version correctly.
But now I notice that from SNAPSHOTs now also normal versions are built:
1.0-SNAPSHOT => 1.0.12
2.0-SNAPSHOT => 2.0.54
Of course this should not be. Best no version is to be adapted with SNAPSHOTS at all, thus Ignoriert. But this does not work:
mvn build-helper:parse-version versions:set -DignoredVersions=.*-SNAPSHOT -DnewVersion=${parsedVersion.majorVersion}.${parsedVersion.minorVersion}${parsedVersion.qualifier?}.##JenkinsBuildNumber##
The build number is still appended. How can I get versions:set to not change the version on SNAPSHOTs?
1.0-SNAPSHOT => 1.0-SNAPSHOT
2.0-SNAPSHOT => 2.0-SNAPSHOT
0.3.0 => 0.3.12
0.5.0 => 0.5.56
1.2.0 => 1.2.124
英文:
I would like to have Maven build Java projects on our Jenkins server. The version should be set correctly in the pom.xml. For this I use in the PreBuild Step:
mvn build-helper:parse-version versions:set -DnewVersion=${parsedVersion.majorVersion}.${parsedVersion.minorVersion}${parsedVersion.qualifier?}.##JenkinsBuildNumber##
0.3.12
0.5.56 etc.
It will now build the version correctly.
But now I notice that from SNAPSHOTs now also normal versions are built:
1.0-SNAPSHOT => 1.0.12
2.0-SNAPSHOT => 2.0.54
Of course this should not be. Best no version is to be adapted with SNAPSHOTS at all, thus Ignoriert. But this does not work:
mvn build-helper:parse-version versions:set -DignoredVersions=.*-SNAPSHOT -DnewVersion=${parsedVersion.majorVersion}.${parsedVersion.minorVersion}${parsedVersion.qualifier?}.##JenkinsBuildNumber##
The build number is still appended. How can I get versions:set to not change the version on SNAPSHOTs?
1.0-SNAPSHOT => 1.0-SNAPSHOT
2.0-SNAPSHOT => 2.0-SNAPSHOT
0.3.0 => 0.3.12
0.5.0 => 0.5.56
1.2.0 => 1.2.124
答案1
得分: 2
我用一个预构建步骤解决了它
条件步骤
执行 Shell
ACTUALVERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) && if echo ${ACTUALVERSION} | test=$(grep -v "SNAPSHOT"); then exit 0; else exit 1; fi
运行 Maven 目标
build-helper:parse-version versions:set -DnewVersion=${parsedVersion.majorVersion}.${parsedVersion.minorVersion}${parsedVersion.qualifier?}.${BUILD_NUMBER}
英文:
I solved it with a Pre-Build Step
Conditional Step
Execute Shell
ACTUALVERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) && if echo ${ACTUALVERSION} | test=$(grep -v "SNAPSHOT"); then exit 0; else exit 1; fi
Run Maven Goal
build-helper:parse-version versions:set -DnewVersion=${parsedVersion.majorVersion}.${parsedVersion.minorVersion}${parsedVersion.qualifier?}.${BUILD_NUMBER}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论