问题描述
我的项目有一个 git 存储库,其结构如下所示。 结构基于源,与源相关的所有代码、脚本都保存在各自的源文件夹下。 脚本和代码包括 sql、scala、pyhton...用于该源的所有类型的文件。
我必须使用 azure devops 来创建 jar 文件并将其存储在 dbfs 位置。有两件事我必须弄清楚。
- 如何使用来自 devops 的 sbt 构建文件从存储库的这个位置创建一个 jar 文件? 我尝试使用 devOps,但看不到任何从 sbt 文件创建 jar 文件的代理作业。
- 如果我可以将这个 sbt 文件转换为 pom.xml,我如何使用 devops 从这个存储库位置创建一个 jar 文件?
解决方法
您应该在 Ubuntu 主机代理上安装了 sbt。这里有一个示例 YAML 代码:
name: sbt
trigger:
- master
variables:
sbtFileDirectory: '<pass your folder where sbt file is>'
pool:
vmImage: 'ubuntu-latest'
steps:
- script: sbt clean
displayName: 'Running $ sbt clean'
workingDirectory: $(sbtFileDirectory)
- script: sbt update
displayName: 'Running $ sbt update'
workingDirectory: $(sbtFileDirectory)
- script: sbt compile
displayName: 'Running $ sbt compile'
workingDirectory: $(sbtFileDirectory)
- script: sbt test
displayName: 'Running $ sbt test'
workingDirectory: $(sbtFileDirectory)
对于经典/发布管道,它会是相似的:
您还可以在开发者社区中监控此主题 - Scala and SBT builder
,根据您的描述,您希望将构建输出(来自 Azure DevOps)添加到源代码管理 (GitHub) 中。不建议从构建更新源代码管理,如果您有特殊原因这样做,您可以在 Powershell 任务中运行 git 命令来执行提交和推送。在这种情况下检查答案:Send specific files from Azure DevOps pipeline to Github
#Clone repo to your workspace
git clone https://github.com/repo
#assuming master is your branch
git checkout master
#Refresh repo if is already in your workspace
git pull -q 2>&1 | Write-Host
#Copy file to the worspace
XCOPY "File current location" "Git workspace location"
#Add files to the local repo
git add -A
#Commits the file to local repo:
git commit -m "Files commited."
#Pushes the changes to Git repo
git -c http.extraheader='AUTHORIZATION: bearer $env:System_AccessToken' push -q -f