how to fetch git remote url using grgit APIs

189 Views Asked by At

I need to read .git folder having below git remote url within my groovy script using grgit APIs.

url = [email protected]:***/****.git

Can you please help

1

There are 1 best solutions below

0
user3142041 On

I could do as below

import org.ajoberstar.grgit.Grgit

Grgit git = new Grgit()
def gitRoot = project.hasProperty('git.root') ? project.property('git.root') : project.rootProject.projectDir
git = Grgit.open(dir: gitRoot)
System.out.println("git.remote.list().url -->"+git.remote.list().url)