You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.0 KiB
35 lines
1.0 KiB
#!/bin/bash |
|
#version=git log --format='%H' -n1 |
|
project_name="hotspot-clear" |
|
version=$(git log --format='%H' -n1) |
|
environment=$(git rev-parse --abbrev-ref HEAD) |
|
hostname="192.168.1.131:8888" |
|
|
|
if [ ! -n "$version" ] ;then |
|
echo "未获取到版本信息" |
|
return |
|
fi |
|
|
|
echo "打包的环境:$environment" |
|
echo "打包版本号:$version" |
|
echo "项目名称:$project_name" |
|
|
|
if [ $environment == "dev" ] ;then |
|
echo "======登录镜像仓库======" |
|
docker login -u admin -p jumai123 192.168.1.131:8888 |
|
fi |
|
|
|
if [ $environment == "master" ] ;then |
|
hostname="harbor.homieyy.com" |
|
echo "======登录镜像仓库======" |
|
docker login -u admin -p 1EeFT5qjpM harbor.homieyy.com |
|
fi |
|
|
|
echo "======build======" |
|
docker build -t $project_name:latest . |
|
echo "======tag=======" |
|
docker tag $project_name:latest $hostname/job/$environment/$project_name:$version |
|
echo "======push=======" |
|
docker push $hostname/job/$environment/$project_name:$version |
|
echo "======delete=====" |
|
docker rmi $project_name:latest $hostname/job/$environment/$project_name:$version
|
|
|