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

Jenkins deployment applications (docker version)

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

Share

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

I. Install 1.docker image run jenkins installation detailed steps refer to the official document https://jenkins.io/zh/doc/book/installing/docker run\-u root\-rm\-d\-p 8080jenkins 8080\-p 50000VRV jenkins-data:/var/jenkins_home\-v / var/run/docker.sock:/var/run/docker.sock\ jenkinsci/blueoceandocker prompt that the forwarding solution is not enabled Vim / usr/lib/sysctl.d/00-system.confnet.ipv4.ip_forward=1 # newly added

Restart network

Browser access port 8080

If the interface prompts that Jenkins is starting, please wait. Or hint.

Please wait while Jenkins is getting ready to work...

Solution:

I need you to enter the working directory of jenkins, open hudson.model.UpdateCenter.xml and change http://updates.jenkins-ci.org/update-center.json to http://mirror.xmission.com/jenkins/updates/update-center.json.

Jenkins slow solution to offline and plug-in installation cd / var/jenkins_home/updates/ sed-I 's/http:\ /\ / updates.jenkins-ci.org\ / download/https:\ /\ / mirrors.tuna.tsinghua.edu.cn\ / jenkins/g' default.json & &\ sed-I' s/http:\ / www.google.com/https:\ / www.baidu.com/g' default.json time inconsistency solution

The Docker container time is synchronized with the host time

Docker cp / usr/share/zoneinfo/Asia/Shanghai jenkins02:/etc/localtime

Incorrect time on Jenkins system

Quite simply, click system Management and select execute script command:

Open [system Management]-> [script Command Line] and run the following command

System.setProperty ('org.apache.commons.jelly.tags.fmt.timeZone',' Asia/Shanghai')

2.docker runs gitlab first to create three directories that need to be mounted: configuration (etc), log (log), Data (data) mkdir-p / mnt/gitlab/etcmkdir-p / mnt/gitlab/logmkdir-p / mnt/gitlab/data run gitlabdocker container run-it\-p 8090 mnt/gitlab/logmkdir 80-p 8443 mnt/gitlab/etcmkdir 22\-- restart unless-stopped\-v / mnt/gitlab/etc:/etc/gitlab\-v / mnt/gitlab/log:/var/log/gitlab\-v / mnt/gitlab/data:/var/opt/gitlab\-- name gitlab gitlab/gitlab-ce:latest enters the container to modify the configuration

Change external_url to the domain name or IP address of the deployment machine

Vim / etc/gitlab/gitlab.rbexternal_url 'http://192.168.100.107'gitlab_rails['gitlab_ssh_host'] =' 192.168.100.107'gitlab_rails ['gitlab_shell_ssh_port'] = 8022gitlab_rails [' gitlab_shell_git_timeout'] = 800

Restart the container

Docker restart gitlab

Modify the cloned port. The default is 80, but we mapped it to 8090, so we need to modify it.

Every time you restart the container, you need the executor to take a step.

Enter the container to execute

Root@6129313605ed:/# cd / var/opt/gitlab/gitlab-rails/etc/vim gitlab.yml gitlab: # # Web server settings (note: host is the FQDN Do not include http://) host: 192.168.100.107 port: 8090 # modified here to 8090 https: falsegitlab-ctl restart# restart several commonly used Gitlab commands # reapply gitlab configuration gitlab-ctl reconfigure# restart gitlab service gitlab-ctl restart# view gitlab running status gitlab-ctl status# stops gitlab service gitlab-ctl stop# view gitlab operation log gitlab-ctl tail# stops related data connection Service gitlab-ctl stop unicorngitlab-ctl stop sideki II. Jenkins Application 1.jenkins Rights Management installation plug-in:

Enable plug-in

Click on system Management at this time, and there will be one more item: Manage and Assign Roles

Create a user: deva

Click

Assign users using Manage and Assign Roles Management

Manage user

Assign users

In this way, deva users can only see the job of dev- and only have permission to execute job.

2.jenkins execution script writes a test script on the node and gives the script execution permission [root@vm2 ~] # cat test.sh #! / bin/bashecho lingxdecho $1 to create a free-style job

Parameterized construction

Click build to select parameters

A preliminary study of 3.pipeline to create job

Configuration

Script content

Node {stage ('Code PUll') {echo "Code PUll" git credentialsId:' ee5eb9ea-39a9-48c3-9b02-0b6985ed092a' Url: 'http://192.168.100.117:8090/root/bk.git'} stage (' Code Build') {echo "code build" sh'/ root/mvn/apache-maven-3.6.3/bin/mvn clean compile'} stage ('Unit Test') {echo "unit test"} stage (' whether to deploy') {input 'deployment test Environment'} stage ('Deploy Test ENV') {sh' / root/test.sh 123'} 4.Jenkins and gitlab integration automatically triggers the jenkins plug-in management to install the GitLab Plugin plug-in

Go to gitlab to generate token

System Administration-- > system configuration gitlab

Create pipeline type job

Log in to gitlab configuration project integration and add webhook

First click to enter the project you want to configure, find the settings, and click integrate.

For the url and token to be filled in above, see the previous step.

If the creation of webhook fails, it is prompted that local network authentication is not allowed. You need to set it in Settings.

In this way, the dev branch automatically triggers the job of the jenkins whenever the code is submitted.

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