/* MAINTAINER WinJayX <WinJayX@Gmail.com>
* LABEL description="This is FZ_CaseCenter_Web Project"
*/
stage('Git Checkout') {
node('MSBuild') {
checkout([$class: 'GitSCM', branches: [[name: '${Branch}']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '8888888-8888-8888-8888-888888fe66', url: 'https://git.nercoa.com/fz/other/classteachercaselibrary.git']]])
}
}
stage('Build'){
node('MSBuild') {
echo '编译解决方案'
bat "$DOTNET publish -c Release -o \"${WORKSPACE}/publish\" \"src/NERC.ClassTeacherCaseLibrary/NERC.ClassTeacherCaseLibrary.FrontEnd/NERC.ClassTeacherCaseLibrary.FrontEnd.csproj\" "
}
}
stage('Backup To The Site Directory'){
node('MSBuild') {
dir('publish') {
bat "zip -r ${BUILD_NUMBER}.zip ./"
}
echo '拷贝文件至备份目录'
bat "xcopy \"publish/${BUILD_NUMBER}.zip\" \"${BACKUP_SHARE_DIR}/${JOB_NAME}/\" /fyi "
bat "rm -rf publish*"
}
}
stage('Download Project Code'){
node('Container') {
echo '建立业务目录'
//sh "mkdir -p ${JOB_NAME} && cd ${JOB_NAME}"
echo '下载程序'
sh "curl -O ${PUBLISH_HOST}/${JOB_NAME}/${BUILD_NUMBER}.zip"
echo '解压源程序'
sh "unzip -o ${BUILD_NUMBER}.zip && rm -f ${BUILD_NUMBER}.zip"
}
}
stage('Build And Push Image') {
node('Container') {
sh '''
REPOSITORY=hub.nercoa.com/case-center/web:${ImageTag}
cat > Dockerfile << EOF
FROM mcr.microsoft.com/dotnet/aspnet
MAINTAINER WinJayX <WinJayX@Gmail.com>
LABEL description="This is FZ_CaseCenter_Web Project"
LABEL version="5.0.7"
USER root
RUN echo 'deb http://mirrors.163.com/debian/ buster main non-free contrib\\r\\ndeb http://mirrors.163.com/debian/ buster-updates main non-free contrib\\r\\ndeb http://mirrors.163.com/debian/ buster-backports main non-free contrib\\r\\ndeb-src http://mirrors.163.com/debian/ buster main non-free contrib\\r\\ndeb-src http://mirrors.163.com/debian/ buster-updates main non-free contrib\\r\\ndeb-src http://mirrors.163.com/debian/ buster-backports main non-free contrib\\r\\ndeb http://mirrors.163.com/debian-security/ buster/updates main non-free contrib\\r\\ndeb-src http://mirrors.163.com/debian-security/ buster/updates main non-free contrib\\r\\n' > /etc/apt/sources.list
RUN cat /etc/apt/sources.list
RUN apt-get update -y && apt-get upgrade -y
RUN apt-get install libgdiplus -y && ln -s libgdiplus.so gdiplus.dll
RUN ln -s /lib/x86_64-linux-gnu/libdl-2.24.so /lib/x86_64-linux-gnu/libdl.so
### 对连接sqlServer协议进行降级
RUN sed -i 's/TLSv1.2/TLSv1/g' /etc/ssl/openssl.cnf &&\
sed -i 's/LEVEL=2/LEVEL=1/g' /etc/ssl/openssl.cnf
WORKDIR /app
COPY . /app/
ENTRYPOINT ["dotnet", "NERC.ClassTeacherCaseLibrary.FrontEnd.dll"]
EOF
docker build -t $REPOSITORY .
docker login hub.nercoa.com -u username -p 8888888
docker push $REPOSITORY
'''
}
}
stage('Deploy To The Test Server') {
node('Container') {
sh '''
REPOSITORY=hub.nercoa.com/case-center/web:${ImageTag}
docker rm -f FZ_CaseCenter_Web || true
docker container run -d \
--volume /etc/localtime:/etc/localtime:ro \
--restart always \
--user root \
--name FZ_CaseCenter_Web \
--hostname FZ_CaseCenter_Web \
-p 8004:80 $REPOSITORY
'''
}
}
stage('Deploying To The Production Server'){
timeout(time: 1, unit: 'DAYS') {
input message: 'Deploying To The Production Server?', ok: 'Deployment'
}
}
stage('Deploy To The Production Docker Server') {
node('Robot') {
sh '''
cd /mnt/Docker/019.CC_Web
REPOSITORY=hub.nercoa.com/case-center/web:${ImageTag}
docker rm -f FZ_CaseCenter_Web || true
docker container run -d \
--volume /etc/localtime:/etc/localtime:ro \
--volume `pwd`/Config:/app/Config \
--restart always \
--user root \
--name FZ_CaseCenter_Web \
-h FZ_CaseCenter_Web \
-p 8015:80 \
$REPOSITORY
'''
}
}
版权归属:
WinJay
本文链接:
https://winjay.cn/?p=324
许可协议:
本文使用《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》协议授权
评论区