0

I have a webook url http://jenskinsserver/gogs-webhook/?job=build which will trigger the jenkins job on any event from gogs.

Now i want to trigger a parameterized job and i want the param to be sent via webhook url. How to add params in gogs webhook url?

Vignesh P
  • 9
  • 2
  • 8

1 Answers1

0

You can simply add a Build Remote Trigger for this to happen. Go toBuild Triggers => Trigger builds remotely (e.g., from scripts) and set the API Token.

You have to configure the General => This project is parameterized and choose whatever you like from the parameters available.

Now in the url, http://jenskinsserver/gogs-webhook/buildWithParameters?token=<api token provided>&param1=value1&param2=value2 provide params like this and access them by using $param1, $param2 in the scripts.

SV Madhava Reddy
  • 1,858
  • 2
  • 15
  • 33
  • i have not used API token can u provide any link for refernce. API Token is any string that we provide in jenkins and webhook? – Vignesh P Feb 15 '18 at 11:09
  • API token is kinda secret that you have to provide. You can simply [use this website](http://www.thebitmill.com/tools/password.html) to generate `without punctuation` random string and paste it there. – SV Madhava Reddy Feb 15 '18 at 11:19
  • 'No valid crumb was included in the request' Getting 403 error – Vignesh P Feb 15 '18 at 11:29
  • Can you post your url once?? – SV Madhava Reddy Feb 15 '18 at 12:29
  • my webhook url will look like this http://172.28.105.1:8082/gogs-webhook/buildWithParameters?token=I5kzHWJgdb&Project=logging – Vignesh P Feb 15 '18 at 12:43
  • `Use the following URL to trigger build remotely: JENKINS_URL/view/Development%20Workflow/job/spock-development/build?token=TOKEN_NAME or /buildWithParameters?token=TOKEN_NAME Optionally append &cause=Cause+Text to provide text that will be included in the recorded build cause.` I do think you read this. Please access url like this. – SV Madhava Reddy Feb 15 '18 at 12:46
  • '/view/Development%20Workflow/job/spock-development/' this part should be as it is? URL: http://server:port/view/Development%20Workflow/job/spock-development/build?token=I5kzHWJgdb – Vignesh P Feb 15 '18 at 13:04
  • i am sry `/view/` is optional and my jenkins specific and final url in your case is like `JENKINS_URL/job//buildWithParameters?token=TOKEN_NAME&Project=logging` – SV Madhava Reddy Feb 15 '18 at 13:39