Skip to content

Commit c5c6f1f

Browse files
authored
Added script to list all repos of an organization
1 parent 32e14e5 commit c5c6f1f

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

api/groovy/ListReposInOrg.groovy

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env groovy
2+
3+
// run with groovy ListReposInOrg -t <personal access token> <org name>
4+
5+
package org.kohsuke.github
6+
7+
@Grab(group='org.kohsuke', module='github-api', version='1.75')
8+
import org.kohsuke.github.GitHub
9+
10+
class ListReposInOrg extends GitHub {
11+
12+
static void main(args) {
13+
14+
def cli = new CliBuilder(usage: 'groovy -t <personal access token> ListReposInOrg.groovy <organization>')
15+
cli.t(longOpt: 'token', 'personal access token', required: false , args: 1 )
16+
17+
OptionAccessor opt = cli.parse(args)
18+
19+
if(opt.arguments().size() != 1) {
20+
cli.usage()
21+
return
22+
}
23+
24+
def org = opt.arguments()[0];
25+
def githubCom
26+
27+
if (opt.t) {
28+
githubCom = GitHub.connectUsingOAuth(opt.t);
29+
} else {
30+
githubCom = GitHub.connect();
31+
}
32+
33+
githubCom.getOrganization(org).listRepositories().each {
34+
println it.getFullName();
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)