Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot upload assets using multiple minimatch patterns #34

Closed
heaths opened this issue Oct 23, 2018 · 6 comments
Closed

Cannot upload assets using multiple minimatch patterns #34

heaths opened this issue Oct 23, 2018 · 6 comments
Labels
bug 🐛 Something isn't working

Comments

@heaths
Copy link
Contributor

heaths commented Oct 23, 2018

Bug Report

Describe the bug
When using multiple minimatch patterns like most other tasks, no assets are uploaded. E.g.

  - task: marcelo-formentao.github-tools.github-release-publish-task.GitHubReleasePublish@0
    inputs:
      githubEndpoint: ***
      githubReleaseAsset: |
        $(Build.ArtifactStagingDirectory)\bin\$(BuildConfiguration)\*.exe
        $(Build.ArtifactStagingDirectory)\bin\$(BuildConfiguration)\*.zip
      githubReleaseDraft: false
      githubReleaseTitle: v$(CloudBuildNumber)
      githubRepository: heaths/Caffeine
      githubTag: v$(BuildVersionSimple)

To Reproduce

Define a YAML build def with task like the one above, such that minimatch patterns should discover multiple artifacts.

2018-10-23T15:36:09.7501793Z ##[debug]Evaluating condition for step: 'Publish build artifacts to GitHub'
2018-10-23T15:36:09.7502328Z ##[debug]Evaluating: SucceededNode()
2018-10-23T15:36:09.7502444Z ##[debug]Evaluating SucceededNode:
2018-10-23T15:36:09.7502675Z ##[debug]=> True
2018-10-23T15:36:09.7502884Z ##[debug]Result: True
2018-10-23T15:36:09.7503063Z ##[section]Starting: Publish build artifacts to GitHub
2018-10-23T15:36:09.7507707Z ==============================================================================
2018-10-23T15:36:09.7507822Z Task         : Create or Modify GitHub Release
2018-10-23T15:36:09.7507886Z Description  : Create or modify GitHub Release, allowing to upload assets, check manifest content and more.
2018-10-23T15:36:09.7507948Z Version      : 0.5.0
2018-10-23T15:36:09.7508039Z Author       : Marcelo Formentão
2018-10-23T15:36:09.7508104Z Help         : [More Information](https://github.com/marceloavf/github-tools-vsts) (Version 0.5.0).
2018-10-23T15:36:09.7508190Z ==============================================================================
2018-10-23T15:36:10.2228912Z ##[debug]agent.TempDirectory=D:\a\_temp
2018-10-23T15:36:10.2252972Z ##[debug]loading inputs and endpoints
2018-10-23T15:36:10.2263630Z ##[debug]loading ENDPOINT_AUTH_af6d67d6-e46f-4f8d-830f-32a041e29412
2018-10-23T15:36:10.2278215Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_af6d67d6-e46f-4f8d-830f-32a041e29412_ACCESSTOKEN
2018-10-23T15:36:10.2282187Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2018-10-23T15:36:10.2284145Z ##[debug]loading ENDPOINT_AUTH_SCHEME_af6d67d6-e46f-4f8d-830f-32a041e29412
2018-10-23T15:36:10.2286959Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2018-10-23T15:36:10.2289193Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2018-10-23T15:36:10.2292113Z ##[debug]loading INPUT_GITHUBDELETEEMPTYTAG
2018-10-23T15:36:10.2293782Z ##[debug]loading INPUT_GITHUBEDITRELEASE
2018-10-23T15:36:10.2295978Z ##[debug]loading INPUT_GITHUBENDPOINT
2018-10-23T15:36:10.2298409Z ##[debug]loading INPUT_GITHUBIGNOREASSETS
2018-10-23T15:36:10.2300360Z ##[debug]loading INPUT_GITHUBRELEASEASSET
2018-10-23T15:36:10.2302013Z ##[debug]loading INPUT_GITHUBRELEASEDRAFT
2018-10-23T15:36:10.2304293Z ##[debug]loading INPUT_GITHUBRELEASEPRERELEASE
2018-10-23T15:36:10.2306151Z ##[debug]loading INPUT_GITHUBRELEASETITLE
2018-10-23T15:36:10.2308268Z ##[debug]loading INPUT_GITHUBREPOSITORY
2018-10-23T15:36:10.2310631Z ##[debug]loading INPUT_GITHUBREUSEDRAFTONLY
2018-10-23T15:36:10.2312618Z ##[debug]loading INPUT_GITHUBREUSERELEASE
2018-10-23T15:36:10.2314477Z ##[debug]loading INPUT_GITHUBSKIPDUPLICATEDASSETS
2018-10-23T15:36:10.2316262Z ##[debug]loading INPUT_GITHUBTAG
2018-10-23T15:36:10.2319045Z ##[debug]loading INPUT_MANIFESTJSON
2018-10-23T15:36:10.2321098Z ##[debug]loading INPUT_MANUALLYSETREPOSITORY
2018-10-23T15:36:10.2328723Z ##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
2018-10-23T15:36:10.2334249Z ##[debug]loaded 22
2018-10-23T15:36:10.2392770Z ##[debug]Agent.ProxyUrl=undefined
2018-10-23T15:36:10.2394359Z ##[debug]Agent.CAInfo=undefined
2018-10-23T15:36:10.2394686Z ##[debug]Agent.ClientCert=undefined
2018-10-23T15:36:10.2395232Z ##[debug]githubEndpoint=af6d67d6-e46f-4f8d-830f-32a041e29412
2018-10-23T15:36:10.2413879Z af6d67d6-e46f-4f8d-830f-32a041e29412 exists true
2018-10-23T15:36:10.2414154Z ##[debug]af6d67d6-e46f-4f8d-830f-32a041e29412 exists true
2018-10-23T15:36:10.2416672Z ##[debug]githubRepository=heaths/Caffeine
2018-10-23T15:36:10.2418640Z ##[debug]githubRepository=heaths/Caffeine
2018-10-23T15:36:10.2418933Z ##[debug]githubOwner=null
2018-10-23T15:36:10.2452247Z ##[debug]githubRepositoryName=null
2018-10-23T15:36:10.2452746Z ##[debug]githubTag=v
2018-10-23T15:36:10.2452969Z ##[debug]githubReleaseTitle=v
2018-10-23T15:36:10.2453183Z ##[debug]githubReleaseNotes=null
2018-10-23T15:36:10.2453362Z ##[debug]githubApiUrl=null
2018-10-23T15:36:10.2453548Z ##[debug]githubTargetCommitsh=null
2018-10-23T15:36:10.2453727Z ##[debug]manuallySetRepository=false
2018-10-23T15:36:10.2455692Z ##[debug]githubReleaseDraft=false
2018-10-23T15:36:10.2456051Z ##[debug]githubReleasePrerelease=false
2018-10-23T15:36:10.2456700Z ##[debug]githubReuseRelease=true
2018-10-23T15:36:10.2457273Z ##[debug]githubReuseDraftOnly=true
2018-10-23T15:36:10.2457609Z ##[debug]githubSkipDuplicatedAssets=false
2018-10-23T15:36:10.2457823Z ##[debug]githubIgnoreAssets=false
2018-10-23T15:36:10.2458027Z ##[debug]githubEditRelease=false
2018-10-23T15:36:10.2458211Z ##[debug]githubDeleteEmptyTag=false
2018-10-23T15:36:10.2458419Z ##[debug]manifestJson=D:\a\1\s
2018-10-23T15:36:10.2458640Z ##[debug]githubReleaseAsset=D:\a\1\a\bin\Release\*.exe
D:\a\1\a\bin\Release\*.zip
2018-10-23T15:36:10.4571831Z Creating release
2018-10-23T15:36:11.3555968Z Release created successfully at
2018-10-23T15:36:11.3557769Z       https://github.com/heaths/Caffeine/releases/tag/v
2018-10-23T15:36:11.3577132Z Finish - Release URL: https://api.github.com/repos/heaths/Caffeine/releases/13611195
2018-10-23T15:36:11.3665042Z ##[section]Finishing: Publish build artifacts to GitHub

Repo: https://github.com/heaths/caffeine
Build: https://dev.azure.com/heaths/public/_build/results?buildId=100&view=logs

Expected behavior
All files matching all minimatch patterns should be used. Ideally, the input control for the task is higher as well, or the documentation for the field at least clarifies that only one line works, but that is certainly not ideal since you'd need multiple tasks to upload multiple artifacts with different patterns.

Enviroment

  • Service: Azure DevOps (formerly VSTS)
  • Agent: Hosted Windows + VS2017
  • OS: Windows Server 2016
  • Node/npm version: unsure (whatever is installed into the vs2017-win2016 VM image)
@marceloavf marceloavf added the bug 🐛 Something isn't working label Oct 23, 2018
@heaths
Copy link
Contributor Author

heaths commented Oct 23, 2018

Looking at the VSTest@2 task source, they use a multiline input type with corresponding code at https://github.com/Microsoft/azure-pipelines-tasks/blob/c35d1e72b74fa72316e3fa35d71a4fad05ce43f2/Tasks/VsTestV2/distributedtest.ts#L101-L115 that seems to support a wider grammar for minimatch patterns than globbing, which is its own benefit but also introduces consistency with built-in tasks.

I don't imagine this would be a breaking change unless globbing and lstat have some slight nuances, but maybe a new major version of the task would be in order? Willing to contribute if you're interested.

@marceloavf
Copy link
Owner

Hey @heaths, first of all thank you for the feedback.

I've never used multi-line folders 😞, code implementation from this repository use glob specification only for a string line and convert all files found into an array.

I used another implementation in my digitalocean-tools-vsts that is almost equal to this example of yours, but I never tested either. would be great to implement it here:

/** Check for one or multiples files into array
* Accept wildcards to look for files
*/
if (githubReleaseAsset && !githubIgnoreAssets) {
githubReleaseAsset = glob.sync(githubReleaseAsset)
}

Code implementation used in digitalocean-tools-vsts

https://github.com/marceloavf/digitalocean-tools-vsts/blob/21925e50e081107fcbd8bb9c3bb91cb83bf20a78/Tasks/DigitalOceanSpacesUpload/utils/utils.ts#L5-L31

I would be very grateful if you could contribute, since I use semantic-release, it would be easy to bump major version for this one.

@heaths
Copy link
Contributor Author

heaths commented Oct 28, 2018

I hope to get to this later today. Any problem with just using the same pattern as other built-in tasks? Consistency improves productivity and reduces errors. Since you document that the tasks supports minimatch patterns, I imagine - as I did - devs would assume it's the same pattern they can use with built-in tasks.

@heaths
Copy link
Contributor Author

heaths commented Oct 28, 2018

PS: I mistakenly pointed out the wrong reference source earlier. Digging in deeper, I see that built-in tasks use https://github.com/Microsoft/azure-pipelines-task-lib/blob/master/node/task.ts#L1412, which does rely on the minimatch library (as does glob) buts adds a bit more processing.

heaths added a commit to heaths/github-tools-vsts that referenced this issue Oct 28, 2018
Resolves marceloavf#34.

Upgraded vsts-task-lib to newer azure-pipelines-task-lib and bumped
the major version of the task since this is a significant new feature
to the API surface.

Signed-off-by: Heath Stewart <[email protected]>
@marceloavf
Copy link
Owner

No problem @heaths, thank you so much for the PR.

I'll release it into our development channel stage to check it out and then make it to production ok.

marceloavf pushed a commit that referenced this issue Oct 28, 2018
BREAKING CHANGE: The assets upload input has been changed to multiLine type.

Resolves #34. Upgraded vsts-task-lib to newer azure-pipelines-task-lib and bumped
the major version of the task since this is a significant new feature to the API surface.
marceloavf added a commit that referenced this issue Oct 28, 2018
<a name="1.0.0"></a>
# [1.0.0](v0.5.0...v1.0.0) (2018-10-28)

### Features

* add support for multiple minimatch patterns ([#36](#36)) ([43e238c](43e238c)), closes [#34](#34)

### BREAKING CHANGES

* The assets upload input has been changed to multiLine type.
@marceloavf
Copy link
Owner

Tested migrating an release task using 0.5.0 to 1.0.0 and the multiLine new type and worked like a charm.

image

image

Thank you again.

heaths added a commit to heaths/Caffeine that referenced this issue Oct 28, 2018
Upgraded GitHubReleasePublish task to version 1 after fixing marceloavf/github-tools-vsts#34
heaths added a commit to heaths/Caffeine that referenced this issue Oct 28, 2018
Upgraded GitHubReleasePublish task to version 1 after fixing marceloavf/github-tools-vsts#34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants