is there a way to call via code the GUI field "Repository URL" in order to use its value on my Jenkins pipeline?
Asked
Active
Viewed 2,884 times
2 Answers
1
The url of your git repository is part of the scm
object. You can get the url by calling scm.getUserRemoteConfigs()[0].getUrl()
.
The method getUserRemoteConfigs()
will return a list with instances of type UserRemoteConfig
. This class has a method called getUrl() which will return the configured url as a string.
Further information: https://javadoc.jenkins.io/plugin/git/hudson/plugins/git/GitSCM.html

Jns
- 3,189
- 1
- 18
- 23
-
Thank you! This is exactly what I want to do. – carlo.zermo Jun 28 '19 at 23:15
1
You can use GIT_URL environment variable of jenkins. i.e. echo "Git URL is ${GIT_URL}" This will give you the git url used in the current jenkins job.

Rajnikant Jaybhaye
- 41
- 5
-
Thanks a lot to you too. Another perfect answer that fit perfectly with my problem. – carlo.zermo Jun 28 '19 at 23:16