微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用 azure devops 从 git 存储库特定位置的项目文件夹构建一个 jar 文件

如何解决使用 azure devops 从 git 存储库特定位置的项目文件夹构建一个 jar 文件

我的项目有一个 git 存储库,其结构如下所示。

enter image description here

enter image description here

结构基于源,与源相关的所有代码、脚本都保存在各自的源文件夹下。 脚本和代码包括 sql、scala、pyhton...用于该源的所有类型的文件

现在对于其中一个代码,我必须创建一个 jar 文件

  1. 为此,我使用 sbt build 在 IntelliJ 中创建了一个项目并创建了 jar 文件
  2. 在各自的源下创建一个文件夹并将整个项目复制到创建的文件夹中,如下所示。

enter image description here

enter image description here

我必须使用 azure devops 来创建 jar 文件并将其存储在 dbfs 位置。有两件事我必须弄清楚。

  1. 如何使用来自 devops 的 sbt 构建文件从存储库的这个位置创建一个 jar 文件? 我尝试使用 devOps,但看不到任何从 sbt 文件创建 jar 文件的代理作业。

    enter image description here

  2. 如果我可以将这个 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)

对于经典/发布管道,它会是相似的:

enter image description here

您还可以在开发者社区中监控此主题 - 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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。