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

Simplify repetitive YAML of 'PublishBuildArtifacts' using default values #7101

Merged
merged 2 commits into from
Apr 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"loc.input.label.PathtoPublish": "Path to publish",
"loc.input.help.PathtoPublish": "The folder or file path to publish. This can be a fully-qualified path or a path relative to the root of the repository. Wildcards are not supported. [Variables](https://go.microsoft.com/fwlink/?LinkID=550988) are supported. Example: $(Build.ArtifactStagingDirectory)",
"loc.input.label.ArtifactName": "Artifact name",
"loc.input.help.ArtifactName": "The name of the artifact to create in the publish location",
"loc.input.help.ArtifactName": "The name of the artifact to create in the publish location.",
"loc.input.label.ArtifactType": "Artifact publish location",
"loc.input.help.ArtifactType": "Choose whether to store the artifact in Visual Studio Team Services/TFS, or to copy it to a file share that must be accessible from the build agent.",
"loc.input.label.TargetPath": "File share path",
Expand Down
10 changes: 5 additions & 5 deletions Tasks/PublishBuildArtifacts/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 133,
"Minor": 135,
"Patch": 0
},
"demands": [],
Expand All @@ -21,24 +21,24 @@
"name": "PathtoPublish",
"type": "filePath",
"label": "Path to publish",
"defaultValue": "",
"defaultValue": "$(Build.ArtifactStagingDirectory)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all tasks will output to the artifact staging directory, so having a default that may not work is not a good idea. It is better to leave it empty since default of $(System.workingdirectory) is more likely to work for most tasks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll propose it's okay to default this value for when artifacts are in the Build.ArtifactStagingDirectory folder. Then, people only have to change it if they depart from the prescribed pattern. ArchiveFiles does this by defaulting its rootFolderOrFile input to $(Build.BinariesDirectory). When it comes to artifacts, the following tasks default to Build.ArtifactStagingDirectory: DotNetCoreCLI, DownloadBuildArtifacts, AppCenterTest, HelmDeploy, NuGetCommand, and DownloadPackage. So this change would make PublishBuildArtifacts more in harmony with those too. Also, our build templates already default the PublishBuildArtifacts task to use this value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want people to be selective with what they publish to the service, I think it would be good to either make $(Build.ArtifactStagingDirectory) the default path, or to add match patterns to this task. $(Build.ArtifactStagingDirectory) is better if the default match pattern would be **\*.

FWIW, if you publish $(Build.ArtifactStagingDirectory) without copying any files to it, your build succeeds with a warning from the agent: ##[warning]Directory 'D:\a\1\a' is empty. Nothing will be added to build artifact 'drop'.

"required": true,
"helpMarkDown": "The folder or file path to publish. This can be a fully-qualified path or a path relative to the root of the repository. Wildcards are not supported. [Variables](https://go.microsoft.com/fwlink/?LinkID=550988) are supported. Example: $(Build.ArtifactStagingDirectory)"
},
{
"name": "ArtifactName",
"type": "string",
"label": "Artifact name",
"defaultValue": "",
"defaultValue": "drop",
"required": true,
"helpMarkDown": "The name of the artifact to create in the publish location"
"helpMarkDown": "The name of the artifact to create in the publish location."
},
{
"name": "ArtifactType",
"aliases": [ "publishLocation" ],
"type": "pickList",
"label": "Artifact publish location",
"defaultValue": "",
"defaultValue": "Container",
"required": true,
"helpMarkDown": "Choose whether to store the artifact in Visual Studio Team Services/TFS, or to copy it to a file share that must be accessible from the build agent.",
"options": {
Expand Down
8 changes: 4 additions & 4 deletions Tasks/PublishBuildArtifacts/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 133,
"Minor": 135,
"Patch": 0
},
"demands": [],
Expand All @@ -21,15 +21,15 @@
"name": "PathtoPublish",
"type": "filePath",
"label": "ms-resource:loc.input.label.PathtoPublish",
"defaultValue": "",
"defaultValue": "$(Build.ArtifactStagingDirectory)",
"required": true,
"helpMarkDown": "ms-resource:loc.input.help.PathtoPublish"
},
{
"name": "ArtifactName",
"type": "string",
"label": "ms-resource:loc.input.label.ArtifactName",
"defaultValue": "",
"defaultValue": "drop",
"required": true,
"helpMarkDown": "ms-resource:loc.input.help.ArtifactName"
},
Expand All @@ -40,7 +40,7 @@
],
"type": "pickList",
"label": "ms-resource:loc.input.label.ArtifactType",
"defaultValue": "",
"defaultValue": "Container",
"required": true,
"helpMarkDown": "ms-resource:loc.input.help.ArtifactType",
"options": {
Expand Down