管道:无法从工件目录发布文件

时间:2020-01-25 17:23:23

标签: azure azure-devops

我有这个管道文件,可以从Electron应用程序中创建一个exe文件。最后,我要发布一个Github发行版,其中包含结果文件(至少我正在尝试这样做)。问题是进行发布时找不到exe文件。

-   job: Release
    dependsOn:
        - WindowsBuild
    pool:
        vmImage: 'ubuntu-latest'
    steps:
        -   bash:
                echo "##vso[task.setvariable variable=GIT_TAG]$(git describe --tags --always)"
            displayName: "Set the tag name"

        -   task: DownloadPipelineArtifact@2
            inputs:
                artifact: 'Windows'
                path: $(Build.ArtifactStagingDirectory)

        -   bash:
                ls -la '$(Build.ArtifactStagingDirectory)'
            displayName: "List artifacts dir"

        -   task: GitHubRelease@1
            displayName: "Github release"
            inputs:
                gitHubConnection: 'github connection'
                repositoryName: '$(Build.Repository.Name)'
                assets: |
                    '$(Build.ArtifactStagingDirectory)/app.exe'
                action: 'edit'
                target: '$(Build.SourceVersion)'
                tagSource: gitTag
                tag: '$(GIT_TAG)'
                addChangeLog: true
                assetUploadMode: replace
                changeLogCompareToRelease: lastNonDraftRelease
                title: 'Release $(GIT_TAG)'

如您所见,我执行的任务之一是ls -la '$(Build.ArtifactStagingDirectory)',因此我可以看到ArtifactStagingDirectory中的内容:

Starting: List artifacts dir
==============================================================================
Task         : Bash
Description  : Run a Bash script on macOS, Linux, or Windows
Version      : 3.159.3
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/bash
==============================================================================
Generating script.
Script contents:
ls -la '/home/vsts/work/1/a'
========================== Starting Command Output ===========================
/bin/bash --noprofile --norc /home/vsts/work/_temp/4a24644d-728f-4a2a-a7d9-12a5de01f75d.sh
total 70480
drwxr-xr-x 2 vsts docker     4096 Jan 25 17:15 .
drwxr-xr-x 6 vsts docker     4096 Jan 25 17:14 ..
-rw-r--r-- 1 vsts docker 72161249 Jan 25 17:15 app.exe

Finishing: List artifacts dir

存在app.exe文件。接下来的任务是GitHubRelease,其指定资产为'$(Build.ArtifactStagingDirectory)/app.exe',但未找到....

Starting: Github release
==============================================================================
Task         : GitHub Release
Description  : Create, edit, or delete a GitHub release
Version      : 1.160.2
Author       : Microsoft Corporation
Help         : https://aka.ms/AA5vv5o
==============================================================================
b1a3412a-0bb2-48a8-8dfc-bc2109012f38 exists true
Computing changes made in this release...
Fetching the latest non-draft release...
Found the latest non-draft release
Fetching the list of commits since the last published release...
Found the list of changes.
Changes computed successfully.
Release notes file: /home/vsts/work/1/s is a directory and not a file.
Fetching the release for tag: v0.0.28
##[warning]No existing release was found to edit. Creating one with the tag: v0.0.28
Creating a release for tag: v0.0.28
Uploading assets...
Searching for file(s) matching ''/home/vsts/work/1/a/app.exe''.
No files found matching ''/home/vsts/work/1/a/app.exe''. Nothing to upload.
All assets uploaded successfully.
Release created successfully at https://github.com/app/desktop/releases/tag/v0.0.28
Finishing: Github release

关于我在这里做错什么的任何想法>?

1 个答案:

答案 0 :(得分:2)

尝试在YAML中删除此行中的单引号

assets: |
         '$(Build.ArtifactStagingDirectory)/app.exe'

似乎用单引号引起来了解释。

Uploading assets...
Searching for file(s) matching ''/home/vsts/work/1/a/app.exe''

当您使用| |时,我在其他Azure DevOps任务上也看到了这一点。多行格式。