Finally, this post helped me to do away with the crumb problem but still securing Jenkins from CSRF attack.
Solution for no-valid crumb included in the request issue
Basically, we need to first request for crumb with authentication and then issue POST api calls with crumb as a header along with authentication again.
This is how I did it,
curl -v -X GET http://jenkins-url:8080/crumbIssuer/api/json --user <username>:<password>
Response was,
{
"_class":"hudson.security.csrf.DefaultCrumbIssuer",
"crumb":"0db38413bd7ec9e98974f5213f7ead8b",
"crumbRequestField":"Jenkins-Crumb"
}
Then the POST api with above crumb information in it.
curl -X POST http://jenkins-url:8080/job/<job-name>/build --user <username>:<password> -H 'Jenkins-Crumb: 0db38413bd7ec9e98974f5213f7ead8b'
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…