Netcore programming to face the unaccustomed Xshell black screen deployment, it is time to use the Jenkins Automation publishing tool

Source: Internet
Author: User
Tags dotnet mkdir svn memsql


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:, 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 Jenkins.reposudo rpm--import

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: 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 = (() =            {                 for(inti =0; I < +; i++) { ($"I={i}"); Thread.Sleep ( +);            }            }); AppDomain.CurrentDomain.ProcessExit+ = (s, e) = ={ ($"{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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.