-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathexample_script.py
executable file
·32 lines (26 loc) · 1.48 KB
/
example_script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python
from optparse import OptionParser
args_options = OptionParser()
args_options.add_option("-g", "--group-id", dest="groupid", help="group id")
args_options.add_option("-a", "--artifact-id", dest="artifactid", help="artifact id")
args_options.add_option("-v", "--version", dest="version", help="version of artifact", default="LATEST")
args_options.add_option("-r", "--repository", dest="repository", help="Nexus repository name", default="snapshots")
args_options.add_option("-p", "--packaging", dest="packaging", help="packaging (jar, war, etc.)", default="jar")
args_options.add_option("-s", "--nexus-url", dest="server",
help="nexus server", default="http://repository.sonatype.org")
args_options.add_option("-d", "--debug", action="store_true", dest="debug", help="Enable debugging", default=False)
args_options.add_option("-u", "--user", dest="user", help="username", default="")
args_options.add_option("--password", dest="password", help="HTTP Basic password", default="")
(options, args) = args_options.parse_args()
# an example is worth a thousand words
from nexus_client.nexus import Nexus
if options.user != "" and options.password != "":
client = Nexus(options.server, user=options.user, password=options.password, verbose=True)
else:
client = Nexus(options.server)
client.get_artifact(
group_id=options.groupid,
artifact_id=options.artifactid,
packaging=options.packaging,
version=options.version,
repository=options.repository)