Avoid docker login everytime even it is done before

Signed-off-by: rick <rick@jenkins-zh.cn>
This commit is contained in:
rick
2020-11-18 22:35:08 +08:00
parent f6fea24a75
commit eb503f4051
2 changed files with 13 additions and 2 deletions

View File

@@ -5,6 +5,11 @@ set -o pipefail
tag_for_branch() {
local tag=$1
if [[ "${tag}" == "" ]]; then
tag=$(git branch --show-current)
tag=${tag/\//-}
fi
if [[ "${tag}" == "master" ]]; then
tag="latest"
fi
@@ -19,6 +24,9 @@ docker build -f build/ks-apiserver/Dockerfile -t $REPO/ks-apiserver:$TAG .
docker build -f build/ks-controller-manager/Dockerfile -t $REPO/ks-controller-manager:$TAG .
# Push image to dockerhub, need to support multiple push
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
cat ~/.docker/config.json | grep index.docker.io
if [[ $? != 0 ]]; then
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
fi
docker push $REPO/ks-apiserver:$TAG
docker push $REPO/ks-controller-manager:$TAG

View File

@@ -1,4 +1,7 @@
#!/bin/bash
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
cat ~/.docker/config.json | grep index.docker.io
if [[ $? != 0 ]]; then
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
fi
docker push kubespheredev/ks-apiserver:latest