VS Code Jenkinsfile docker.withRegistry {...} brackets do not match error

Viewed 1563

I'm writing a jenkinsfile in VS Code and when I use docker.withRegistry("some.registry"){...} I get a brackets do not match error inside of code. It parses fine inside jenkins, but this error inside of code is bugging me a lot. As soon as anything goes between the {} I get the error show up on the closing bracket.

Even copying in directly from the documentation from the Jenkins website gives the same issue.

Any ideas?

3 Answers

Oddly enough I had the same issue when I was using a private registry with a credentials ID, when I switched away from single quotes to double quotes the error went away, you could give that a try?

docker.withRegistry("https://some.registry", "docker-registry-creds") { 
    def customImage = docker.build("my-image:${env.GIT_COMMIT}")
}

As mentioned by Carl here, this happens when you have the following 2 characters, in this particular order, in a single quoted string:

'/*'

So strings like the following will trigger the error:

  • '**/*.xml'
  • '/some/path/to/random/files/*.py'

Just use double quote in those strings, and all the errors will go away:

  • "**/*.xml"
  • "/some/path/to/random/files/*.py"

I noticed this also occurs when using a parenthesis in single quotes. Again fixed by putting these in double quotes. e.g.:

def something= somethingelse.tokenize('(')

can be replaced by

def something= somethingelse.tokenize("(")
Related