# Set git credencial
export GOPATH="/opt/jkwork/workspace/skylar"
export PATH=/usr/local/go1.17.6/bin:$PATH
export GOROOT=/usr/local/go1.17.6
cd $GOPATH/src/${JOB_BASE_NAME}
#alias dep='http_proxy=http://proxy.lfk.demo.cn:3128 https_proxy=http://proxy.lfk.demo.cn:3128 dep'
#alias git='http_proxy=http://proxy.lfk.demo.cn:3128 https_proxy=http://proxy.lfk.demo.cn:3128 git'
#alias go='http_proxy=http://proxy.lfk.demo.cn:3128 https_proxy=http://proxy.lfk.demo.cn:3128 go'
#alias dep='http_proxy=http://static-proxy.g0.demo.cn:3128 https_proxy=http://static-proxy.g0.demo.cn:3128 no_proxy=git-biz.demo.cn dep'
#alias git='http_proxy=http://static-proxy.g0.demo.cn:3128 https_proxy=http://static-proxy.g0.demo.cn:3128 no_proxy=git-biz.demo.cn git'
#alias go='http_proxy=http://static-proxy.g0.demo.cn:3128 https_proxy=http://static-proxy.g0.demo.cn:3128 no_proxy=git-biz.demo.cn go'
export http_proxy=http://static-proxy.g0.demo.cn:3128
export https_proxy=http://static-proxy.g0.demo.cn:3128
export no_proxy=git-biz.demo.cn,harbor.ops.demo.cn,git-open.demo.cn
check_git_daemon=`ps -ef | grep git-credential-cache | egrep -v grep | wc -l`
if [ $check_git_daemon -gt 0 ]
then
killall -q git-credential-cache--daemon
fi
rm -rf $HOME/.git-credential-cache
git config --global --unset credential.helper
git config --global credential.helper 'cache --timeout=600'
cat << EOF > .git.tmp
protocol=https
host=git-biz.demo.cn
username=$m_user
password=$m_passwd
EOF
cat .git.tmp | git credential approve
cat << EOF > .git.tmp
protocol=https
host=git-open.demo.cn
username=$m_user
password=$m_passwd
EOF
cat .git.tmp | git credential approve
#cat "$GIT_SSH_KEY" > .git.key
#chmod 600 .git.key
#export GIT_SSH_COMMAND="ssh -i $GOPATH/src/${JOB_BASE_NAME}/.git.key -o User=git"
#rm -f .git.tmp
export GO111MODULE=on
git config url."https://".insteadOf git://
#go build -o $GOPATH/bin/zeus-da-service internal/main.go
make build
#rm -f ../.git.key
GITVERSION=$(git rev-parse --short HEAD)
DATE=$(date +%m%d)
GITBRANCH=$(echo $GIT_BRANCH | sed 's#origin/##g' | sed 's#/#_#g')
VERSION=${DATE}.${GITBRANCH}_${GITVERSION}.${BUILD_ID}
DESC_VERSION=${VERSION}
echo ${VERSION}
#cd docker/${JOB_BASE_NAME}
#IMAGE=harbor.ops.demo.cn/skylar/${JOB_BASE_NAME}:${VERSION}
#docker build -t $IMAGE .
#docker push $IMAGE
id
cd arkbuild
unset http_proxy
unset https_proxy
planth build -t ${DESC_VERSION} -p --from "harbor.ops.demo.cn/library/centos:8.4.2105-2022-03-25"
