===============================================
2020/11/30_第1次修改 ccb_warlock
===============================================
本次示例就是选择搭建了私有的harbor,并将修改了host使用myharbor.cn。
sudo yum install -y git
cd /opt/source
git clone -b dev <git地址>
mkdir -p /opt/publish/abc/published
mkdir -p /opt/build/abc cd /opt/build/abc vi build.sh
# 将下面的内容保存到build.sh中。
#!/bin/bash source_dir="/opt/source/abc" publish_dir="/opt/publish/abc/published" echo "==> Begin build project <==========" cd $source_dir sudo git checkout dev commit_id_old=`git rev-parse HEAD` sudo git pull commit_id_current=`git rev-parse HEAD` if [ $commit_id_old = $commit_id_current ];then echo "==> Branch dev has not changed, exit <==========" exit 1 fi sudo rm -rf $publish_dir sudo mkdir -p $publish_dir sudo dotnet publish -o $publish_dir echo "==> End build project <==========" echo "==> Begin build image <==========" # Dockerfile文件放在源码的Server目录下 sudo yes| cp -rf $source_dir/Server/Dockerfile /opt/publish/abc cd /opt/publish/abc # 这里myharbor.cn是私有的harbor,并修改了本地host sudo docker build --rm -t myharbor.cn/abc/abc:latest . sudo docker push myharbor.cn/abc/abc:latest echo "==> End build image <==========" echo "==> Begin deploy stack <==========" cd /opt/docker/compose/abc sudo docker stack rm abc-stack sudo docker stack deploy -c abc-stack.yml abc-stack echo "==> End deploy stack <=========="
三、部署jenkins服务器
3.1 部署jenkins服务器
参考:https://www.cnblogs.com/straycats/p/14033405.html
3.2 配置密钥对
参考:https://www.cnblogs.com/straycats/p/14058205.html
3.3 配置凭据
<明天继续写后面的内容>
3.4 安装jenkins插件Publish Over SSH
3.5 创建jenkins任务
1)点击“新建任务”
2)构建环境,勾选“Add timestamps to the Console Output”
<明天继续写后面的内容>