有没有办法获得在pom.xml文件中定义的版本,以便它可以与Bitbucket管道中的变量一起使用?
在StackOverflow上也有类似的问题,但它们主要指的是Jenkins和"readMavenPom“,这似乎在Bitbucket管道中不可用。
我想使用它作为第二步上传到S3的版本标签。
- step:
name: Build and Test
caches:
- maven
script:
- mvn package
artifacts:
- target/myapp-*.jar
- step:
name: Upload to S3
deployment: production
script:
- pipe: atlassian/aws-code-deploy:0.2.10
variables:
AWS_DEFAULT_REGION: $AWS_REGION
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
COMMAND: 'upload'
APPLICATION_NAME: 'myapp'
ZIP_FILE: "target/myapp-*.jar"
S3_BUCKET: 'myapps'
VERSION_LABEL: "myapp-${version}-${BITBUCKET_COMMIT:0:8}"发布于 2021-02-24 23:07:32
基于@joe的提示和类似的问题How to get Maven project version to the bash command line,我可以确认这在Bitbucket管道上是有效的:
- step:
name: Get the version from pom.xml
script:
- MVN_VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
- echo $MVN_VERSION结果
+ MVN_VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
+ echo $MVN_VERSION
0.0.1-SNAPSHOThttps://stackoverflow.com/questions/66336916
复制相似问题