Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Basic construction of jenkins

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Introduction to Jenkins+Gitlab of continuous Integration [1]

Continuous integration concept

Continuous integration of Continuous Integration

Continuous delivery of Continuous Delivery

Continuous deployment of Continuous Deployment

1.1 what is continuous integration:

Continuous integration means that developers can frequently integrate code deployment into the trunk and automate testing in the process of code development.

1.3 what is continuous delivery:

Continuous delivery refers to the deployment of code to a pre-production environment based on a continuously integrated environment.

1.4 continuous deployment:

On the basis of continuous delivery, the process of deployment to the production environment is automated. The difference between continuous deployment and continuous delivery is that the final deployment to the production environment is automated.

1.5 deployment code launch process

1. Code acquisition (pull directly)

two。 Compile (optional)

3. Put the configuration file in

4. Packing

5.scp to target server

6. Remove the target server from the cluster

7. Extract and place it on Webroot

8.Scp difference file

9. Restart (optional)

10. test

11. Join the cluster

Operation and maintenance must know OWASP

Introduction of the OWASP plug-in on Jenkins: it is an open Web application security project [OWASP,Open Web Application Secunity Project]. It produces a security vulnerability for top10 every year. We need to know what the current top10 vulnerabilities are.

Https://www.owasp.org/images/5/57/OWASP_Proactive_Controls_2.pdf

Https://www.owasp.org/index.php/Top_10_2013-Top_10

Gitlab introduction

GitLab is an open source application developed using Ruby on Rails to implement a self-hosted Git project repository

Public or private projects can be accessed through the Web interface.

GitLab has features similar to Github, capable of browsing source code and managing defects and comments. Can manage the team to the warehouse

It is very easy to browse the submitted version and provides a library of file history. It also provides a snippet collection feature that can

In order to easily achieve code reuse, it is easy to find it when needed in the future.

Environmental preparation

Upload the required installation package

Install and deploy gitlab

1. Install gitlab

Rpm-ivh gitlab-ce-11.9.8-ce.0.el6.x86_64.rpm

two。 Initialize gitlab

Gitlab-ctl reconfigure

3. The browser logs in to gitlab

4. Create a new project

Generate the key in Linux and copy

Ssh-keygen-t rsa generate key

Cat / root/.ssh/id_rsa.pub view the key and copy

Place the key

Enter your own project

5. Set up the project in linux

Refer to the introduction on web

(1) create users and required mailboxes to identify themselves

[root@localhost] # git config-- global user.name "admin" [root@localhost ~] # git config-- global user.email admin@admin.com

(2) Clone a warehouse

Git clone git@192.168.1.40:root/xgp-demo.git [root@localhost ~] # cd xgp-demo/ enter library [root@localhost xgp-demo] # vim index.html create test file [root@localhost xgp-demo] # git add index.html upload test file to cache [root@localhost xgp-demo] # git commit-m "1" upload to board library [root@localhost xgp-demo] # git push-u origin master upload to run warehouse

(3)。 Modify the configuration file

[root@localhost xgp-demo] # vim / etc/gitlab/gitlab.rb external_url 'http://192.168.1.40' # 13 line

(4)。 Reinitialize it.

Gitlab-ctl reconfigure

Install and deploy jenkins

Jenkins introduction

Jenkins is just a platform, and what really works is plug-ins. This is why jenkins is popular, because jenkins has all kinds of plug-ins. Hudson, the predecessor of Jenkins, is a continuous integration tool developed based on Java to monitor the repetitive work of programs.

Hudson was later acquired and became a commercial version. Later, the founder wrote another jenkins, and jenkins is far more functional than

Hudson

Jenkins official website: https://jenkins.io/

Jenkins is written by Java, so you need to install JDK first. Yum installation is used here. If you need a version, you can

Download JDK directly from the Oracle website.

Installation

1. Install JDK

Rpm-ivh jenkins-2.172-1.1.noarch.rpm

two。 Modify JDK configuration file

Vim / etc/sysconfig/jenkins

JENKINS_PORT= "8081" # modify port 56

3. Start JDK and view the port

/ etc/init.d/jenkins start # launch

Netstat-anpt | grep 8081 # View port

Jenkins Web access address: 192.168.1.40 purl 8081

Linux view the password and copy it to the web page, then click continue

[root@localhost ~] # cat / var/lib/jenkins/secrets/initialAdminPassword

Bb220f4cf61d46999ba7f6686eeecf32

(1) installation method 1

Copy the ID under this file, otherwise you can't install it. We can choose the recommended installation.

Set the username and password:

Click Save and exit

(3) installation method 2

[root@localhost ~] # tar zxf jenkins-plugins.tar.gz # unpack the required installation package [root@localhost ~] # rm-rf / var/lib/jenkins/plugins/ # Delete the directory [root@localhost ~] # mv plugins/ / var/lib/jenkins/ # move the replacement directory over [root@localhost ~] # / etc/init.d/jenkins restart # restart JDKRestarting jenkins (via systemctl): [OK]

Check the browser.

Linux view the password and copy it to the web page, then click continue (remember to disconnect)

[root@localhost ~] # cat / var/lib/jenkins/secrets/initialAdminPassword

Bb220f4cf61d46999ba7f6686eeecf32

3. After installation, check out the plug-in.

Jenkins+Gitlab of continuous Integration to realize continuous Integration [2]

Project: continuous integration using git+jenkins

(1) method 1

Source code management

We installed the git plug-in, and we can also install the svn plug-in

You also need permission authentication to store the git path here, otherwise there will be error.

Cat / root/.ssh/id_rsa view key mode

Let's add a certification.

Now that we copy the url of git, there will be no verification prompt.

(2) method 2

After saving, we chose to build immediately

Build successfully

Check it on Linux

Automatically build and install plug-ins

Go to the place where you checked the plug-in before.

System settings-plug-in management-advanced _-- upload plug-ins gitlab-oauth, gitlab-plugin, windows-slaves, ruby-runt ime, gitlab-hook

Build trigger (xgp changed to x)

X-demo--- configuration-build trigger-check trigger remote build-- build token 238e3f0ed60b9bc795f3 generated by identity token (execute openssl rand-hex 10 at the end)

Check Build when a change is pushed to GitLab

-- Save

Openssl rand-hex 10 generates ten-digit tokens

Go back to the web page of git1ab

Click projects--your project--web- demo--settings-- Integrations-- JENKINS_ URL/ job/web- demo/build?token=TOKEN NAME--uncheck Enable SSL verification

Error is reported after confirmation: solution

Go back to the web page of git1ab-Click the small pliers-settings---Ne twork-0utbound requests---- check Allow requests to the local ne twork (allow local requests)

Click projects--your project--web- demo--settings-- Integrations-- JENKINS_ URL/ job/web- demo/build?token=TOKEN NAME- again-uncheck Enable SSL verification

4. Test it

You can see that there is another error: the solution.

Go back to the jenkins page

System management-global security settings-authorization policy-uncheck to prevent cross-site request forgery

Check anonymous users to have readable permissions

System management-system settings-uncheck Enable authentication for'/ project' end-point

Go back to gitlab and test it.

Success

Create a test file on Linux and test it again

49 cd xgp-demo/50 vim xgp.txt51 git add xgp.txt 52 git commit-m "web hook" 53 git push origin master

Check the jenkins of the web interface.

The experiment is over

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report