question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

String does not match the pattern of "^PowerShell@2$".

See original GitHub issue

We have the following task in azure-pipelines.yaml file.

    - task: PublishBuildArtifacts@1
      condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
      displayName: 'Publish Build Artifacts'

The below false positive error will be shown on the PublishBuildArtifacts@1 line.

Publish build artifacts to Azure Pipelines or a Windows file share
String does not match the pattern of "^PowerShell@2$".
Peek Problem (Alt+F8)
No quick fixes available

See related issue.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
evidolobcommented, Oct 26, 2020

@sheeeng As for Azure Pipelines it is better to use https://marketplace.visualstudio.com/items?itemName=ms-azure-devops.azure-pipelines as it has build in language server specific for azure-pipelines.yaml and that server has support of ignoreCase fields.

2reactions
evidolobcommented, Oct 26, 2020

@JPinkney @gorkem I done investigation around this issue, the problem in schema itself, it is used ignoreCase field for some object fields. I cannot find any mentions of ignoreCase in JSON Schema spec, across schema it has different values, like key, all, value. json-language-server also doesn’t have support of this: Screenshot 2020-10-26 at 11 31 39

Schema used for that JSON is https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/master/service-schema.json As you can see it has exactly the same error.

And error happened because object with PublishBuildArtifacts@1 defined as:

        {
          "properties": {
            "task": {
              "description": "Publish build artifacts\n\nPublish build artifacts to Azure Pipelines or a Windows file share",
              "ignoreCase": "value",
              "pattern": "^PublishBuildArtifacts@1$"
            },
            "inputs": {
              "description": "Publish build artifacts inputs",
              "properties": {
                "PathtoPublish": {
                  "type": "string",
                  "description": "Path to publish",
                  "ignoreCase": "key"
                },
                "ArtifactName": {
                  "type": "string",
                  "description": "Artifact name",
                  "ignoreCase": "key"
                },
...
              "additionalProperties": false,
              "required": []
            }
          },
          "firstProperty": [
            "task"
          ],
          "required": [
            "task"
          ]
        }

So next yaml doesn’t have error:

---
trigger:
- main

pool:
  vmImage: 'ubuntu-latest'

stages:
- stage: 'BuildStage'
  jobs:
  - job: 'BuildJob'
    pool:
      vmImage: 'ubuntu-latest'
    steps:
    - task: PublishBuildArtifacts@1
      condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
      displayName: 'Publish Build Artifacts'
      inputs:
        PathtoPublish: artifacts
        ArtifactName: artifacts

Need to set pathToPublish -> PathtoPublish and artifactName -> ArtifactName as their names defined in schema.

In the end, I not sure that we need to implement support of ignoreCase, as it is not part of JSON Schema specification. WDYT?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure Pipelines VSTest@2 task fails Intellisense validation ...
Azure Pipelines VSTest@2 task fails Intellisense validation with 'String does not match the pattern of "^@PowerShell@2$". - Visual Studio Feedback.
Read more >
Powershell Select-String -pattern -notMatch - Stack Overflow
Currently I'm stuck with code that use only one -notMatch. And I can't use -Match because there could be 2+ users in the...
Read more >
Select-String - PowerShell - Microsoft Learn
Select-String uses the Pattern parameter to specify HELLO. The CaseSensitive parameter specifies that the case must match only the upper-case pattern.
Read more >
about Comparison Operators - PowerShell | Microsoft Learn
Long description · -like , -ilike , -clike - string matches wildcard pattern · -notlike , -inotlike , -cnotlike - string does not...
Read more >
Where-Object (Microsoft.PowerShell.Core)
Starting in Windows PowerShell 3.0, there are two different ways to ... if the property value does not match a value that includes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found