[英]How to use Azure DevOps only for the build part ? and the rest of the ci/cd in jenkins
我需要完成这个场景 Jenkins 是主要的 ci/cd 工具,现在我们想使用 Azure 作为我们的构建服务器,但仅用于构建:
我如何结合第 3 部分?
我如何结合第 3 部分?
据我所知,可以使用 Azure Devops 自托管代理连接 azure devops 和 Jenkins。
您可以参考以下步骤:
在 Jenkins 服务器上创建 Azure Devops 自托管代理。
由于结帐步骤在 Jenkins 上,您可以在 Azure Devops 中添加Copy file task
以将源复制到构建目录。
eg Source Repo Path -> $(Build.SourcesDirectory)
例如Source: $(build.artifactstagingdirectory) -> Target: Slave Path
如果您需要将文件复制到另一台远程机器,您可以尝试使用通过 SSH 复制文件或Windows 机器文件复制任务。
更新:
配置源后,您可以将存储库作为工件发布到 Jenkins Server 中。
您可以在 azure devops 中使用Jenkins download artifacts
任务来下载工件。
注意:工件将下载到$(Build.ArtifactStagingDirectory)
。
然后您可以运行任务并在托管 Macos 代理上发布构建工件。
要将创建的工件复制回 Jenkins:
您可以添加另一个代理作业并使用自托管代理(在 linux AWS 上)将工件下载到 jenkins 服务器。
代理作业 1 正在托管 MacOs 代理上运行。 代理作业 2 正在自托管代理上运行。
更新2:
Yaml 示例:
stages:
- stage: CopyFile
pool:
name: default
jobs:
- job: testjob
steps:
- task: CopyFiles@2
inputs:
SourceFolder: 'Local Path'
Contents: '**'
TargetFolder: '$(build.artifactstagingdirectory)'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'Source'
publishLocation: 'Container'
- stage: BuildProject
dependsOn: CopyFile
pool:
vmImage: ubuntu-16.04
jobs:
- job: buildjob
steps:
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'Source'
downloadPath: '$(System.ArtifactsDirectory)'
- task: xxx(build task)
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'Artifacts'
publishLocation: 'Container'
- stage: BackToJenkins
dependsOn: BuildProject
pool:
name: default
jobs:
- job: Sendjob
steps:
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'Artifacts'
downloadPath: '$(System.ArtifactsDirectory)'
您需要修改路径(发布路径、下载路径)以满足您的需求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.