How to trigger Jenkins build with parameters from Gitlab webhook?

2,140 views
Skip to first unread message

Mark Allison

unread,
Jan 9, 2017, 6:02:30 AM1/9/17
to Jenkins Users
I have GitLab Community Edition 8.15.2 successfully trigger pipeline projects in Jenkins 2.32.1 using a webhook (but without any parameters). I want the gitlab push to trigger a build with parameters but the parameter value is null when it comes through to Jenkins so the build fails.

The gitlab webhook looks like:

http://jenkins.server:8080/project/project-a/buildWithParameters?MYPARAM=foo


In my pipeline project I echo the parameter value out with

echo "MYPARAM: ${MYPARAM}"


and it's not set to anything. Any ideas on where I've gone wrong?

David Karr

unread,
Jan 9, 2017, 1:41:36 PM1/9/17
to jenkins...@googlegroups.com
I'm not sure if this matters, but did you define that parameter in the
pipeline job?
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-use...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/058c423d-150e-4f17-99ca-aa0dfc2c5d50%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Mark Allison

unread,
Jan 11, 2017, 5:58:45 PM1/11/17
to Jenkins Users
I have defined it outside of the pipeline script in the This project is parameterised section. Is that what you mean? I haven't defined anything in the pipeline itself. Do I need to do it there? If so, what is the syntax?

Thanks

Indra Gunawan (ingunawa)

unread,
Jan 11, 2017, 6:23:09 PM1/11/17
to jenkins...@googlegroups.com

It should be “echo MYPARAM: ${env.MYPARAM}” in pipeline

Mark Allison

unread,
Jan 12, 2017, 3:33:24 AM1/12/17
to Jenkins Users, ingu...@cisco.com
I don't think that's correct because when I invoke the job manually and set parameters, then they show up in the echo command. However, when I use the webhook from gitlab, the parameter values don't show up.
Message has been deleted

vitorarr...@gmail.com

unread,
Mar 27, 2017, 2:55:23 PM3/27/17
to Jenkins Users
Hello There. Any luck with this?
Reply all
Reply to author
Forward
0 new messages