Mr.DevEng
Mr.DevEng

Reputation: 2431

SVN post commit hook is giving 403 forbidden while triggering Jenkins job

I am trying to implement my post commit hook from my SVN repo to trigger one Jenkins job for my spring boot microservice deployment. But when I am committing code change, its committing to SVN repository. But its not triggering Jenkins job and giving error like 403 forbidden and it showing post commit hook failed with error code 8 on dialog box,

I am getting error like the following:

enter image description here

My post commit hook file post-commit like the following (I was removed post-commit.tmpl and created new post-commit file and added content here):

enter image description here

And My Jenkins freestyle jobs like the following:

enter image description here

enter image description here

NB: Code change are successfully committing to SVN repository. Problem is when triggering the Jenkins job.

Have I made a mistake in any of my implementation?

Upvotes: 2

Views: 490

Answers (2)

Alex O
Alex O

Reputation: 8164

This is probably a permission issue. See the subversion plugin documentation:

For this to work, your Jenkins has to allow anonymous read access (specifically, "Job > Read" access) to the system. If access control to your Jenkins is more restrictive, you may need to specify the username and password, depending on how your authentication is configured.

Upvotes: 0

K. B.
K. B.

Reputation: 3690

Maybe you hit the CSRF (Cross Site Request Forgery) Jenkins protection.

CSRF protection uses a token (called crumb in Jenkins) that is created by Jenkins and sent to the user. Any form submissions or similar action resulting in modifications, like triggering builds or changing configuration, requires that the crumb be provided.

Requests sent using the POST method are subject to CSRF protection in Jenkins >and generally need to provide a crumb.

If you have administrator permissions, you can configure CSRF Protection through Manage Jenkins » Configure Global Security » CSRF Protection.

If you authenticate your API calls with a username and a user API token then a crumb is not required from Jenkins 2.96. So you can:

  1. Generate API token from Jenkins (admin permissions needed).
  2. Then use the API token instead of password for your calls.

Reference:
https://www.jenkins.io/doc/book/security/csrf-protection/
Jenkins : Error 403 No valid crumb was included in the request : From TFS
https://support.cloudbees.com/hc/en-us/articles/219257077-CSRF-Protection-Explained
Jenkins: 403 No valid crumb was included in the request

Upvotes: 1

Related Questions