janjoerke / vscode-jenkins-pipeline-linter-connector

MIT License
60 stars 21 forks source link

TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Jenkins-Crumb"] #29

Open dzintars opened 3 years ago

dzintars commented 3 years ago

Wanted to try out this extension, but without no luck.

}
  "jenkins.pipeline.linter.connector.crumbUrl": "https://jenkins.example.com/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,%22:%22,//crumb)",
  "jenkins.pipeline.linter.connector.url": "https://jenkins.example.com/pipeline-model-converter/validate",
  "jenkins.pipeline.linter.connector.user": "vscode-jenkins-pipeline-linter",
  "jenkins.pipeline.linter.connector.pass": "2391d2db4z8fe92307b8b789f57a4328cf",
  "jenkins.pipeline.linter.connector.token": "2391d2db4z8fe92307b8b789f57a4328cf",
  }

I have pretty secure http2 proxy in front of my Jenkins, but i assume that https should work just fine with this extension.

Postman GET https://jenkins.example.com/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,%22:%22,//crumb) initially returns just 500 with:

 <!DOCTYPE html>
<html class="">

<head resURL="/static/4cbb666e" data-rooturl="" data-resurl="/static/4cbb666e" data-extensions-available="true"
    data-unit-test="false" data-imagesurl="/static/4caa677e/images" data-crumb-header="Jenkins-Crumb"
    data-crumb-value="a0f12091a9580ff88e74wwy457jikl092354d4d9515c9b2b16e89e754012a128">

.... the rest of some page

Jenkins logs of Postman error:

2021-01-06 20:34:12.240+0000 [id=6403]  WARNING h.i.i.InstallUncaughtExceptionHandler#handleException: Caught unhandled exception with ID 1e699b43-ad36-4888-847f-7dbd7a3095a2
org.dom4j.InvalidXPathException: Invalid XPath expression: concat(//crumbRequestField,":",//crumb) HTTP/1.1 Unexpected 'HTTP/1.1'

which tells me that Postman somehow automatically appended HTTP/1.1 to the xpath query parameter (not sure why). After manually removing it i get response 200 with:

Jenkins-Crumb:a0f12091a9580ff88e74wwy457jikl092354d4d9515c9b2b16e89e754012a128

Which tells me that my Jenkins instance is healthy.

But the extension still does not work.

I have no way to test http only and i am not sure is it relevant there at all.

Similar issues: https://github.com/janjoerke/vscode-jenkins-pipeline-linter-connector/issues/1 https://github.com/janjoerke/vscode-jenkins-pipeline-linter-connector/issues/2 https://github.com/janjoerke/vscode-jenkins-pipeline-linter-connector/issues/13

P.S Keys are faked. 😃

dzintars commented 3 years ago

I had got it worked only as http and public Jenkins IP address. So there is something to deal with ... proxy, TLS termination, God knows what else.

hengeek commented 3 years ago

Detect Jenkinsfile syntax, output No Jenkinsfile specified

elfprince13 commented 2 years ago

+1

txynidakis commented 2 years ago

+1

kamil-j-kion commented 2 years ago

+1

egomez99 commented 1 year ago

Did anyone get this problem fixed?

Some work around suggest setting up env variables but no luck ...

sapipeti commented 1 year ago

I've got it working by setting the connector.url, connector.user and connector.token only. When you set the connector.tokenyou do not need the connector.pass and connector.crumbUrl.

If you got the following error: Error: unable to verify the first certificate then make sure to set the connector.strictssl to false. Hope it helps.

egomez99 commented 1 year ago

I confirm solution proposed by @sapipeti worked like a charm. Thank You!