In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1. Jenkins and continuous Integration 1) what is Jenkins?
Jenkins is an open source software project that aims to provide an open and easy-to-use software platform and make continuous integration of software possible. Jenkins is a continuous integration tool developed based on Java to monitor continuous repetitive work, with features such as:
1) continuous software release / test project
2) monitor the work performed by external calls
Friends who are interested in Jenkins can refer to Jenkins Chinese documentation.
2) what is continuous integration? 1) what is integration?
It refers to a process in which the code is compiled, released, tested, and launched!
2) what is continuous integration?
Efficient, continuous iterative code integration work!
3) how to achieve continuous integration efficiently and accurately?
It is essential to need an automated and visual platform to help us!
Second, why can Jenkins help us with continuous integration? 1) Jenkins is an open source continuous integration system based on JAVA code development.
Because it contains very rich plug-in support, we can easily get through all aspects of the version library, test build environment, and online environment. And rich and friendly notification users and developers, managers.
2) simple installation and maintenance
Installing Jenkins is not too complicated. And supports a common platform.
3) Java applications are commonly used
In the process of enterprise software construction, the application engineering of JAVA is slightly complex, due to complex construction and code online, and the restart of services. The whole process takes a lot of time, but Jenkins can well integrate the compilation mode of maven, and uses the support of automated plug-ins and custom development scripts. Therefore, it is widely used in the continuous integration platform of JAVA project.
Most of the software packages used next are downloaded from the open source mirror station of Tsinghua University!
3. Deployment installation Gitlab1) install gitlabs [root @ jenkins ~] # yum-y install epel-release curl openssh-server openssh-clients postfix cronie policycoreutils-python# installation depends on [root@jenkins ~] # wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm# to get the gitlabRPM package [root@jenkins ~] # rpm-ivh gitlab-ce-12.3.5-ce. 0.el7.x86_64.rpm# installs the gitlab package [root@jenkins ~] # vim / etc/gitlab/gitlab.rb external_url 'http://192.168.1.10'# to change to the local IP address It is easy to access [root@jenkins ~] # gitlab-ctl reconfigure# to reconfigure gitlab. Even if you do not modify the configuration file, you need to reconfigure gitlab [root@jenkins ~] # netstat-anpt after installation | grep-w 80 # make sure that port 80 is listening. 2) configure gitlab
As shown in the figure:
3) generate a key pair to facilitate ssh to log in to [root@jenkins ~] # ssh-keygen-t rsa-C "1454295320@qq.com" # to generate a key pair [root@jenkins ~] # cat ~ / .ssh/id_rsa.pub # to view the public key and copy ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDuyAYPbmf92Pi6OOfcbdi7BCxN+Fq1c5lc4YAQhM8420mwfT4WltUOSXUidxR2oT3ViXSxwzlOr+XoHJ4YJEeQ3jIeXr5aSwtU5YTNgvVA+SYk0uvPLJg11NdEuMkSIB2K8PJ9zSxvppKbAkynmLEyZ1n61j5NbbApjgMslUqdB10vWowSE/Xoo11ugooQH2y3GxVrSv/EMeaVkToMVFM7BWx0pLBLi+tMJpb6Aj0pOSyv5rBj0hA1+2qrPQ3DtJc4QGMK+FRyxw/N13slfmoLzZ+6bF9oyNQZNWa9isL5C80srZhF7JkCrscYMIo0hOCkYOLVGJDFSgxiceG9ZmYh 1454295320@qq.com
Next, you need to do something on the web page. As shown in the figure:
4) create a library
As shown in the figure:
5) the local server tests [root@jenkins ~] # git clone git@192.168.1.10:root/test01.git# to perform the clone operation, and enter yes for the first time according to the prompt! [root@jenkins ~] # cd test01/ [root@jenkins test01] # lsREADME.md# enter the cloned library to check whether it is consistent with the content of the library created on the web page [root@jenkins test01] # git config-- global user.name admin [root@jenkins test01] # git config-- global user.email admin@admin.com# self-report Simply declare the user name and email address [root@jenkins test01] # echo "hello world" > 123.txt [root@jenkins test01] # git add 123.txt [root@jenkins test01] # git commit-m "commit form local first" # create a file to test [root@jenkins test01] # git push origin master# push the local test file to the remote (gitlab) 6) gitlab verification
After refreshing the page, as shown in the figure:
This is the end of the configuration of gitlab, and then install Jenkins!
IV. Deploy and install Jenkins1) install Jenkins [root @ jenkins ~] # wget https://mirrors-i.tuna.tsinghua.edu.cn/jenkins/redhat/jenkins-2.172-1.1.noarch.rpm# get the Jenkins package [root@jenkins] # rpm-ivh jenkins-2.172-1.1.noarch.rpm # install Jenkins [root @ jenkins ~] # rpm-ql jenkins # View the location of Jenkins-related files [root@ Jenkins ~] # sed-I's Universe Port = "8080" / JENKINS_PORT= "8081" / g'/ etc/sysconfig/jenkins# because the components of gitlab have occupied port 8080 Therefore, you need to change the listening port [root@jenkins ~] # / etc/init.d/jenkins start # to start the Jenkins service [root@jenkins ~] # ss-lnt | grep 8081 # make sure that the port is listening to LISTEN 050: 8081: * 2) the configuration of the Jenkins web page
As shown in the figure:
[root@jenkins ~] # cat / var/lib/jenkins/secrets/initialAdminPasswordc6e0fcde793648e9b4bad088e8896897# view password information and copy it
Because it takes a long time to download its plug-in, use another approach:
After installing a plug-in, disconnect the network! Download the required software
[root@jenkins] # tar zxf jenkins-plugins.tar.gz-C / var/lib/jenkins/ [root@jenkins ~] # / etc/init.d/jenkins restart
Visit the web page again, as shown below:
You can already see Jenkins's work page!
3) configure the warehouse code for Jenkins to pull Gitlab
As shown in the figure:
Because of the SSH approach used to get the code, a key pair is required. The public key has been stored on the gitlab. The error message in the scarlet letter above is that the private key cannot be found, so you need to add the private key manually!
[root@jenkins ~] # cat ~ / .ssh/id_rsa # View the private key and copy the whole content-BEGIN RSA PRIVATE KEY-MIIEpAIBAAKCAQEA3uXh+36ATD8j2CQGovVpPUvIF6kFf2ei6YseQjQ6wcnpou9NxjhWmzJ2LKinnfS0SJ9QsuM1b7i0EJal8VyOql2H1aeQ93y/awVavN5Z5+68zgKv/PdDRDK9EDd5ANWP9YiTpeoXPL6aupF4BsAKpmYtQrY1ApEeDMc9KMI7cT33+MW7GdSRYPxHMH0NRtamEbRasJhBQbUlrDb3HpAUz0Xax9CTQzIBxLeRE/Fpq2+pG2iDc+LzLYEGSswX/u2QPE3uRkZFM7mit3NS/PRslzF1RuYMWNoYo9pnSCOOkWCM+QxxNvIMGIkbEs5RnU/m5Y9CaycD2x6RKNcO84nYPQIDAQABAoIBAQCC893zalun8AR4DJ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z/A4Y19ifWkP3yimnjFKUuwaQCsFl/mnqxsSy62onaqdiEMIw/00ouWbi9v11Nl0ulLzSylkMQNdraUsH3BkW2fNNSKWDLAyFAr4uL5xo30SUE0oX/v6MNdaTXmZrNg==-END RSA PRIVATE KEY-
The server detects the synchronized data:
[root@jenkins ~] # ls / var/lib/jenkins/workspace/web01123.txt README.md [root@jenkins ~] # cat / var/lib/jenkins/workspace/web01/123.txt hello world 5. Configure Jenkins+gitlab to achieve continuous automatic integration
In the following configuration, for speed and convenience, it is recommended to download the plug-in provided by me.
The configuration is shown in the figure:
Upload the packages I provided in the following order: gitlab-oauth-- > gitlab-plugin-- > windows-slaves-- > ruby-runtime-- > gitlab-hook!
If you want to install the plug-in online, you can change the plug-in source to the URL of the Jenkins Mirror Station of Tsinghua University. A link to the changed method is attached here, and you can change it yourself!
The modifications are as follows:
This is the end of modifying the plugin address!
Since most of the next steps are mouse clicks, only the key pictures are attached here!
Click: system Administration-> Global Security configuration-- > Authorization Policy
Click: system Management-> system Settings
After the above operation is completed, do the following:
Generate a token at the terminal and copy:
[root@jenkins ~] # openssl rand-hex 10 # copy the following content a13d2c8d22991c70a9e5
Go back to the web page of Gitlab and do the following:
Next you need to go to the Jenkins page to find the URL you need! As follows:
We need to splice the URL of Jenkins: the access address of Jenkins + / the content of job....= authentication tokencode stitching: http://192.168.1.10:8081/job/web01/build?token=a13d2c8d22991c70a9e5
Then, for the gitlab page, enter the URL of Jenkins, as shown in the figure:
After the addition is complete, drop down the page and do the following:
At this point, the continuous deployment is complete, and the next step is testing. Submit the code to gitlab on the terminal to check whether Jenkins has automatic synchronization, as shown below:
# push the new code [root@jenkins ~] # cd test01/ [root@jenkins test01] # echo "123456" > test.txt [root@jenkins test01] # git add test.txt [root@jenkins test01] # git commit-m "commit form local second" [root@jenkins test01] # git push origin master to gitlab
Jenkins can see the following to show that the continuous deployment configuration is complete!
From the information output from the console, you can see that the code has been synchronized successfully, so check it locally!
[root@jenkins ~] # cat / var/lib/jenkins/workspace/web01/test.txt 12345 is the same as the document we just submitted
-this is the end of this article. Thank you for reading-
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
Solve the problem that XP cannot turn on firewall Msconfig: illegally disable service
© 2024 shulou.com SLNews company. All rights reserved.