mirror of
https://github.com/goharbor/harbor.git
synced 2024-10-31 23:59:32 +01:00
Add docker-hub login in build package (#13528)
Signed-off-by: danfengliu <danfengl@vmware.com>
This commit is contained in:
parent
341b8f0c7e
commit
490042d8d9
@ -34,20 +34,18 @@ class DockerAPI(object):
|
||||
_tag = "latest"
|
||||
if expected_error_message is "":
|
||||
expected_error_message = None
|
||||
caught_err = False
|
||||
ret = ""
|
||||
try:
|
||||
self.DCLIENT.pull(r'{}:{}'.format(image, _tag))
|
||||
ret = self.DCLIENT.pull(r'{}:{}'.format(image, _tag))
|
||||
return ret
|
||||
except Exception as err:
|
||||
caught_err = True
|
||||
if expected_error_message is not None:
|
||||
print( "docker image pull error:", str(err))
|
||||
if str(err).lower().find(expected_error_message.lower()) < 0:
|
||||
raise Exception(r"Pull image: Return message {} is not as expected {}".format(str(err), expected_error_message))
|
||||
else:
|
||||
raise Exception(r" Docker pull image {} failed, error is [{}]".format (image, err.message))
|
||||
if caught_err == False:
|
||||
else:
|
||||
if expected_error_message is not None:
|
||||
if str(ret).lower().find(expected_error_message.lower()) < 0:
|
||||
raise Exception(r" Failed to catch error [{}] when pull image {}, return message: {}".format (expected_error_message, image, str(ret)))
|
||||
|
@ -20,7 +20,8 @@ def push_image_to_project(project_name, registry, username, password, image, tag
|
||||
time.sleep(2)
|
||||
if expected_login_error_message != None:
|
||||
return
|
||||
_docker_api.docker_image_pull(image, tag = tag)
|
||||
ret = _docker_api.docker_image_pull(image, tag = tag)
|
||||
print("docker image pull ret:", ret)
|
||||
time.sleep(2)
|
||||
|
||||
new_harbor_registry, new_tag = _docker_api.docker_image_tag(r'{}:{}'.format(image, tag), r'{}/{}/{}'.format(registry, project_name, image))
|
||||
@ -147,4 +148,4 @@ class Repository(base.Base):
|
||||
|
||||
base._assert_status_code(expect_status_code, status_code)
|
||||
base._assert_status_code(200, status_code)
|
||||
return data
|
||||
return data
|
||||
|
@ -55,7 +55,9 @@ Package Harbor Offline
|
||||
[Arguments] ${with_notary}=true ${with_clair}=true ${with_migrator}=true ${with_chartmuseum}=true
|
||||
Log To Console \nStart Docker Daemon
|
||||
Start Docker Daemon Locally
|
||||
docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_PASSWORD
|
||||
${rc} ${output}= Run And Return Rc And Output docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_PASSWORD
|
||||
Log ${rc}
|
||||
Log ${output}
|
||||
Log To Console \n\nmake package_offline BASEIMAGETAG=%{Harbor_Build_Base_Tag} NPM_REGISTRY=%{NPM_REGISTRY} VERSIONTAG=%{Harbor_Assets_Version} PKGVERSIONTAG=%{Harbor_Package_Version} NOTARYFLAG=${with_notary} CLAIRFLAG=${with_clair} MIGRATORFLAG=${with_migrator} CHARTFLAG=${with_chartmuseum} HTTPPROXY=
|
||||
${rc} ${output}= Run And Return Rc And Output make package_offline BASEIMAGETAG=%{Harbor_Build_Base_Tag} NPM_REGISTRY=%{NPM_REGISTRY} VERSIONTAG=%{Harbor_Assets_Version} PKGVERSIONTAG=%{Harbor_Package_Version} NOTARYFLAG=${with_notary} CLAIRFLAG=${with_clair} MIGRATORFLAG=${with_migrator} CHARTFLAG=${with_chartmuseum} HTTPPROXY=
|
||||
Log To Console ${rc}
|
||||
@ -66,7 +68,9 @@ Package Harbor Online
|
||||
[Arguments] ${with_notary}=true ${with_clair}=true ${with_migrator}=false ${with_chartmuseum}=true
|
||||
Log To Console \nStart Docker Daemon
|
||||
Start Docker Daemon Locally
|
||||
docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_PASSWORD
|
||||
${rc} ${output}= Run And Return Rc And Output docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_PASSWORD
|
||||
Log ${rc}
|
||||
Log ${output}
|
||||
Log To Console \nmake package_online VERSIONTAG=%{Harbor_Assets_Version} PKGVERSIONTAG=%{Harbor_Package_Version} NOTARYFLAG=${with_notary} CLAIRFLAG=${with_clair} MIGRATORFLAG=${with_migrator} CHARTFLAG=${with_chartmuseum} HTTPPROXY=
|
||||
${rc} ${output}= Run And Return Rc And Output make package_online VERSIONTAG=%{Harbor_Assets_Version} PKGVERSIONTAG=%{Harbor_Package_Version} NOTARYFLAG=${with_notary} CLAIRFLAG=${with_clair} MIGRATORFLAG=${with_migrator} CHARTFLAG=${with_chartmuseum} HTTPPROXY=
|
||||
Log ${rc}
|
||||
|
Loading…
Reference in New Issue
Block a user