1

is there a way to call via code the GUI field "Repository URL" in order to use its value on my Jenkins pipeline?

Jenkins GUI

carlo.zermo
  • 161
  • 1
  • 3
  • 9

2 Answers2

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
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.