Dockerfile+Jenkinsfile+GitLab轻松实现.NetCore程序的CI&CD
2021-02-16 16:20
标签:一个 生成 generate eve 类型 div hooks inf 触发器 然后将程序文件push到Gitlab上 说明: Dockerfile+Jenkinsfile+GitLab轻松实现.NetCore程序的CI&CD 标签:一个 生成 generate eve 类型 div hooks inf 触发器 原文地址:https://www.cnblogs.com/peyshine/p/12966816.html一.相关介绍
二.Jenkins和GitLab的安装
三.打通GitLab Webhooks与Jenkins流程
pipeline{
agent any
stages {
stage(‘Build‘) {
steps{
echo ‘This is a build step‘
}
}
stage(‘Test‘) {
steps{
echo ‘This is a test step‘
}
}
stage(‘Deploy‘) {
steps{
echo ‘This is a deploy step‘
}
}
}
}
四.接入Jenkinsfile,Dockerfile实现自动发布
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
COPY *.csproj ./app/
WORKDIR /app
RUN dotnet restore
COPY . ./
RUN dotnet publish -o out /p:PublishWithAspNetCoreTargetManifest="false"
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS runtime
ENV ASPNETCORE_URLS http://+:80
WORKDIR /app
COPY --from=build /app/out ./
ENTRYPOINT ["dotnet", "WebApplication_Jenkinsfile.dll"]
pipeline{
agent any
stages {
stage(‘Checkout‘) {
steps{
git credentialsId: ‘85ca7e47-532e-4901-9828-50a8da071d16‘, url: ‘http://xxx.gitlab.com/webapplication_jenkinsfile.git‘, branch:‘master‘
echo ‘---This is a Checkout step---‘
}
}
stage(‘Build‘) {
steps{
sh ‘‘‘cd WebApplication_Jenkinsfile
docker rmi -f docker_webapplication_test:1.0
docker build -t docker_webapplication_test:1.0 .‘‘‘
echo ‘---This is a Build step---‘
}
}
stage(‘Run‘) {
steps{
sh ‘‘‘docker rm -f docker_webapplication_test
docker run --name docker_webapplication_test -d -p 7489:80 docker_webapplication_test:1.0
‘‘‘
echo ‘---This is a run step---‘
}
}
}
}
文章标题:Dockerfile+Jenkinsfile+GitLab轻松实现.NetCore程序的CI&CD
文章链接:http://soscw.com/index.php/essay/56172.html