如何解决如何使用bitbucket管道生成war文件并将其复制到下载文件?
我想将bitbucket用作个人项目的Maven存储库。我的计划是使用bitbucket管道来构建项目并将war文件复制到下载页面。构建成功完成后,我收到以下消息:
Building war: /opt/atlassian/pipelines/agent/build/todoey-be/target/todoey.war
但是当运行第二个管道复制战争时,我得到以下信息:
File opt/atlassian/pipelines/agent/build/todoey-be/target/todoey.war doesn't exist.
“工件”选项卡也为空。
bitbucket_pipelines.yaml:
image: maven:3.6.3
pipelines:
default:
- step:
name: Build and Test
caches:
- maven
script:
- mvn clean compile package
artifacts:
- opt/atlassian/pipelines/agent/build/todoey-be/target/todoey.war
- step:
name: Generate and deploy war
script:
- pipe: atlassian/bitbucket-upload-file:0.3.2
variables:
BITBUCKET_USERNAME: $BITBUCKET_USERNAME
BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
FILENAME: "opt/atlassian/pipelines/agent/build/todoey-be/target/todoey.war"
解决方法
问题在这里:
opt/atlassian/pipelines/agent/build/todoey-be/target/todoey.war
您已删除路径字符串开头的"/"
,这使其成为当前目录的相对路径。尝试这样的事情,以使用绝对路径:
/opt/atlassian/pipelines/agent/build/todoey-be/target/todoey.war
但是,除了使用硬编码的完整路径之外,还有一种更好的方法来使用带有一些环境变量的相对路径,并添加一些临时调试行以验证路径。考虑这样的事情:
script:
- mvn clean compile package
# Now verify the path of the built WAR output file
- echo $BITBUCKET_CLONE_DIR # Debug: Print the Git clone directory
- pwd # Debug: Print the current working directory
- find "$(pwd -P)" -name todoey.war # Debug: Show the full file path of todoey.war,from the current working directory
- echo "$BITBUCKET_CLONE_DIR/build/todoey-be/target/todoey.war" # Debug: Print the resolved path of todoey.war
artifacts:
- "$BITBUCKET_CLONE_DIR/build/todoey-be/target/todoey.war"
- pipe: atlassian/bitbucket-upload-file:0.3.2
variables:
BITBUCKET_USERNAME: $BITBUCKET_USERNAME
BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
FILENAME: "$BITBUCKET_CLONE_DIR/build/todoey-be/target/todoey.war"
$BITBUCKET_CLONE_DIR
是项目的“ Git clone”根文件夹的预定义环境变量:在此处进行了描述:https://support.atlassian.com/bitbucket-cloud/docs/variables-in-pipelines/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。