I recently practiced continuous integration in the company and used Jenkins’ Pipeline to improve the team’s integration and deployment efficiency based on ASP.NET Core API services, so here is a summary.
1. About continuous integration and Jenkins Pipeline
1.1 Concepts related to continuous integration
The development and release of Internet software has formed a set of standard processes. The most important part is Continuous integration (Continuous integration, referred to as CI).
Continuous integration refers to frequently (multiple times a day) integrating code into the backbone.
It has two main benefits:
(1) Find errors quickly. Every time a little update is completed, it is integrated into the backbone, errors can be found quickly, and it is easier to locate errors.
(2) Prevent branches from greatly deviating from the main trunk. If it is not integrated frequently, and the backbone is constantly updated, it will become more difficult to integrate in the future, or even difficult to integrate.
The purpose of continuous integration is to allow products to iterate quickly while maintaining high quality.
Martin Fowler said: “Continuous integration does not eliminate bugs, but makes them very easy to find and correct.”
Related to continuous integration, there are continuous delivery and continuous deployment.
Continuous delivery refers to: frequently deliver new versions of the software to the quality team or users for review. If the review passes, the code enters the production stage. It emphasizes that no matter how you update, the software can be delivered anytime, anywhere.
Continuous deployment is the next step of continuous delivery, which refers to automatic deployment of the code to the production environment after passing the review. It emphasizes that code is deployable at any time and can enter the production phase.
1.2 Jenkins Pipeline
Jenkins Yes A popular open source continuous integration (CI) and continuous deployment (CD) tool, widely used in project development, with functions such as automated construction, testing, and deployment. For the installation of Jenkins, you can refer to this article of mine for installation.
I believe that many children’s shoes are already using Jenkins or plan to use Jenkins to replace the traditional manual release process. Therefore, we have created a lot of free style (Free Style) construction tasks for multiple jobs, and we We often hear about pipeline tasks, so what is pipeline?
Pipeline is a set of workflow frameworks running on Jenkins. It connects tasks that originally run independently on a single or multiple nodes to achieve complex process orchestration and visualization that is difficult to complete a single task. . The following picture is an example effect of Jenkins Pipeline:
p>
Pipeline :Build => Test => Deploy
Here are several important concepts in Pipeline, you need to understand:
- < strong>Stage: Stage, a pipeline can be divided into several stages, and each stage represents a set of operations. Note that Stage is a logical grouping concept that can span multiple Nodes. As shown in the figure above, Build, Test, and Deploy are Stages, representing three different stages: compilation, testing, and deployment.
- Node: Node, a Node is a Jenkins node, or Master, or Slave, which is the specific runtime environment for executing Step.
- Step: Step, Step is the most basic unit of operation, ranging from creating a directory to building a Docker image, which is managed by various Jenkins Plugin provides.
Second, prepare ASP.NET Core Docker environment
2.1 Install Docker environment
can refer to my article “.NET Core Microservices ASP.NET Core on Docker” to install and configure the Docker environment, it is recommended to configure in the Linux environment.
2.2 Install SFTP service
Under Linux, the SSH service is installed by default, but under Windows Server, it needs to be installed separately, which can be achieved with the help of FreeSSHD, a free tool. Since my physical machine is Windows Server, and the VM on the physical machine is Linux (Docker operating environment), I need to configure FreeSSHD for the physical machine to implement Release from the CI server to the VM in the physical server.
As for how to install and configure FreeSSHD, you can refer to this article “freeSSHD to build an SFTP server in the windows environment”.
Three, configure Jenkins Pipeline pipeline tasks
3.1 Overall goal
(1) Continuous integration: Realize compilation + unit test automatic operation
< p>
The goal I want to achieve here is: When someone Push the code to the git server (the git server I use here is Gogs, and you need to set up a Webhook for Gogs, as shown in the figure below. Note that the key text set must be consistent with the one filled in the Pipeline, otherwise Jenkins cannot be correct Receive web hook), git server will trigger a webhook to send a post request to CI server, CI server will trigger the construction of the pipeline task, all the way to pull code + compile + unit test.
(2) Continuous release : Realize compilation + release to specific test environment
p>
Because in the development phase, I don’t need to publish every time Push, so what I set here is to manually trigger the publishing task in Jenkins to achieve automated publishing.
3.2 Global Settings
First of all, the plugin for Jenkins must be installed.
(1)Generic WebHook Trigger => Necessary to trigger WebHook
(2) Gogs Plugin => Because the Git Server I use is built by Gogs
(3) MSBuild Plugin => Compile sln, csproj project files
(4) MSTest & xUnit => Carry out unit tests based on MSTest or xUnit
(5) Nuget Plugin => Necessary to pull Nuget package
(6) Pipeline => Necessary to implement Pipeline tasks, it is recommended to install all relevant Pipeline plug-ins
(7) Powershell Plugin => If your CI server is based on Windows, install the Powershell plug-in to execute commands.
(8)Publish Over SSH => Required for remote release release
(9)WallDisplay => Necessary to build a task list for TV screencasting
Secondly, in order to prompt emails, the Email extension must also be supported, and the following configuration should be performed:
(1) One: Jenkins Location
(2) The second part: Email extension plug-in global variable settings
The main purpose here is to set Subject and Content, which can be used in each Pipeline. Therefore, post my Default Content content here:
offset="0">
${ENV, var="JOB_NAME"}-the ${BUILD_NUMBER}th build log
Hello colleagues, the following is ${PROJECT_NAME} Construction task information |
Building information |
|
In order to be able to send to more people, it is recommended to check the above two options.
Here is required for email notification Fill in the SMTP server configuration.
Finally, it is the statement of the SSH server, specifying which servers can be used for SSH publishing and what their IP is:
3.3 New Pipeline script
(1) Continuous integration of Pipeline
First, fill in the key text of the Webhook:
Secondly, the timing of Build Triggers is “Build when a change is pushed to Gogs”, that is, it is triggered when someone pushes the code to the warehouse. Of course, you need to set up Webhook in Gogs in advance.
Secondly, write a Pipeline script , Write clearly the responsibilities of each stage:
< p> The specific Pipeline script is as follows:
pipeline {
agent any
stages {
stage(‘XDP Core Services Checkout’) {
steps{
checkout([$class:'GitSCM', branches: [[name:'*/dev-xds']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '35b9890b-2338-45e2-8a1a-78e9bbe1d3e2', url:'http://192.168.18.150:3000/EDC.ITC.XDP.Core/EDC.XDP.Core.git']]])
echo ‘Core Services Checkout Done’
}
}
stage(‘XDP Core Services Build’) {
steps{
bat ‘‘‘cd "D:\Jenkins\workspace\XDS.Dev.CI.Pipeline\src\services\EDC.XDP.Core\"
dotnet build EDC.XDP.Core-All.sln‘‘‘
echo ‘Core Services Build Done’
}
}
stage(‘Core Delivery Service Unit Test’) {
steps{
bat'''cd "D:\Jenkins\workspace\XDS.Dev.CI.Pipeline\src\services\EDC.XDP.Core\Services\EDC.XDP.Core .Delivery.UnitTest"
dotnet test -v n --no-build EDC.XDP.Core.Delivery.UnitTest.csproj‘‘‘
echo ‘Core Delivery Service Unit Test Done’
}
}
stage(‘XDS Delivery Service Checkout’) {
steps{
checkout([$class:'GitSCM', branches: [[name:'*/dev-service']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '35b9890b-2338-45e2-8a1a-78e9bbe1d3e2', url:'http://192.168.18.150:3000/EDC.ITC.XDP.XDS/EDC.XDP.XDS.git']]])
echo ‘Core Delivery Service Checkout Done’
}
}
stage(‘XDS Delivery Service Build’) {
steps{
bat ‘‘‘cd "D:\Jenkins\workspace\XDS.Dev.CI.Pipeline\src\services\EDC.XDP.XDS"
dotnet build EDC.XDP.XDS.sln‘‘‘
echo ‘XDS Service Build Done’
}
}
stage(‘XDS Delivery Service Unit Test’) {
steps{
bat'''cd "D:\Jenkins\workspace\XDS.Dev.CI.Pipeline\src\services\EDC.XDP.XDS\EDC.XDP.XDS.Delivery. UnitTest"
dotnet test -v n --no-build EDC.XDP.XDS.Delivery.UnitTest.csproj‘‘‘
echo ‘XDS Service Unit Test Done’
}
}
}
post{
failure {
emailext (
subject: ‘${DEFAULT_SUBJECT}’,
body: ‘${DEFAULT_CONTENT}’,
to: "[email protected],[email protected]")
}
}
}
(2) Continuous release of Pipeline
Continuous release of Pipeline is similar to continuous integration of Pipeline, only in the script It’s different:
pipeline{
agent any
stages {
stage(‘Core Delivery Service Checkout’) {
steps{
checkout([$class:'GitSCM', branches: [[name:'*/dev-xds']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '35b9890b-2338-45e2-8a1a-78e9bbe1d3e2', url:'http://192.168.18.150:3000/EDC.ITC.XDP.Core/EDC.XDP.Core.git']]])
echo ‘Core Delivery Service Dev Branch Checkout Done’
}
}
stage(‘Core Delivery Service Build & Publish’) {
steps{
bat ‘‘‘cd "D:\Jenkins\workspace\XDS.API.Dev.CD.Pipeline\src\services\EDC.XDP.Core"
dotnet build EDC.XDP.Core-DataServices.sln
dotnet publish "%WORKSPACE%\src\services\EDC.XDP.Core\Services\EDC.XDP.Core.Delivery.API\EDC.XDP.Core.Delivery.API.csproj "-o "%WORKSPACE%\EDC.XDP.Core.Delivery.API/publish" --framework netcoreapp2.1
‘‘‘
echo ‘Core Delivery Service Build & Publish Done’
}
}
stage(‘Core Delivery Service Deploy To 190 Server’) {
steps{
sshPublisher(publishers: [sshPublisherDesc(configName:'XDP-DEV-Server', transfers: [sshTransfer(cleanRemote: false, excludes:'', execCommand:'''docker stop xdp_core_deliveryservice; docker rm xdp_core_deliveryservice; docker run --ulimit core=0 --restart=always -v /etc/localtime:/etc/localtime -d -e ASPNETCORE_ENVIRONMENT=dev --privileged=true --name=xdp_core_deliveryservice -p 8010:80 -v /XiLife/publish /EDC.XDP.Core.Delivery.API/:/app -w /app xdp_service_runtime:latest dotnet EDC.XDP.Core.Delivery.API.dll''', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes : false, patternSeparator:'[, ]+', remoteDirectory:'EDC.XDP.Core.Delivery.API/', remoteDirectorySDF: false, removePrefix:'EDC.XDP.Core.Delivery.API/publish/', sourceFiles: 'EDC.XDP.Core.Delivery.API/publish/**')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
echo ‘Delivery Service Deploy To 190 Done’
}
}
stage(‘Core Delivery Service Deploy To 175 Server’) {
steps{
sshPublisher(publishers: [sshPublisherDesc(configName:'XDP-DEV-MT-Server', transfers: [sshTransfer(cleanRemote: false, excludes:'', execCommand:'''docker stop xdp_core_deliveryservice; docker rm xdp_core_deliveryservice; docker run --ulimit core=0 --restart=always -v /etc/localtime:/etc/localtime -d -e ASPNETCORE_ENVIRONMENT=devmt --privileged=true --name=xdp_core_deliveryservice -p 8010:80 -v /XiLife /publish/EDC.XDP.Core.Delivery.API/:/app -w /app xdp_service_runtime:latest dotnet EDC.XDP.Core.Delivery.API.dll''', execTimeout: 120000, flatten: false, makeEmptyDirs: false , noDefaultExcludes: false, patternSeparator:'[, ]+', remoteDirectory:'EDC.XDP.Core.Delivery.API/', remoteDirectorySDF: false, removePrefix:'EDC.XDP.Core.Delivery.API/publish/', sourceFiles:'EDC.XDP.Core.Delivery.API/publish/**')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
echo ‘Delivery Service Deploy To 175 Done’
}
}
stage(‘XDS Delivery Service Checkout’) {
steps{
checkout([$class:'GitSCM', branches: [[name:'*/dev-service']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '35b9890b-2338-45e2-8a1a-78e9bbe1d3e2', url:'http://192.168.18.150:3000/EDC.ITC.XDP.XDS/EDC.XDP.XDS.git']]])
echo ‘XDS Delivery Service Checkout Done’
}
}
stage(‘XDS Delivery Service Build & Publish’) {
steps{
bat ‘‘‘cd "D:\Jenkins\workspace\XDS.API.Dev.CD.Pipeline\src\services\EDC.XDP.XDS"
dotnet build EDC.XDP.XDS.sln
dotnet publish "%WORKSPACE%\src\services\EDC.XDP.XDS\EDC.XDP.XDS.Delivery.API\EDC.XDP.XDS.Delivery.API.csproj" -o "%WORKSPACE%\EDC.XDP.XDS.Delivery.API/publish" --framework netcoreapp2.1
‘‘‘
echo ‘XDS Delivery Service Build & Publish Done’
}
}
stage(‘XDS Delivery Service Deploy To 190 Server’) {
steps{
sshPublisher(publishers: [sshPublisherDesc(configName:'XDP-DEV-Server', transfers: [sshTransfer(cleanRemote: false, excludes:'', execCommand:'''docker stop xdp_xds_delivery_service;docker rm x runp_xds_delivery_service; --ulimit core=0 --restart=always -v /etc/localtime:/etc/localtime -d -e ASPNETCORE_ENVIRONMENT=dev --privileged=true --name=xdp_xds_delivery_service -p 9020:80 -v /XiLife/publish /EDC.XDP.XDS.Delivery.API/:/app -w /app xdp_service_runtime:latest dotnet EDC.XDP.XDS.Delivery.API.dll''', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes : false, patternSeparator:'[, ]+', remoteDirectory:'EDC.XDP.XDS.Delivery.API/', remoteDirectorySDF: false, removePrefix:'EDC.XDP.XDS.Delivery.API/publish/', sourceFiles: 'EDC.XDP.XDS.Delivery.API/publish/**')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
echo ‘XDS Delivery Service Deploy to 190 Done’
}
}
stage(‘XDS Delivery Service Deploy To 175 Server’) {
steps{
sshPublisher(publishers: [sshPublisherDesc(configName:'XDP-DEV-MT-Server', transfers: [sshTransfer(cleanRemote: false, excludes:'', execCommand:'''docker stop xdp_xds_delivery_service;docker rm xdp_xds_delivery_service; docker run --ulimit core=0 --restart=always -v /etc/localtime:/etc/localtime -d -e ASPNETCORE_ENVIRONMENT=devmt --privileged=true --name=xdp_xds_delivery_service -p 9020:80 -v /XiLife /publish/EDC.XDP.XDS.Delivery.API/:/app -w /app xdp_service_runtime:latest dotnet EDC.XDP.XDS.Delivery.API.dll''', execTimeout: 120000, flatten: false, makeEmptyDirs: false , noDefaultExcludes: false, patternSeparator:'[, ]+', remoteDirectory:'EDC.XDP.XDS.Delivery.API/', remoteDirectorySDF: false, removePrefix:'EDC.XDP.XDS.Delivery.API/publish/', sourceFiles:'EDC.XDP.XDS.Delivery.API/publish/**')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
echo ‘XDS Delivery Service Deploy to 175 Done’
}
}
}
}
Because my test environment is divided into two here, one is the developer joint debugging environment 190, and the other is the integration test Environment 175, unified release in a pipeline task.
For the Master branch, we can also integrate the publishing of the Web system into the same Pipeline task to achieve a one-stop publishing pipeline task. Because the implementation technology of each Web system is different, it is not here. Paste the script again.
Four. Effect demonstration
(1) Continuous integration example
(2) Continuous release example
(3) Build failure warning
(4) Build a large screen display
Here is the effect of projecting another screen to the TV screen in the work area. You can see the result of the build when you look up, whether it is green or famous? Of course, we all like “green” ones, huhu.
Five. Summary h1>
With continuous integration and continuous release, our developers can save a lot of quality assurance and release deployment time, thereby reducing a lot of human errors caused by QA and Deploy. From another level, it can also enable us Avoid 996 (well, although the association is a bit far-fetched). In the future, I will explore K8S. I hope to share a series of articles on ASP.NET Core on K8S at that time, so stay tuned.
References
Dabaoyu, “Playing with Jenkins Pipeline”
Li Zhiqiang, “Jenkins Advanced Usage-Pipeline Installation”
Li Zhiqiang , “Jenkins Advanced Usage-Jenkinsfile Introduction and Practical Experience”
Three Squirrels, “Jenkins + Pipeline Construction Automation Deployment”
ofnhkb1, “.NET Project from CI to CD-Jenkins_Pipeline Application of “
Author: Zhou Xulong
Source: http://edisonchou.cnblogs.com
The copyright of this article belongs to the author and the blog garden. Reprinting is welcome, but this statement must be retained without the author’s consent, and a link to the original text should be given in an obvious place on the article page.
offset="0">
${ENV, var="JOB_NAME"}-the ${BUILD_NUMBER}th build log
Hello colleagues, the following is ${PROJECT_NAME} Construction task information |
Building information |
|
< pre>pipeline{
agent any
stages {
stage(‘XDP Core Services Checkout’) {
steps{
checkout([$class:’GitSCM’, branches: [[name:’*/dev-xds’]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: ’35b9890b-2338-45e2-8a1a-78e9bbe1d3e2′, url:’http://192.168.18.150:3000/EDC.ITC.XDP.Core/EDC.XDP.Core.git’]]])
echo ‘Core Services Checkout Done’
}
}
stage(‘XDP Core Services Build’) {
steps{
bat ‘‘‘cd “D:\Jenkins\workspace\XDS.Dev.CI.Pipeline\src\services\EDC.XDP.Core\”
dotnet build EDC.XDP.Core-All.sln‘‘‘
echo ‘Core Services Build Done’
}
}
stage(‘Core Delivery Service Unit Test’) {
steps{
bat”’cd “D:\Jenkins\workspace\XDS.Dev.CI.Pipeline\src\services\EDC.XDP.Core\Services\EDC.XDP.Core .Delivery.UnitTest”
dotnet test -v n –no-build EDC.XDP.Core.Delivery.UnitTest.csproj‘‘‘
echo ‘Core Delivery Service Unit Test Done’
}
}
stage(‘XDS Delivery Service Checkout’) {
steps{
checkout([$class:’GitSCM’, branches: [[name:’*/dev-service’]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: ’35b9890b-2338-45e2-8a1a-78e9bbe1d3e2′, url:’http://192.168.18.150:3000/EDC.ITC.XDP.XDS/EDC.XDP.XDS.git’]]])
echo ‘Core Delivery Service Checkout Done’
}
}
stage(‘XDS Delivery Service Build’) {
steps{
bat ‘‘‘cd “D:\Jenkins\workspace\XDS.Dev.CI.Pipeline\src\services\EDC.XDP.XDS”
dotnet build EDC.XDP.XDS.sln‘‘‘
echo ‘XDS Service Build Done’
}
}
stage(‘XDS Delivery Service Unit Test’) {
steps{
bat”’cd “D:\Jenkins\workspace\XDS.Dev.CI.Pipeline\src\services\EDC.XDP.XDS\EDC.XDP.XDS.Delivery. UnitTest”
dotnet test -v n –no-build EDC.XDP.XDS.Delivery.UnitTest.csproj‘‘‘
echo ‘XDS Service Unit Test Done’
}
}
}
post{
failure {
emailext (
subject: ‘${DEFAULT_SUBJECT}’,
body: ‘${DEFAULT_CONTENT}’,
to: “[email protected],[email protected]”)
}
}
}
pipeline{
agent any
stages {
stage(‘XDP Core Services Checkout’) {
steps{
checkout([$class:'GitSCM', branches: [[name:'*/dev-xds']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '35b9890b-2338-45e2-8a1a-78e9bbe1d3e2', url:'http://192.168.18.150:3000/EDC.ITC.XDP.Core/EDC.XDP.Core.git']]])
echo ‘Core Services Checkout Done’
}
}
stage(‘XDP Core Services Build’) {
steps{
bat ‘‘‘cd "D:\Jenkins\workspace\XDS.Dev.CI.Pipeline\src\services\EDC.XDP.Core\"
dotnet build EDC.XDP.Core-All.sln‘‘‘
echo ‘Core Services Build Done’
}
}
stage(‘Core Delivery Service Unit Test’) {
steps{
bat'''cd "D:\Jenkins\workspace\XDS.Dev.CI.Pipeline\src\services\EDC.XDP.Core\Services\EDC.XDP.Core .Delivery.UnitTest"
dotnet test -v n --no-build EDC.XDP.Core.Delivery.UnitTest.csproj‘‘‘
echo ‘Core Delivery Service Unit Test Done’
}
}
stage(‘XDS Delivery Service Checkout‘) {
steps{
checkout([$class: ‘GitSCM‘, branches: [[name: ‘*/dev-service‘]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: ‘35b9890b-2338-45e2-8a1a-78e9bbe1d3e2‘, url: ‘http://192.168.18.150:3000/EDC.ITC.XDP.XDS/EDC.XDP.XDS.git‘]]])
echo ‘Core Delivery Service Checkout Done‘
}
}
stage(‘XDS Delivery Service Build‘) {
steps{
bat ‘‘‘cd "D:\Jenkins\workspace\XDS.Dev.CI.Pipeline\src\services\EDC.XDP.XDS"
dotnet build EDC.XDP.XDS.sln‘‘‘
echo ‘XDS Service Build Done‘
}
}
stage(‘XDS Delivery Service Unit Test‘) {
steps{
bat ‘‘‘cd "D:\Jenkins\workspace\XDS.Dev.CI.Pipeline\src\services\EDC.XDP.XDS\EDC.XDP.XDS.Delivery.UnitTest"
dotnet test -v n --no-build EDC.XDP.XDS.Delivery.UnitTest.csproj‘‘‘
echo ‘XDS Service Unit Test Done‘
}
}
}
post{
failure {
emailext (
subject: ‘${DEFAULT_SUBJECT}‘,
body: ‘${DEFAULT_CONTENT}‘,
to: "[email protected],[email protected]")
}
}
}
pipeline{
agent any
stages {
stage(‘Core Delivery Service Checkout‘) {
steps{
checkout([$class: ‘GitSCM‘, branches: [[name: ‘*/dev-xds‘]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: ‘35b9890b-2338-45e2-8a1a-78e9bbe1d3e2‘, url: ‘http://192.168.18.150:3000/EDC.ITC.XDP.Core/EDC.XDP.Core.git‘]]])
echo ‘Core Delivery Service Dev Branch Checkout Done‘
}
}
stage(‘Core Delivery Service Build & Publish‘) {
steps{
bat ‘‘‘cd "D:\Jenkins\workspace\XDS.API.Dev.CD.Pipeline\src\services\EDC.XDP.Core"
dotnet build EDC.XDP.Core-DataServices.sln
dotnet publish "%WORKSPACE%\src\services\EDC.XDP.Core\Services\EDC.XDP.Core.Delivery.API\EDC.XDP.Core.Delivery.API.csproj" -o "%WORKSPACE%\EDC.XDP.Core.Delivery.API/publish" --framework netcoreapp2.1
‘‘‘
echo ‘Core Delivery Service Build & Publish Done‘
}
}
stage(‘Core Delivery Service Deploy To 190 Server‘) {
steps{
sshPublisher(publishers: [sshPublisherDesc(configName: ‘XDP-DEV-Server‘, transfers: [sshTransfer(cleanRemote: false, excludes: ‘‘, execCommand: ‘‘‘docker stop xdp_core_deliveryservice; docker rm xdp_core_deliveryservice; docker run --ulimit core=0 --restart=always -v /etc/localtime:/etc/localtime -d -e ASPNETCORE_ENVIRONMENT=dev --privileged=true --name=xdp_core_deliveryservice -p 8010:80 -v /XiLife/publish/EDC.XDP.Core.Delivery.API/:/app -w /app xdp_service_runtime:latest dotnet EDC.XDP.Core.Delivery.API.dll‘‘‘, execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: ‘[, ]+‘, remoteDirectory: ‘EDC.XDP.Core.Delivery.API/‘, remoteDirectorySDF: false, removePrefix: ‘EDC.XDP.Core.Delivery.API/publish/‘, sourceFiles: ‘EDC.XDP.Core.Delivery.API/publish/**‘)], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
echo ‘Delivery Service Deploy To 190 Done‘
}
}
stage(‘Core Delivery Service Deploy To 175 Server‘) {
steps{
sshPublisher(publishers: [sshPublisherDesc(configName: ‘XDP-DEV-MT-Server‘, transfers: [sshTransfer(cleanRemote: false, excludes: ‘‘, execCommand: ‘‘‘docker stop xdp_core_deliveryservice; docker rm xdp_core_deliveryservice; docker run --ulimit core=0 --restart=always -v /etc/localtime:/etc/localtime -d -e ASPNETCORE_ENVIRONMENT=devmt --privileged=true --name=xdp_core_deliveryservice -p 8010:80 -v /XiLife/publish/EDC.XDP.Core.Delivery.API/:/app -w /app xdp_service_runtime:latest dotnet EDC.XDP.Core.Delivery.API.dll‘‘‘, execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: ‘[, ]+‘, remoteDirectory: ‘EDC.XDP.Core.Delivery.API/‘, remoteDirectorySDF: false, removePrefix: ‘EDC.XDP.Core.Delivery.API/publish/‘, sourceFiles: ‘EDC.XDP.Core.Delivery.API/publish/**‘)], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
echo ‘Delivery Service Deploy To 175 Done‘
}
}
stage(‘XDS Delivery Service Checkout‘) {
steps{
checkout([$class: ‘GitSCM‘, branches: [[name: ‘*/dev-service‘]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: ‘35b9890b-2338-45e2-8a1a-78e9bbe1d3e2‘, url: ‘http://192.168.18.150:3000/EDC.ITC.XDP.XDS/EDC.XDP.XDS.git‘]]])
echo ‘XDS Delivery Service Checkout Done‘
}
}
stage(‘XDS Delivery Service Build & Publish‘) {
steps{
bat ‘‘‘cd "D:\Jenkins\workspace\XDS.API.Dev.CD.Pipeline\src\services\EDC.XDP.XDS"
dotnet build EDC.XDP.XDS.sln
dotnet publish "%WORKSPACE%\src\services\EDC.XDP.XDS\EDC.XDP.XDS.Delivery.API\EDC.XDP.XDS.Delivery.API.csproj" -o "%WORKSPACE%\EDC.XDP.XDS.Delivery.API/publish" --framework netcoreapp2.1
‘‘‘
echo ‘XDS Delivery Service Build & Publish Done‘
}
}
stage(‘XDS Delivery Service Deploy To 190 Server‘) {
steps{
sshPublisher(publishers: [sshPublisherDesc(configName: ‘XDP-DEV-Server‘, transfers: [sshTransfer(cleanRemote: false, excludes: ‘‘, execCommand: ‘‘‘docker stop xdp_xds_delivery_service;docker rm xdp_xds_delivery_service; docker run --ulimit core=0 --restart=always -v /etc/localtime:/etc/localtime -d -e ASPNETCORE_ENVIRONMENT=dev --privileged=true --name=xdp_xds_delivery_service -p 9020:80 -v /XiLife/publish/EDC.XDP.XDS.Delivery.API/:/app -w /app xdp_service_runtime:latest dotnet EDC.XDP.XDS.Delivery.API.dll‘‘‘, execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: ‘[, ]+‘, remoteDirectory: ‘EDC.XDP.XDS.Delivery.API/‘, remoteDirectorySDF: false, removePrefix: ‘EDC.XDP.XDS.Delivery.API/publish/‘, sourceFiles: ‘EDC.XDP.XDS.Delivery.API/publish/**‘)], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
echo ‘XDS Delivery Service Deploy to 190 Done‘
}
}
stage(‘XDS Delivery Service Deploy To 175 Server‘) {
steps{
sshPublisher(publishers: [sshPublisherDesc(configName: ‘XDP-DEV-MT-Server‘, transfers: [sshTransfer(cleanRemote: false, excludes: ‘‘, execCommand: ‘‘‘docker stop xdp_xds_delivery_service;docker rm xdp_xds_delivery_service; docker run --ulimit core=0 --restart=always -v /etc/localtime:/etc/localtime -d -e ASPNETCORE_ENVIRONMENT=devmt --privileged=true --name=xdp_xds_delivery_service -p 9020:80 -v /XiLife/publish/EDC.XDP.XDS.Delivery.API/:/app -w /app xdp_service_runtime:latest dotnet EDC.XDP.XDS.Delivery.API.dll‘‘‘, execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: ‘[, ]+‘, remoteDirectory: ‘EDC.XDP.XDS.Delivery.API/‘, remoteDirectorySDF: false, removePrefix: ‘EDC.XDP.XDS.Delivery.API/publish/‘, sourceFiles: ‘EDC.XDP.XDS.Delivery.API/publish/**‘)], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
echo ‘XDS Delivery Service Deploy to 175 Done‘
}
}
}
}
pipeline{
agent any
stages {
stage(‘Core Delivery Service Checkout‘) {
steps{
checkout([$class: ‘GitSCM‘, branches: [[name: ‘*/dev-xds‘]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: ‘35b9890b-2338-45e2-8a1a-78e9bbe1d3e2‘, url: ‘http://192.168.18.150:3000/EDC.ITC.XDP.Core/EDC.XDP.Core.git‘]]])
echo ‘Core Delivery Service Dev Branch Checkout Done‘
}
}
stage(‘Core Delivery Service Build & Publish‘) {
steps{
bat ‘‘‘cd "D:\Jenkins\workspace\XDS.API.Dev.CD.Pipeline\src\services\EDC.XDP.Core"
dotnet build EDC.XDP.Core-DataServices.sln
dotnet publish "%WORKSPACE%\src\services\EDC.XDP.Core\Services\EDC.XDP.Core.Delivery.API\EDC.XDP.Core.Delivery.API.csproj" -o "%WORKSPACE%\EDC.XDP.Core.Delivery.API/publish" --framework netcoreapp2.1
‘‘‘
echo ‘Core Delivery Service Build & Publish Done‘
}
}
stage(‘Core Delivery Service Deploy To 190 Server‘) {
steps{
sshPublisher(publishers: [sshPublisherDesc(configName: ‘XDP-DEV-Server‘, transfers: [sshTransfer(cleanRemote: false, excludes: ‘‘, execCommand: ‘‘‘docker stop xdp_core_deliveryservice; docker rm xdp_core_deliveryservice; docker run --ulimit core=0 --restart=always -v /etc/localtime:/etc/localtime -d -e ASPNETCORE_ENVIRONMENT=dev --privileged=true --name=xdp_core_deliveryservice -p 8010:80 -v /XiLife/publish/EDC.XDP.Core.Delivery.API/:/app -w /app xdp_service_runtime:latest dotnet EDC.XDP.Core.Delivery.API.dll‘‘‘, execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: ‘[, ]+‘, remoteDirectory: ‘EDC.XDP.Core.Delivery.API/‘, remoteDirectorySDF: false, removePrefix: ‘EDC.XDP.Core.Delivery.API/publish/‘, sourceFiles: ‘EDC.XDP.Core.Delivery.API/publish/**‘)], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
echo ‘Delivery Service Deploy To 190 Done‘
}
}
stage(‘Core Delivery Service Deploy To 175 Server‘) {
steps{
sshPublisher(publishers: [sshPublisherDesc(configName: ‘XDP-DEV-MT-Server‘, transfers: [sshTransfer(cleanRemote: false, excludes: ‘‘, execCommand: ‘‘‘docker stop xdp_core_deliveryservice; docker rm xdp_core_deliveryservice; docker run --ulimit core=0 --restart=always -v /etc/localtime:/etc/localtime -d -e ASPNETCORE_ENVIRONMENT=devmt --privileged=true --name=xdp_core_deliveryservice -p 8010:80 -v /XiLife/publish/EDC.XDP.Core.Delivery.API/:/app -w /app xdp_service_runtime:latest dotnet EDC.XDP.Core.Delivery.API.dll‘‘‘, execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: ‘[, ]+‘, remoteDirectory: ‘EDC.XDP.Core.Delivery.API/‘, remoteDirectorySDF: false, removePrefix: ‘EDC.XDP.Core.Delivery.API/publish/‘, sourceFiles: ‘EDC.XDP.Core.Delivery.API/publish/**‘)], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
echo ‘Delivery Service Deploy To 175 Done‘
}
}
stage(‘XDS Delivery Service Checkout‘) {
steps{
checkout([$class: ‘GitSCM‘, branches: [[name: ‘*/dev-service‘]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: ‘35b9890b-2338-45e2-8a1a-78e9bbe1d3e2‘, url: ‘http://192.168.18.150:3000/EDC.ITC.XDP.XDS/EDC.XDP.XDS.git‘]]])
echo ‘XDS Delivery Service Checkout Done‘
}
}
stage(‘XDS Delivery Service Build & Publish‘) {
steps{
bat ‘‘‘cd "D:\Jenkins\workspace\XDS.API.Dev.CD.Pipeline\src\services\EDC.XDP.XDS"
dotnet build EDC.XDP.XDS.sln
dotnet publish "%WORKSPACE%\src\services\EDC.XDP.XDS\EDC.XDP.XDS.Delivery.API\EDC.XDP.XDS.Delivery.API.csproj" -o "%WORKSPACE%\EDC.XDP.XDS.Delivery.API/publish" --framework netcoreapp2.1
‘‘‘
echo ‘XDS Delivery Service Build & Publish Done‘
}
}
stage(‘XDS Delivery Service Deploy To 190 Server‘) {
steps{
sshPublisher(publishers: [sshPublisherDesc(configName: ‘XDP-DEV-Server‘, transfers: [sshTransfer(cleanRemote: false, excludes: ‘‘, execCommand: ‘‘‘docker stop xdp_xds_delivery_service;docker rm xdp_xds_delivery_service; docker run --ulimit core=0 --restart=always -v /etc/localtime:/etc/localtime -d -e ASPNETCORE_ENVIRONMENT=dev --privileged=true --name=xdp_xds_delivery_service -p 9020:80 -v /XiLife/publish/EDC.XDP.XDS.Delivery.API/:/app -w /app xdp_service_runtime:latest dotnet EDC.XDP.XDS.Delivery.API.dll‘‘‘, execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: ‘[, ]+‘, remoteDirectory: ‘EDC.XDP.XDS.Delivery.API/‘, remoteDirectorySDF: false, removePrefix: ‘EDC.XDP.XDS.Delivery.API/publish/‘, sourceFiles: ‘EDC.XDP.XDS.Delivery.API/publish/**‘)], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
echo ‘XDS Delivery Service Deploy to 190 Done‘
}
}
stage(‘XDS Delivery Service Deploy To 175 Server‘) {
steps{
sshPublisher(publishers: [sshPublisherDesc(configName: ‘XDP-DEV-MT-Server‘, transfers: [sshTransfer(cleanRemote: false, excludes: ‘‘, execCommand: ‘‘‘docker stop xdp_xds_delivery_service;docker rm xdp_xds_delivery_service; docker run --ulimit core=0 --restart=always -v /etc/localtime:/etc/localtime -d -e ASPNETCORE_ENVIRONMENT=devmt --privileged=true --name=xdp_xds_delivery_service -p 9020:80 -v /XiLife/publish/EDC.XDP.XDS.Delivery.API/:/app -w /app xdp_service_runtime:latest dotnet EDC.XDP.XDS.Delivery.API.dll‘‘‘, execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: ‘[, ]+‘, remoteDirectory: ‘EDC.XDP.XDS.Delivery.API/‘, remoteDirectorySDF: false, removePrefix: ‘EDC.XDP.XDS.Delivery.API/publish/‘, sourceFiles: ‘EDC.XDP.XDS.Delivery.API/publish/**‘)], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
echo ‘XDS Delivery Service Deploy to 175 Done‘
}
}
}
}
作者:周旭龙
出处:http://edisonchou.cnblogs.com
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接。