dave-hagedorn / jenkins-runner

VS Code plugin to develop and run Jenkins Pipeline scripts
MIT License
30 stars 8 forks source link

No valid crumb was included in the request #16

Closed g1ps closed 4 years ago

g1ps commented 4 years ago

This seems broken, now. It was working prior to recent updates to VSCode and Jenkins. Turning CSRF protection on an off made no difference. Using useCrumbIssuer true or false made no difference. Password removed, re-entered, removed, re-entered, etc. No difference. Builds that used to work now don't.

[2019-11-20 13:20:50.139] [Jenkins] [info] Creating Jenkins instance @url=http://XXXXXXXXXXX:8080, with user=XXXXXX, password=****
[2019-11-20 13:20:50.140] [Jenkins] [info] Creating pipeline build using job vscode @http://XXXXXXXXXXX:8080, with params [object Object]
[2019-11-20 13:20:50.140] [Jenkins] [info] Fetching remote XML config for job vscode @http://XXXXXXXXXXX:8080
[2019-11-20 13:20:50.288] [Jenkins] [info] Parsing and updating XML with new pipeline script
[2019-11-20 13:20:50.293] [Jenkins] [info] Pushing remote XML config for job vscode @http://XXXXXXXXXXX:8080
[2019-11-20 13:20:50.604] [Jenkins] [error] Error starting job vscode #undefined @http://XXXXXXXXXXX:8080}: Error: jenkins: job.config: forbidden
[2019-11-20 13:20:50.604] [Jenkins] [error] <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 403 No valid crumb was included in the request</title>
</head>
<body><h2>HTTP ERROR 403</h2>
<p>Problem accessing /job/vscode/config.xml. Reason:
<pre>    No valid crumb was included in the request</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.z-SNAPSHOT</a><hr/>

</body>
</html>

[2019-11-20 13:20:53.580] [Jenkins] [info] Stopping job vscode #undefined @http://XXXXXXXXXXX:8080
[2019-11-20 13:20:53.581] [Jenkins] [info] Stopping job vscode #undefined @http://XXXXXXXXXXX:8080

Thanks.

eugeneaik commented 4 years ago

I faced same issue today (

[2019-11-26 12:30:53.090] [Jenkins] [info] Creating Jenkins instance @url=https://XXXXXX.com, with user=XXXXXX, password=****
[2019-11-26 12:30:53.090] [Jenkins] [info] Creating pipeline build using job Common/Pipeline-Release-Candidate @https://XXXXXX.com, with params [object Object]
[2019-11-26 12:30:53.091] [Jenkins] [info] Fetching remote XML config for job Common/Pipeline-Release-Candidate @https://XXXXXX.com
[2019-11-26 12:30:53.795] [Jenkins] [info] Parsing and updating XML with new pipeline script
[2019-11-26 12:30:53.824] [Jenkins] [info] Pushing remote XML config for job Common/Pipeline-Release-Candidate @https://XXXXXX.com
[2019-11-26 12:30:54.895] [Jenkins] [error] Error starting job Common/Pipeline-Release-Candidate #undefined @https://XXXXXX.com}: Error: jenkins: job.config: forbidden
[2019-11-26 12:30:54.895] [Jenkins] [error] <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 403 No valid crumb was included in the request</title>
</head>
<body><h2>HTTP ERROR 403</h2>
<p>Problem accessing /job/XXXX/job/XXXXXXXXXXXXXX/config.xml. Reason:
<pre>    No valid crumb was included in the request</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.z-SNAPSHOT</a><hr/>

</body>
</html>

[2019-11-26 12:31:25.669] [Jenkins] [info] Stopping job XXXXX #undefined @https://XXXXXX.com
[2019-11-26 12:31:25.669] [Jenkins] [info] Stopping job XXXXX #undefined @https://XXXXXX.com

Jenkins version is "Jenkins ver. 2.190.2"

typ431127 commented 4 years ago

我也是同样的问题......

ggao commented 4 years ago

I am seeing the same issue

g1ps commented 4 years ago

How do I revert this to an eaerlier version? It was useful and I set myself up to use it and now it's a pain that it's broken.

What effort is being made to fix it? What else can we provide to help?

Thanks.

g1ps commented 4 years ago

Are you going to help your users or shall we just dump this thing and move on? At least let us know, please.

Thanks.

briceo commented 4 years ago

@g1ps I took a shot at fixing this, and it appears the issue is just a bug in the version of the Jenkins npm module that is being used. I ran an npm update jenkins and it fixed the issue (it updated to version 0.27).

Granted, I had to build a new version of the extension locally, and it then install it. But after that, the problem went away, and I could use this extension again as it fixed the crumbIssuer error.

g1ps commented 4 years ago

@g1ps I took a shot at fixing this, and it appears the issue is just a bug in the version of the Jenkins npm module that is being used. I ran an npm update jenkins and it fixed the issue (it updated to version 0.27).

Well done, thanks @briceo. A pull request would be great, so we can get it published. I don't know what's required in order to rebuild it myself. I'll try and find out if I have time but as things are, it's probably unlikely. Any pointers would be appreciated.

Cheers.

briceo commented 4 years ago

@g1ps I am not able to make a PR for this issue. It looks like the owner has this repository locked down so that nobody can contribute fixes.

Basically, I just updated package.json to depend on version 0.27.0 (instead of version 0.23.0) of the jenkins npm module (only relavent section shown below).

    "version": "1.2.3",
<snip>
    "dependencies": {
        "ajv": "6.9.1",
        "jenkins": "0.27.0",
        "object-assign-deep": "0.4.0",
        "xml2js": "0.4.19"
    }

To build this extension: Make sure you have node.js installed (I used version 12.15.0) switch to the root of the checked out repo from a terminal and run the following commands: npm install (this installs all of the packaged dependencies) npm install -g vsce (install the utility to build the VSCode extension) vsce package (this builds the updated vsix package that you can then install from within VSCode Extension section) NOTE: I bumped the extension version in package.json from 1.2.2 to 1.2.3 just so that I would remember (hopefully) that I had a custom build of this extension.

Once the new vsix has been build, you can install it from within VSCode. Go to Extensions -> click the 3 dots in the upper right corner of the extension tab -> Install from VSIX (using the file you just built above).

g1ps commented 4 years ago

Hi @briceo,

Oh dear. Not great. Many thanks for the details. I still haven't found time to try but I appreciate knowing. I just wanted to let you know that I had received your reply.

Cheers.

atiniir commented 4 years ago

i've submitted https://github.com/dave-hagedorn/jenkins-runner/pull/20 for this. hopefully, it'll get picked up and released soon.

many thanks @briceo for the steps to build the plugin!

g1ps commented 4 years ago

I have now upgraded and rebuilt the plugin and it's working again. Thanks again @briceo for the explanation. There were some tense moments at first when it still wasn't working after installing it with CSRF Protection on or off on the Jenkins server but after re-starting VSCode it now works with CSRF protection on and the Default Crumb Issuer selected.

dave-hagedorn commented 4 years ago

@g1ps I am not able to make a PR for this issue. It looks like the owner has this repository locked down so that nobody can contribute fixes.

Basically, I just updated package.json to depend on version 0.27.0 (instead of version 0.23.0) of the jenkins npm module (only relavent section shown below).

    "version": "1.2.3",
<snip>
    "dependencies": {
        "ajv": "6.9.1",
        "jenkins": "0.27.0",
        "object-assign-deep": "0.4.0",
        "xml2js": "0.4.19"
    }

To build this extension: Make sure you have node.js installed (I used version 12.15.0) switch to the root of the checked out repo from a terminal and run the following commands: npm install (this installs all of the packaged dependencies) npm install -g vsce (install the utility to build the VSCode extension) vsce package (this builds the updated vsix package that you can then install from within VSCode Extension section) NOTE: I bumped the extension version in package.json from 1.2.2 to 1.2.3 just so that I would remember (hopefully) that I had a custom build of this extension.

Once the new vsix has been build, you can install it from within VSCode. Go to Extensions -> click the 3 dots in the upper right corner of the extension tab -> Install from VSIX (using the file you just built above).

@briceo - can you show the error you got when trying to make a PR? I'm not seeing this on my end but want to make sure others can create PRs. Thanks.

briceo commented 4 years ago

@dave-hagedorn , I believe the error was relating to the ability to push a branch to remote origin. I could commit the change locally, but was not able to push the branch to GitHub (due to permission issues). Once the branch was on the remote, I could have created the PR though (at least it appears that I could).

EDIT The err of my ways was that I was trying to create a branch in your repo and issue the PR that way. I , for whatever reason, completely ignored the fact that I should have forked the repo, and then made a PR from my fork to your repo. I guess that happens when I'm distracted. Thanks for getting the fix in.

dave-hagedorn commented 4 years ago

Ah - thanks for the update! Thanks again @atiniir for the fix.