win 或 linux gitee jenkins Generic Webhook Trigger自动部署 k8s
1 jenkins安装 Generic Webhook Trigger 插件配置jenkins
批量删除dockerImages
jenkins nginx 配置
location /jenkins {
proxy_pass http://yjx-jenkins.com:32001;
sendfile off;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header Access-Control-Allow-Methods *;
add_header Access-Control-Max-Age 3600;
add_header Access-Control-Allow-Credentials true;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers $http_access_control_request_headers;
proxy_max_temp_file_size 0;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_temp_file_write_size 64k;
proxy_http_version 1.1;
proxy_request_buffering off;
proxy_buffering off;
}
}
1 jenkins安装 Generic Webhook Trigger 插件
配置jenkins 根据提交代码到test分支触发构建
然后在 Optional filter 选项卡中填写要过滤的分支名称。 Expression 填写正则 ^(refs/heads/test)$,
Text 可以填写变量 $ref
这样提交代码到test分支即可自动发布jenkins
配置jenkins 根据提交的内容构建服务
如图配置 的token 需要放在gtiee的url里面
http://xxx/generic-webhook-trigger/invoke?token=yjx-service-test2
xxx 是jenkins的url
http://yjx-sho.top:8800/jenkins/generic-webhook-trigger/invoke?token=yjx-service-test2
win 系统构建完后脚本 使用阿里云镜像仓库 并k8s更新部署
set imageNS=yjx-service
set imageName=yjx-test
cd business-service/yjx-test-parent/%imageName%/
set registryusername=*****@qq.com
set registrypasswd=*****
set registryURL=registry.cn-hangzhou.aliyuncs.com
set nextPlatformTags=0.0.1
docker login --username=%registryusername% --password=%registrypasswd% %registryURL%
echo "--------------------------------------------------------------------------------------"
docker build -t %registryURL%/%imageNS%/%imageName%:%nextPlatformTags% .
docker push %registryURL%/%imageNS%/%imageName%:%nextPlatformTags%
docker logout
curl -X PUT -H "Content-Type: application/yaml" -H "Cookie: KuboardUsername=admin; KuboardAccessKey=74cfnbhnpxt7.ybxbif3zspm3nkzjmakdsiyh4dypprz5" -d "{\"kind\":\"deployments\",\"namespace\":\"yjx-service\",\"name\":\"test-svc-deployment\"}" "http://域名:端口号/kuboard-api/cluster/default/kind/CICDApi/admin/resource/restartWorkload"
linux 系统构建完后脚本 使用阿里云镜像仓库 并k8s更新部署
imageNS=yjx-service
imageName=yjx-test
cd business-service/yjx-test-parent/${imageName}/
registryusername=***@qq.com
registrypasswd=***
registryURL=registry.cn-hangzhou.aliyuncs.com
#platformRepoTags=$(aliyun cr GetRepoTags --RepoNamespace huaqinits --RepoName ${imageName} |jq ".data.tags[].tag" |head -1|sed 's/\"//g')
#OLD_IFS="$IFS"
#IFS="."
#arryPlatTags=($platformRepoTags)
#IFS="$OLD_IFS"
#nextPlatformTags=${arryPlatTags[0]}.${arryPlatTags[1]}.$[arryPlatTags[2]+1]
nextPlatformTags=0.0.1
sudo docker login --username=${registryusername} --password=${registrypasswd} ${registryURL}
echo "--------------------------------------------------------------------------------------"
sudo docker build -t ${registryURL}/${imageNS}/${imageName}:${nextPlatformTags} .
sudo docker push ${registryURL}/${imageNS}/${imageName}:${nextPlatformTags}
sudo docker logout
curl -X PUT \
-H "Content-Type: application/yaml" \
-H "Cookie: KuboardUsername=admin; KuboardAccessKey=74cfnbhnpxt7.ybxbif3zspm3nkzjmakdsiyh4dypprz5" \
-d '{"kind":"deployments","namespace":"yjx-service","name":"jenkins-deployment"}' \
"http://域名:端口/kuboard-api/cluster/default/kind/CICDApi/admin/resource/restartWorkload"
win和linux系统的区别是curl请求的时候,请求体 也就是 -d 后面的参数win需要把 单引号,换车双引号,里面的双引号进行转义 例如:linux:-d ‘{“kind”:“xxx”}’ win则写成: -d “{“kind”:“xxx”}”
单个pom服务api发布时候
单个pom服务发布时候
clean install -Dmaven.test.skip=true -Dmaven.javadoc.skip=true -Dgpg.skip=true -T 1C -Dmaven.compile.fork=true -P test
core包时需要构建一些其他的api pom则可以开启多核打包
clean install -Dmaven.test.skip=true -Dmaven.javadoc.skip=true -Dgpg.skip=true -T 1C -Dmaven.compile.fork=true -P test
-Dmaven.test.skip=true 跳过测试
-Dmaven.javadoc.skip=true 跳过文档打包
-Dgpg.skip=true 跳过 gpg
-T 1C
-T 4 是直接指定4线程
-T 1C 表示CPU线程的倍
就是假设,现在现在1个物理CPU,有4个核心,8个线程。
那么此时-T 1C 就是8线程
-Dmaven.compile.fork=true 开启多线程打包
-P test 打包环境为test 环境
下面是core的配置
更多推荐
所有评论(0)