侧边栏壁纸
博主头像
★街角晚灯★ 博主等级

博观而约取 厚积而薄发

  • 累计撰写 468 篇文章
  • 累计创建 185 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

Dotnet JenkinsFile|.Net Jenkins File

WinJay
2021-07-13 / 0 评论 / 0 点赞 / 205 阅读 / 0 字 / 正在检测是否收录...

img

/*  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
        '''
  }
}
0
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin

评论区