
How to trigger Jenkins Job with Bash Script?
Hello everyone after a long time :)
I haven’t been able to write an article for a long time because I’m very busy. I thought and said to myself that I should write something. So Now, I decided to write small acticle. :)
How to trigger Jenkins Job with Bash Script?
I think everyone know the Jenkins. We have been used it in CI/CD processes for a long time. But how to use for it with bash script? Now, we are going to learn it.
Jenkins has API support. We are going to make to requests with curl after we will have csrftoken. Now, we can taking to step by step.
First step, We will API token generate for user then we will use it for connect session. Now, Login to Jenkins and go to your profile page. Then click the configure on button. You will see the same as the picture below. You should generate token from API token section and you don’t forget token (copy) because we will use the token in bash script.

Second step, we can start writing bash script. You can write script code as below. You have to complete in the special fields there then you should run code. You can send the parameters in the job with -F. You can also see line 20.
If it’s success then you will see trigger job on Jenkins but If you see “CRUMB ERROR” then you check in script. You must make sure all custom fields correct.