Jenkins and CodeStream CSRF fix
For some time, I have had the problem with Jenkins, that when I ran my Code Stream pipeline, it gave me the following error
To fix it, I have been running the code below, in the Jenkins “Script Console”
def instance = Jenkins.instance
This has been ok, until my container, running Jenkins, restarted or got updated, and then I got the error again.
Today I finally took the time, to fix it, and it was really simple.
It turns out, that the error is due to using username/password in Code Stream, and not token.
Code Stream supports, username/password, and don’t mention token, anywhere.
So I tried to replace my password, with a token I created, and it worked.
And now I don’t get the errors anymore.
So a heads up. If you are using username/password, then generate a token, and replace your password with it, to be future proof.
You generate a token, by following the steps below.
- Log in to Jenkins.
- Click you name (upper-right corner).
- Click Configure (left-side menu).
- Use “Add new Token” button to generate a new one then name it.
- You must copy the token when you generate it as you cannot view the token afterwards.
- Revoke old tokens when no longer needed.