Getting git tags as parameter from Jenkins pipeline with “Git Parameter” plugin


When I am using Jenkins pipeline, I discover that there is no Source Code Management section like normal project, so seems like there is no GUI way to allow me to define parameter to choice a particular git tag to build from.


The solution is to use “Git Parameter” plugin


In pipeline section create a script:

Script contain as follow:

According to the documentation of “Git Parameter”, the first part defined parameter called “git_tag” and would pull all tag from the git repository defined in checkout action in build stage with the “userRemoteConfigs”.

Afterwards, we have 2 build job task to reuse the git_tag parameter by calling “gitParameter(name: ‘git_tag’, value: “${paraams.git_tag}”)”.


As I am not familiar with the Jenkins pipeline staged build, this setup make the pipeline itself occupy a Jenkins worker and the build job would spawn another task occupying another Jenkins worker, and the pipeline occupied worker would be released only when all stage completed.

I hope I would have time to follow up with that.


Hope this quick tips help someone to build pipeline that need to pull a choice list of git tags as parameter to choose from.