A long time ago, net can only be deployed on windows, perhaps a lot of startup company friends release projects are human deployment, anyway, Windows is a visual interface, procrastination, switch off is not
is particularly troublesome ... Now your project needs to be deployed on Linux, unfortunately there is no visual interface to you, all on the Xshell, if the Xshell on the deployment of single-digit projects you may also
To accept, if you want to deploy more than more than the service, it is estimated that many people on the Xshell on the head is big ... That's why Docker has dockerfile, there will be container docker-compose, so find
An automated publishing tool is in the offing.
One: Jenkins deployment
Its official website is: jenkins.io/download/, using Docker mode deployment is too simple, this article does not use Docker deployment, but directly deployed to the host CentOS, such as:
1. Import the Jenkins key
sudo wget -o/etc/yumrepos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/ Jenkins.reposudo rpm--import https://Pkg.jenkins.io/redhat-stable/jenkins.io.key
2. Installing with Yum
Yum Install Jenkins
3. Start Jenkins
[Root@localhost ~] # Service Jenkins start Starting Jenkins (via Systemctl): [ OK ]
4. Then enter your virtual machine ip:http://192.168.23.173:8080 in the browser, and see the following interface even if it succeeds.
Then you can follow the steps step by step down.
Two: Build your Netcore program
A simple test program is provided for subsequent automation deployments only.
Static voidMain (string[] args) { varBgtask = Task.run (() = { for(inti =0; I < +; i++) {Log.info ($"I={i}"); Thread.Sleep ( +); } }); AppDomain.CurrentDomain.ProcessExit+ = (s, e) = ={log.info ($"{DateTime.Now} Congratulations, Testservice Service program is ready to quit! "); Environment.exit (0); }; Bgtask. Wait (); }
Three: Jenkins Configuration
1. Click New Task
2. Choose to build a free-style software project, then click OK
3. Here the "Source Management" tab is very important, the default support Git and SVN, here to choose SVN, the address you generate SVN paste up, because the subsequent
when you execute a shell script, the Jenkins the workspace folder in which dotnet publish is executed.
4. In the "Build" tab page, the most important thing is the shell script inside.
PS grep grep grep awk ' {print $} ' Xargs --no-run-ifkillCD. /memsql.testmkdir -p/data/output/memsql.test/-o/data/output/memsql.test/v${ Build_number}-/data/output/memsql.test/v${build_number}build_id=dontkillme nohup dotnet MemSql.Test.dll &
Here are some of the places to be concerned:
"1" in the Kill PID, if the PID does not exist, your default script will report the PID does not exist error, so add--no-run-if-empty if judgment, no
Kill is not executed.
"2" uses a Jenkins environment variable {build_number}, which is the location in which the compiled version number is used as a folder.
"3" because I use nohup to generate a background process, so use the Dotkillme command to let Jenkins do not kill it after the build is finished.
Then click Save and the automated deployment of this test project is done ...
Four: Operation Flow
Before the operation, be sure to let Jenkins users elevate permissions, or your copy,mkdir may not have enough permissions, here I ascend to root.
1: Add the Jenkins user to the root group.
Gpasswd-a Root Jenkins
2: Modify the/etc/sysconfig/jenkins file to change the original users= Jenkins to root.
# Unix user account that runs the Jenkins daemon# is careful when you change this, as you need to update# permissions of $ Jenkins_home and/var/log/jenkins. #JENKINS_USER = "root"jenkins_group= "root "
3: Restart Jenkins
Service Jenkins Restart
4. Then your steps are:
"1" commits the code in SVN.
"2" Find your project and click "Build Now".
Of course, it can also be built by Jenkins Automation, but considering the build project, it is best to add a manual release of this button, safe and reliable, after the build, you can look at the "console output" Jenkins.
Then you can go through the FTP production to see, sure enough to run, V21 is my build version number, and your log is really my business logic output, right, such as:
At this time, you think the code is a problem, need to modify, change I to M, the next step is "Submit Code", "visual compile immediately" and "view results" such as the pipeline operation is ....
Well, this article is here, and I hope it will help you.