Easiest way to deploy automatic builds over remote server

in devops •  6 years ago  (edited)

In this blog, I will write down the details about how to deploy code to a remote server using Continuous Integration pipeline with GitLab repository and Jenkins as an automation tool for CI/CD.

Step 1: click on New Item from Jenkins Dashboard
Screenshot_2019-04-17 Dashboard [Jenkins].png

Step 2: Create Free style project
Enter an item name (ex: demo)
And choose Freestyle Project
Screenshot_2019-04-18 New Item [Jenkins].png

Step 3:
Click on "Ok", at the end of that page while scrolling down.

Step4:
Now configure the job
-->Give some general description of the job.
-->Discard old builds to keep you Jenkins server light weighted.
-->Select default Strategy Log Rotation
-->Can select Days to keep builds or Max # of builds to keep as per requirement.
-->Now create a GitLab Connection
Screenshot_2019-07-26 sails-backendapp Config [Jenkins](4).png

Following are the process to create GitLab connection.

i) Create a developer account in GitLab and generate access token under user settings.

Screenshot_2019-07-26 Personal Access Tokens · User Settings.png

ii) Prerequisite for this step is few plugins needed to be installed as below In Jenkins

Screenshot_2019-07-26 Update Center [Jenkins].png

iii) Using the access token gitlab connection needs to be set up.

Screenshot_2019-07-26 Configure System [Jenkins](1).png

Step 5: Source Code Management
Choose Git repository and input Repository URL in given box
Screenshot_2019-07-26 sails-backendapp Config [Jenkins].png

Credentials to the gitlab repository access should be created in jenkins credentials beforehand.

Screenshot_2019-07-26 System » Global credentials (unrestricted) » dipanwita das (gitlab ncportal) Config [Jenkins].png

Specify the branch to build.
Mention Repository browser, select gitlab and insert URL and version.

Step 6: Build Triggers
Select Build when a change is pushed to GitLab. GitLab webhook URL: "JenkinsHostName:Port"/project/"projectname" and schedule Poll SCM which will trigger build for certain interval

Screenshot_2019-07-26 sails-backendapp Config [Jenkins](1).png

Step 7: Build Environment

Select options whichever is necessary according to the need
Screenshot_2019-07-26 sails-backendapp Config [Jenkins](2).png

Step 8 : Build
Set up certains post build actions such as archiving code artifacts. Files to be included can be set up here.
Screenshot_2019-07-26 sails-backendapp Config [Jenkins](3).png

Step 8a: As the code should be deployed over remote server ssh needed to be integrated. In advance options if certain files needed to be excluded from build can be done.
Screenshot_2019-07-26 ncportaltest-upgraded Config [Jenkins].png

For this step SSH servers should be set up in Jenkins configuration
Screenshot_2019-07-26 Configure System [Jenkins](2).png

That's all now workspace can be deleted once build is done to minimize jenkins server load as post build action and email notifications can be set up as per requirement.

Now the job can be saved.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Congratulations @dipanwita! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!