我正为Azure Devops的一条yml管道而挣扎。我创建了一个stage.yml、build.yml和deploy.yml文件。stage.yml非常向前,它有两个阶段,并将您引导到build.yml或deploy.yml。
deploy.yml应该提取来自build.yml的工件,并使用SSH将其复制到远程环境中。Azure将工件作为第一阶段的结果显示出来,因此这是可行的。但是,每次运行作业时,它都会在run输出中显示以下消息:
Starting: Copy JAR to host deploy
==============================================================================
Task : Copy files over SSH
Description : Copy files or build artifacts to a remote machine over SSH
Version : 0.189.0
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/deploy/copy-files-over-ssh
==============================================================================
Setting up SSH service connection to remote host xx.xx.xx.xx.
Found 0 files to copy to the remote machine.
Completed copying 0 files to the remote machine.
Finishing: Copy JAR to host deploy是我的配置中缺少了什么,还是路径配置错了?如果是的话,应该如何配置?
我的build.yml看起来是这样的:
parameters:
- name: incomingFeedName
type: string
default: 'project'
jobs:
- job: build_maven
displayName: Build
pool:
vmImage: ubuntu-latest
variables:
- name: MAVEN_CACHE_FOLDER
value: $(Pipeline.Workspace)/.m2/repository
- name: MAVEN_OPTS
value: '-Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)'
steps:
- task: Cache@2
# This task create cache of your all dependancies to fast the build for next time
# https://learn.microsoft.com/en-us/azure/devops/pipelines/caching/?view=azure-devops
inputs:
key: 'maven4 | "$(Agent.OS)" | **/pom.xml,!**/target/**/pom.xml'
restoreKeys: |
maven4 | "$(Agent.OS)"
maven4
path: $(MAVEN_CACHE_FOLDER)
displayName: 'Cache local maven repo'
- task: MavenAuthenticate@0
# This task will authenticate your maven feed for input dependancies and output dependancies
inputs:
artifactsFeeds: ${{parameters.incomingFeedName}}
displayName: 'Authenticate to Azure Maven feed'
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m $(MAVEN_OPTS)'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '11'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
mavenVersionOption: 'Default'
mavenAuthenticateFeed: false
goals: 'deploy'
displayName: 'Maven build'
- task: CopyFiles@2
# pick up the results of the build (JAR file) and stage them.
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)/target'
Contents: '*.jar'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
displayName: Stage Jar files for publishing
- task: PublishPipelineArtifact@1
# Upload the results into the pipeline. This files can be used in the release pipeline
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifact: 'Binaries'
publishLocation: 'pipeline'
displayName: Publish Jar filedeploy.yml:
parameters:
- name: envName
type: string
jobs:
- deployment: deploy_jar
displayName: Deploy JAR
environment: ${{ parameters.envName }}
variables:
# - group: 'global'
- name: 'endpoint'
${{ if eq(parameters.envName, 'Test') }}:
value: 'deploy'
# pool:
# name: 'poolname here'
strategy:
runOnce:
deploy:
steps:
# - task: DeleteFiles@1
# inputs:
# sourceFolder: '${Pipeline.Workspace)\Binaries'
# contents: '*'
# removeSourceFolder: true
# displayName: 'Clear JAR file from pipeline downloads: Before'
# - download: current
# artifact: Binaries
- task: CopyFilesOverSSH@0
inputs:
sshEndpoint: ${{variables.endpoint}}
sourceFolder: '$(Build.ArtifactStagingDirectory)'
# contents: '*'
targetFolder: '~/_work/'
readyTimeout: '20000'
# overWrite: true
displayName: 'Copy JAR to host ${{variables.endpoint}}'
# - task: SSH@0
# inputs:
# sshEndpoint: ${{variables.endpoint}}
# runOptions: 'commands'
# commands: 'execute service'
# readyTimeout: '200'
# displayName: 'Run service'
# - task: DeleteFiles@1
# inputs:
# sourceFolder: '${Pipeline.Workspace)\Binaries'
# contents: '*'
# removeSourceFolder: true
# displayName: 'Clear JAR file from pipeline downloads: After'发布于 2021-12-02 13:49:23
在部署时,构建工件将被下载到$(Pipeline.Workspace)。$(Build.ArtifactStagingDirectory)在这里无效。
您可以通过在副本之前添加如下步骤来验证这一点:
- pwsh: |
Write-Host "Build.ArtifactStagingDirectory is $(Build.ArtifactStagingDirectory)"
Write-Host "Pipeline.Workspace is $(Pipeline.Workspace)"
Get-ChildItem $(Build.ArtifactStagingDirectory)
Get-ChildItem $(Pipeline.Workspace)https://stackoverflow.com/questions/70195841
复制相似问题