36 lines
1004 B
Python
36 lines
1004 B
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import subprocess
|
|
import os
|
|
import sys
|
|
|
|
site_name = "harbor.svnlan.com"
|
|
app_name = "library/java/disk"
|
|
dep_version = "latest"
|
|
docker_login_name = "admin"
|
|
docker_login_password = "Harbor12345"
|
|
|
|
#执行shell命令
|
|
def docker_cmd(cmd):
|
|
return_code = subprocess.call(cmd, shell=True)
|
|
if return_code != 0:
|
|
print "command === %s === error" % (cmd)
|
|
usage()
|
|
return return_code
|
|
|
|
def main():
|
|
global dep_version
|
|
if len(sys.argv) >= 2:
|
|
dep_version = sys.argv[1]
|
|
docker_login = 'docker login -u %s -p %s https://%s' % (docker_login_name, docker_login_password, site_name )
|
|
docker_tag = 'docker build -t %s/%s:%s .' % ( site_name.lower(), app_name.lower(), dep_version)
|
|
docker_push = 'docker push %s/%s:%s' % ( site_name.lower(), app_name.lower(),dep_version)
|
|
|
|
for cmd in [docker_login, docker_tag, docker_push]:
|
|
docker_cmd(cmd)
|
|
print "docker cmd is run..."
|
|
|
|
if __name__ =='__main__':
|
|
main()
|