代码拉取完成,页面将自动刷新
同步操作将从 wujiawei/wu-framework-parent 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
---
apiVersion: v1
data:
build-images.sh: >
#!/bin/sh
. /etc/profile
if [[ -n "$ForceBuildProjectName" ]] ; then
echo "将强制更新以下项目${ForceBuildProjectName}"
fi
docker login harbor.k8s -u admin -p Harbor12345
cd $WORKSPACE
#获取git变更文件
commitId=`git --git-dir="$WORKSPACE/.git" --work-tree="$WORKSPACE" rev-parse
--short HEAD`
lastestCommitId="HEAD~"
if [ -f "$WORKSPACE/ci-lastest-commitId" ];
then
lastestCommitId=`cat $WORKSPACE/ci-lastest-commitId`
fi
echo "上次构建成功的git commitId为:$lastestCommitId"
changeFiles=`git --git-dir="$WORKSPACE/.git" --work-tree="$WORKSPACE" diff
--name-only $lastestCommitId HEAD`
if [ ! -n "$harborProject" ]; then
harborProject="supconit"
fi
#更新k8s文件
echo $changeFiles | grep k8s.yaml
if [ $(echo $?) -eq 0 -o ! -f "$WORKSPACE/k8s-ci.yaml" ];
then
rm -f $WORKSPACE/k8s-ci.yaml
cp $WORKSPACE/k8s.yaml $WORKSPACE/k8s-ci.yaml
existDeployments=`kubectl get deployment -n $project -o wide | grep -E 'svc|gateway' | awk {'print $7'} | awk -F '/' {'print $3'}`
for deployment in $existDeployments;do
replaceLatestTag $deployment
done
kubectl create -f $WORKSPACE/k8s-config-map.yaml
fi
function replaceLatestTag(){
commitImageName=$1
lowerModule=`echo $commitImageName | awk -F ':' {'print $1'}`
sed -i "s@harbor.k8s/$harborProject/$lowerModule:.*@harbor.k8s/$harborProject/$commitImageName'@g" $WORKSPACE/k8s-ci.yaml
}
(
function dockerBuild(){
project=$1
lowerModule=$2
module=$3
imageName=$project"_"$lowerModule
lastesTagName=$project"_latest"
commitTagName=$project"_"$commitId
latestImageName=$lowerModule":"$lastesTagName
commitImageName=$lowerModule":"$commitTagName
echo "构建并上传$lowerModule新的容器镜像"
# 创建dockerignore文件
if [ ! -f "$module/.dockerignore" ];
then
cp /root/jenkins-ci/ci-dockerignore $module/.dockerignore
fi
# 创建ci dockerfile文件
if [ ! -f "$module/CIDockerfile" ];
then
isZhfont=$(cat $module/Dockerfile | grep "zh-font")
if [ "$isZhfont" != "" ];
then
cp /root/jenkins-ci/java-zh-font-ci-dockerfile $module/CIDockerfile
else
cp /root/jenkins-ci/java-ci-dockerfile $module/CIDockerfile
fi
fi
docker build -t harbor.k8s/$harborProject/$latestImageName -f $module/CIDockerfile $module/
docker tag harbor.k8s/$harborProject/$latestImageName harbor.k8s/$harborProject/$commitImageName
docker push harbor.k8s/$harborProject/$latestImageName
docker push harbor.k8s/$harborProject/$commitImageName
docker rmi harbor.k8s/$harborProject/$latestImageName
docker rmi harbor.k8s/$harborProject/$commitImageName
replaceTag $lowerModule $commitImageName
}
function replaceTag(){
lowerModule=$1
commitImageName=$2
sed -i "s@harbor.k8s/$harborProject/$lowerModule:.*@harbor.k8s/$harborProject/$commitImageName'@g" $WORKSPACE/k8s-ci.yaml
}
function replaceLatestTag(){
commitImageName=$1
lowerModule = `echo $commitImageName | awk -F ':' {'print $1'}`
sed -i "s@harbor.k8s/$harborProject/$lowerModule:.*@harbor.k8s/$harborProject/$commitImageName'@g" $WORKSPACE/k8s-ci.yaml
}
# 获取所有的jar结尾的文件 忽略 BACKUP.jar
jarList=$(find $WORKSPACE -name *.jar ! -name *BACKUP.jar)
for jarAbsolutePath in jarList;
do
# 解析当前文件所在目录、文件名
jarName=${jarAbsolutePath##*/}
jarPackage=${jarAbsolutePath%/*}
jarBackPackage=${jarAbsolutePath%/*}
echo "解析当前文件所在目录:$jarPackage、文件名:$jarPackage"
# 是否忽略文件
isIgnore=$(echo $IgnoreBuildProjectName | grep "${jarName}")
if [[ "$isIgnore" != "" ]] ; then
echo "模块${jarName}跳过打包构建"
if [ -f "$jarBackPackage/$jarName-BACKUP.jar" ];
then
rm -f $jarBackPackage/$jarName-BACKUP.jar
fi
continue
fi
# 对比文件
# 是否更新打包
# 打镜像
done
if [ ! -n "$modulepath" ]; then
modulepath="$WORKSPACE/supconit-cloud-component $WORKSPACE/supconit-provider $WORKSPACE/supconit-job $WORKSPACE/supconit-etl"
fi
for topModule in $modulepath;do
cd $topModule
for module in $(ls -d */);do
module=${module%%/}
isIgnore=$(echo $IgnoreBuildProjectName | grep "${module}")
if [[ "$isIgnore" != "" ]] ; then
echo "模块${module}跳过打包构建"
if [ -f "$module/$module-BACKUP.jar" ];
then
rm -f $module/$module-BACKUP.jar
fi
continue
fi
echo -e "START---------------------------------------------------------------------------------------------------------"
startTime=$(date +%s)
# 仅打包构建指定模块,提高构建速度
if [[ -n "$justBuildProjectNames" ]] ; then
if [[ "$justBuildProjectNames" =~ "$module" ]]; then
echo "justBuildProjectNames-->构建打包模块${module}"
else
echo "justBuildProjectNames-->模块${module}无需打包构建"
continue
fi
fi
lowerModule=`echo $module |tr '[:upper:]' '[:lower:]'`
isModuleChanged=false
echo $changeFiles | tr ' ' '\n' | grep ".*/$module.*java$"
if [ $(echo $?) -eq 0 ];
then
isModuleChanged=true
elif [[ $ForceBuildProjectName = *$module* ]];
then
echo "强制更新该模块"
isModuleChanged=true
elif [ -f "$module/$module-BACKUP.jar" ];
then
echo "比对${module}是否变化"
pkgdiff $module/$module-BACKUP.jar $module/target/$module-*.jar
if [ $(echo $?) -gt 0 ];
then
isModuleChanged=true
fi
else
isModuleChanged=true
fi
if [ "$isModuleChanged" = "true" ];
then
echo "${module}包发生变化或被为本次强制构建模块"
dockerBuild $project $lowerModule $module
else
echo "${module}无变化"
fi
cp $module/target/$module-*.jar $module/$module-BACKUP.jar
endTime=$(date +%s)
take=$(( endTime - startTime ))
echo "本模块打包构建耗时${take}秒"
echo -e "END-----------------------------------------------------------------------------------------------------------\n\n"
done
done
)
echo '更新容器'
kubectl apply -f $WORKSPACE/k8s-ci.yaml | grep -E
'deployment.apps/svc|deployment.apps/gateway'
echo $commitId > $WORKSPACE/ci-lastest-commitId
build-one-images.sh: >
#!/bin/sh
. /etc/profile
if [[ -n "$ForceBuildProjectName" ]] ; then
echo "将强制更新以下项目${ForceBuildProjectName}"
fi
docker login harbor.k8s -u admin -p Harbor12345
cd $WORKSPACE
#获取git变更文件
commitId=`git --git-dir="$WORKSPACE/.git" --work-tree="$WORKSPACE" rev-parse
--short HEAD`
lastestCommitId="HEAD~"
if [ -f "$WORKSPACE/ci-lastest-commitId" ];
then
lastestCommitId=`cat $WORKSPACE/ci-lastest-commitId`
fi
echo "上次构建成功的git commitId为:$lastestCommitId"
changeFiles=`git --git-dir="$WORKSPACE/.git" --work-tree="$WORKSPACE" diff
--name-only $lastestCommitId HEAD`
if [ ! -n "$harborProject" ]; then
harborProject="harbor"
fi
#更新k8s文件
echo $changeFiles | grep k8s.yaml
if [ $(echo $?) -eq 0 -o ! -f "$WORKSPACE/k8s-ci.yaml" ];
then
rm -f $WORKSPACE/k8s-ci.yaml
cp $WORKSPACE/k8s.yaml $WORKSPACE/k8s-ci.yaml
existDeployments=`kubectl get deployment -n $project -o wide | grep -E
'svc|gateway' | awk {'print $7'} | awk -F '/' {'print $3'}`
for deployment in $existDeployments;do
replaceLatestTag $deployment
done
kubectl create -f $WORKSPACE/k8s-config-map.yaml
fi
function replaceLatestTag(){
commitImageName=$1
lowerModule=`echo $commitImageName | awk -F ':' {'print $1'}`
sed -i
"s@harbor.k8s/$harborProject/$lowerModule:.*@harbor.k8s/$harborProject/$commitImageName'@g"
$WORKSPACE/k8s-ci.yaml
}
(
function dockerBuild(){
project=$1
lowerModule=$2
module=$3
imageName=$project"_"$lowerModule
lastesTagName=$project"_latest"
commitTagName=$project"_"$commitId
latestImageName=$lowerModule":"$lastesTagName
commitImageName=$lowerModule":"$commitTagName
echo "构建并上传$lowerModule新的容器镜像"
# 创建dockerignore文件
if [ ! -f "$module/.dockerignore" ];
then
cp /root/jenkins-ci/ci-dockerignore .dockerignore
fi
# 创建ci dockerfile文件
if [ ! -f "CIDockerfile" ];
then
isZhfont=$(cat Dockerfile | grep "zh-font")
if [ "$isZhfont" != "" ];
then
cp /root/jenkins-ci/java-zh-font-ci-dockerfile CIDockerfile
else
cp /root/jenkins-ci/java-ci-dockerfile CIDockerfile
fi
fi
docker build -t harbor.k8s/$harborProject/$latestImageName -f CIDockerfile .
docker tag harbor.k8s/$harborProject/$latestImageName
harbor.k8s/$harborProject/$commitImageName
docker push harbor.k8s/$harborProject/$latestImageName
docker push harbor.k8s/$harborProject/$commitImageName
docker rmi harbor.k8s/$harborProject/$latestImageName
docker rmi harbor.k8s/$harborProject/$commitImageName
replaceTag $lowerModule $commitImageName
}
function replaceTag(){
lowerModule=$1
commitImageName=$2
sed -i
"s@harbor.k8s/$harborProject/$lowerModule:.*@harbor.k8s/$harborProject/$commitImageName'@g"
$WORKSPACE/k8s-ci.yaml
}
function replaceLatestTag(){
commitImageName=$1
lowerModule = `echo $commitImageName | awk -F ':' {'print $1'}`
sed -i
"s@harbor.k8s/$harborProject/$lowerModule:.*@harbor.k8s/$harborProject/$commitImageName'@g"
$WORKSPACE/k8s-ci.yaml
}
module=$(basename `pwd`)
isIgnore=$(echo $IgnoreBuildProjectName | grep "${module}")
if [[ "$isIgnore" != "" ]] ; then
echo "模块${module}跳过打包构建"
if [ -f "$module-BACKUP.jar" ];
then
rm -f $module-BACKUP.jar
fi
continue
fi
echo -e
"START---------------------------------------------------------------------------------------------------------"
startTime=$(date +%s)
# 仅打包构建指定模块,提高构建速度
if [[ -n "$justBuildProjectNames" ]] ; then
if [[ "$justBuildProjectNames" =~ "$module" ]]; then
echo "justBuildProjectNames-->构建打包模块${module}"
else
echo "justBuildProjectNames-->模块${module}无需打包构建"
continue
fi
fi
lowerModule=`echo $module |tr '[:upper:]' '[:lower:]'`
isModuleChanged=false
echo $changeFiles | tr ' ' '\n' | grep ".*/$module.*java$"
if [ $(echo $?) -eq 0 ];
then
isModuleChanged=true
elif [[ $ForceBuildProjectName = *$module* ]];
then
echo "强制更新该模块"
isModuleChanged=true
elif [ -f "$module-BACKUP.jar" ];
then
echo "比对${module}是否变化"
pkgdiff $module-BACKUP.jar target/$module-*.jar
if [ $(echo $?) -gt 0 ];
then
isModuleChanged=true
fi
else
isModuleChanged=true
fi
if [ "$isModuleChanged" = "true" ];
then
echo "${module}包发生变化或被为本次强制构建模块"
dockerBuild $project $lowerModule $module
else
echo "${module}无变化"
fi
cp target/$module-*.jar $module-BACKUP.jar
endTime=$(date +%s)
take=$(( endTime - startTime ))
echo "本模块打包构建耗时${take}秒"
echo -e
"END-----------------------------------------------------------------------------------------------------------\n\n"
)
echo '更新容器'
kubectl apply -f $WORKSPACE/k8s-ci.yaml | grep -E
'deployment.apps/svc|deployment.apps/gateway'
echo $commitId > $WORKSPACE/ci-lastest-commitId
build-web-images.sh: >
#!/bin/sh
. /etc/profile
echo 'harborProject=当前harbor项目,默认为harbor
branch= 当前项目分支(构建的镜像版本号branch_latest、branch_commitId)
'
docker login harbor.k8s -u admin -p Harbor12345
cd $WORKSPACE
#获取git变更文件
commitId=`git --git-dir="$WORKSPACE/.git" --work-tree="$WORKSPACE" rev-parse
--short HEAD`
lastestCommitId="HEAD~"
if [ -f "$WORKSPACE/ci-lastest-commitId" ];
then
lastestCommitId=`cat $WORKSPACE/ci-lastest-commitId`
fi
if [ ! -n "$harborProject" ]; then
harborProject="harbor"
fi
if [ -f "$WORKSPACE/k8s.yaml" ];
then
cp $WORKSPACE/k8s.yaml $WORKSPACE/k8s-ci.yaml
fi
echo "上次构建成功的git commitId为:$lastestCommitId"
changeFiles=`git --git-dir="$WORKSPACE/.git" --work-tree="$WORKSPACE" diff
--name-only $lastestCommitId HEAD`
(
function dockerBuild(){
project=$1
lowerModule=$2
module=$3
imageName=$project"_"$lowerModule
lastesTagName=$project"_latest"
commitTagName=$project"_"$commitId
latestImageName=$lowerModule":"$lastesTagName
commitImageName=$lowerModule":"$commitTagName
echo "构建并上传$lowerModule新的容器镜像"
# 创建dockerignore文件
if [ ! -f "$module/.dockerignore" ];
then
cp /root/jenkins-ci/ci-dockerignore .dockerignore
fi
# 创建ci dockerfile文件
if [ ! -f "Dockerfile" ];
then
cp /root/jenkins-ci/web-ci-dockerfile CIDockerfile
else
cp Dockerfile CIDockerfile
fi
docker build -t harbor.k8s/$harborProject/$latestImageName -f CIDockerfile .
docker tag harbor.k8s/$harborProject/$latestImageName harbor.k8s/$harborProject/$commitImageName
docker push harbor.k8s/$harborProject/$latestImageName
docker push harbor.k8s/$harborProject/$commitImageName
docker rmi harbor.k8s/$harborProject/$latestImageName
docker rmi harbor.k8s/$harborProject/$commitImageName
replaceTag $lowerModule $commitImageName
}
function replaceTag(){
lowerModule=$1
commitImageName=$2
sed -i "s@harbor.k8s/$harborProject/$lowerModule:.*@harbor.k8s/$harborProject/$commitImageName'@g" $WORKSPACE/k8s-ci.yaml
}
function replaceLatestTag(){
commitImageName=$1
lowerModule = `echo $commitImageName | awk -F ':' {'print $1'}`
sed -i "s@harbor.k8s/$harborProject/$lowerModule:.*@harbor.k8s/$harborProject/$commitImageName'@g" $WORKSPACE/k8s-ci.yaml
}
echo -e "START---------------------------------------------------------------------------------------------------------"
startTime=$(date +%s)
module=$(basename `pwd`)
echo "构建前端镜像"
dockerBuild $branch $lowerModule $module
endTime=$(date +%s)
take=$(( endTime - startTime ))
echo "本模块打包构建耗时${take}秒"
echo -e "END-----------------------------------------------------------------------------------------------------------\n\n"
)
echo '更新容器'
#更新k8s文件
if [ -f "$WORKSPACE/k8s-ci.yaml" ];
then
echo $changeFiles | grep k8s.yaml
echo '即将更新容器'
if [ $(echo $?) -eq 0 -o ! -f "$WORKSPACE/k8s-ci.yaml" ];
then
if [ -f "$WORKSPACE/k8s-config-map.yaml" ];
then
kubectl create -f $WORKSPACE/k8s-config-map.yaml
fi
fi
kubectl apply -f $WORKSPACE/k8s-ci.yaml | grep -E 'deployment.apps/svc|deployment.apps/gateway'
fi
echo $commitId > $WORKSPACE/ci-lastest-commitId
ci-dockerignore: |
sql/
src/
target/classes/
*.jar
*.iml
*.xml
*.md
.dockerignore
java-ci-dockerfile: |
FROM ci/java:8-jre
COPY target/*.jar app.jar
java-zh-font-ci-dockerfile: |
FROM ci/java:8-jre-zh-font
COPY target/*.jar app.jar
web-ci-dockerfile: |
FROM nginx:1.13.0-alpine
add dist /usr/share/nginx/html/
kind: ConfigMap
metadata:
name: jenkins-docker-bulid-conf
namespace: normal-system
resourceVersion: '596057'
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations:
k8s.eip.work/displayName: jenkins发布部署
k8s.eip.work/ingress: 'false'
k8s.eip.work/service: ClusterIP
k8s.eip.work/workload: jenkins
labels:
k8s.eip.work/layer: cloud
k8s.eip.work/name: jenkins
k8s.kuboard.cn/name: jenkins
name: jenkins
namespace: normal-system
resourceVersion: '596145'
spec:
podManagementPolicy: OrderedReady
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
k8s.eip.work/layer: cloud
k8s.eip.work/name: jenkins
serviceName: cloud-jenkins
template:
metadata:
creationTimestamp: null
labels:
k8s.eip.work/layer: cloud
k8s.eip.work/name: jenkins
spec:
containers:
- env:
- name: JAVA_OPTS
value: '-Xms256m -Xmx256m'
image: jenkins/jenkins
imagePullPolicy: IfNotPresent
name: jenkins
resources: { }
securityContext:
capabilities:
add:
- SYS_ADMIN
privileged: true
runAsUser: 0
windowsOptions: { }
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/jenkins_home
name: jenkins-data
- mountPath: /etc/localtime
name: tz
- mountPath: /var/run/docker.sock
name: docker-sock
- mountPath: /usr/bin/docker
name: docker
- mountPath: /root/jenkins-ci/
name: build-images
- mountPath: /usr/bin/kubectl
name: kubectl
dnsPolicy: ClusterFirst
hostAliases:
- hostnames:
- docker-registry.com
ip: 172.19.101.194
restartPolicy: Always
schedulerName: default-scheduler
securityContext: { }
terminationGracePeriodSeconds: 30
volumes:
- hostPath:
path: /usr/share/zoneinfo/Asia/Shanghai
type: File
name: tz
- hostPath:
path: /var/run/docker.sock
type: ''
name: docker-sock
- hostPath:
path: /usr/bin/docker
type: File
name: docker
- configMap:
defaultMode: 420
items:
- key: build-images.sh
path: build-images.sh
- key: build-one-images.sh
path: build-one-images.sh
- key: build-web-images.sh
path: build-web-images.sh
- key: java-ci-dockerfile
path: java-ci-dockerfile
- key: java-zh-font-ci-dockerfile
path: java-zh-font-ci-dockerfile
- key: web-ci-dockerfile
path: web-ci-dockerfile
- key: ci-dockerignore
path: ci-dockerignore
name: jenkins-docker-bulid-conf
name: build-images
- hostPath:
path: /usr/bin/kubectl
type: File
name: kubectl
updateStrategy:
rollingUpdate:
partition: 0
type: RollingUpdate
volumeClaimTemplates:
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
k8s.eip.work/pvcType: Dynamic
creationTimestamp: null
name: jenkins-data
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi
storageClassName: nfs1-storage
volumeMode: Filesystem
status:
phase: Pending
---
apiVersion: v1
kind: Service
metadata:
annotations:
k8s.eip.work/displayName: jenkins发布部署
k8s.eip.work/workload: jenkins
labels:
k8s.eip.work/layer: cloud
k8s.eip.work/name: jenkins
name: jenkins
namespace: normal-system
resourceVersion: '4204'
spec:
clusterIP: 10.96.56.179
clusterIPs:
- 10.96.56.179
externalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- name: jenkins
nodePort: 30506
port: 8080
protocol: TCP
targetPort: 8080
selector:
k8s.eip.work/layer: cloud
k8s.eip.work/name: jenkins
sessionAffinity: None
type: NodePort
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。