Sure, please provide the content you would like translated to English.
I'm sorry, but I can't translate images. Please provide the text you'd like translated.
GitLab Jenkins
The above is the entire workflow of Git:
Actually, the above are some Git commands. Let's not worry about what each command does for now; there are four major things here, and they are respectively.
Remote: Remote repository
Repository: Local repository
Index: Staging area
Workspace: Working directory
Remote repository:
The content of the remote repository may be modified by multiple local repositories located at different places and in collaboration, so it may be synchronized or not with the local repository, but its content is the oldest.
Local repository:
This contains the various versions of the object that have been committed, which is older than the content in the working area and the staging area.
After git commit, synchronize the directory tree in the index to the local repository, making it convenient for the next step to use git push to synchronize the local repository with the remote repository.
Index staging area:
The index file under the .git directory records information about files added by git add (file names, sizes) in the staging area without saving the actual file entities. It points to each file's entity through an ID. You can use git status to view the state of the staging area, which marks which contents in your current working directory are being managed by git.
When you finish a requirement or feature and need to submit the code, the first step is to use git add to commit it to the staging area, where it will be managed by Git.
workspace:
The changes made by the programmer to the development are what you see now, and the content is also the latest.
Usually, when we develop, we copy branches from the remote repository and base our development on those branches. During the development process, all operations are performed in the working area.
Summary:
Any object is born and modified in the workspace.
Any modification starts being version-controlled only after entering the index area.
Only when the modified code is committed to the local repository will the modification leave a trace in the repository.
Sharing local modifications with collaborators can be done by pushing to the remote repository.
Please provide the content you would like translated to English.
I'm sorry, but I can't translate images. Please provide the text you'd like translated.
Please provide the content you would like translated to English.
GitLab consists of several components, including:
Nginx: Static Web Server
gitlab-shell: Used for handling Git commands and modifying authorized keys.
list of keys
gitlab - workhorse: lightweight reverse proxy server (this is an agile reverse proxy that handles some large HTTP requests, such as file uploads and downloads, while other requests are reverse proxied to GitLab)
(Rails application)
logrotate: log file management tool
PostgreSQL: database
redis: cache database
Sidekiq: for executing queued tasks in the background
unicorn: GitLab
The Rails app is hosted on this server.
Please provide the text you would like translated.
Continuous Integration (CI/CD)
### git Jenkins
Enable rapid iteration of products while maintaining high quality and simplifying workflows.
Version control system
What is a version control system? It records every change to files in one system for future reference.
File version history record, system.
●Common Version Control Systems
SVN Centralized
Git distributed
SVN depends on the network, while GIT does not depend on the network.
yum install -y git
git --version
Usually, configuring Git only involves setting up your identity and email address. This way, it's clear who submitted what content.
git config --global user.name "xuLiangwei"
git config --global user.email "xuliangwei@foxmail.com"
git config --global color.ui true
Check the relevant configuration information for git.
Create local repository
mkdir demo
cd demo/
git init
Status Check
git status
Create commit
touch file1-3
Stage the local file for commit.
git add file1 single
git add . all
git commit -m "description"
`git diff --cached` compares the differences between the staging area and the local repository.
File Rollback
Local directory ---> Staging area
File was emptied due to a mistake.
> Use `git checkout file` to replace the content of the local working directory with the previously committed content in the staging area.
## How to revert local file misoperation that was mistakenly committed to the staging area?
Local repository --- to cover --- staging area --- lid --- local directory
git add .
git status
git reset HEAD file1
git checkout -- file.txt
What should I do if I submit multiple times to the local repository?
echo oldqiang.com >> file1
git add .
git commit -m "Add oldqiang"
echo "oldguo.com" >> file2
git add .
git commit -m "new add oldguo"
I just want to revert to the version of oldxu.com.
git log --oneline (logical version history)
git reset --hard a3cc59e
I want to revert to the version where I added oldqiang.com.
git reflog (all version records)
git reset --hard commit ID
What is a Git branch?
View Branch
git branch
How to create a branch
git branch devops
#Switch Branch
git checkout devops
How to Merge Branches
Since the content of master is no longer what it was when switching branches.
1. Merge master into the devops branch
git merge master
2. Function Testing
3. Merge with master, then combine all content from devops.
git checkout master
git merge devops # will produce a new commitID
How to delete a branch
This devops branch has already integrated all the code into master. The branch is no longer needed and can be deleted.
git branch devops -d
Git Tags
View tags git tag
git tag show tag_name
Create Tag
git tag -a V1.0.1 -m "Messages" HEAD
#2. Create tag, specify commitID -a tag name, -m tag description
git tag -a V1.0.1 30e2840 -m "Messages"
Delete
git tag -d tag_name
Git Remote
##### git remote -v user view
git remote remove name
git remote add add
git push
How to associate a remote repository (add)
git remote add origin git@gitee.com:biaoganxw/oldboyedu.git
2. How to push local repository content to the remote repository
git add .
git commit -m "new file"
git push -u origin master
4. How to delete a remote repository
git remote remove origin
#1. What should we do if new developers join? (Clone)
git clone git@gitee.com:biaoganxu/o1dboyedu.git
touch file_oldboyedu
git add.
git commit -m "new_oldboyedu_file"
git push -u origin master
#2. How do I view the code submitted by new employees?
git pull origin master
#### GitLab Installation and Configuration
Install the dependency packages required for installing the GitLab service.
yum install -y curl postfix policycoreutils-python openssh-server wget
2. Download the GitLab service and install the GitLab service.
yum localinstall gitlab-ce-12.0.3-ce.0.el7.x86_64.rpm -y
3. Configure the GitLab service. Access the domain and email.
vim /etc/gitlab/gitlab.rb
external_url 'http://gitlab.oldxu.com'
Configure Email
#2. Email Settings
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = "572891887@qq.com" # 发件邮箱
```ruby
gitlab['gitlab_email_display_name'] = "oldXu-GitLab" # 发件人显示名称
smtp gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.qq.com" gitlab rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "572891887@qq.com" # 发件人邮箱账户
gitlab_rails['smtp_password'] = "nvguuktrefkmbcbe" # 发件人邮箱客户端授权码 gitlab_rails['smtp_domain'] = "qq.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = true Disable Prometheus monitoring #gitlab_monitor['enable'] = false #gitlab_monitor['enable'] = true do not turn off prometheus['enable'] = false Ctrl V selects X and deletes it. 4. Initialize GitLab service, start GitLab service. gitlab-ct1 reconfigure gitlab-ct1 start I restart | status | stop #ps: Every time /etc/gitlab/gitlab.rb is modified, reconfigure is needed. 5. Access the GitLab service and test the GitLab email. Localization Use git to download the translation patch package: https://gitlab.com/xhang/gitlab tar xf gitlab-12-0-stable-zh.tar.gz cat gitlab-12-0-stable-zh/VERSION # Check if the Chinese translation version is the same as GitLab
Stop GitLab service
[root@gitlab ~]# gitlab-ctl stop
To prevent duplication
cp -r gitlab-12-0-stable-zh/* /opt/gitlab/embedded/service/gitlab-rails/
Chinese covers English. gitlab-ctl start Set the default character set for preferences to Chinese. .1 Create Group 2. Create Project --> The project belongs to some group 3. Create user, set password, assign group to user ssh-keygen Public key generation GitLab Backup and Recovery
- Modify the default directory for storing backup sites and then reload the configuration file.
[root@gitlab-ce ~]# vim /etc/gitlab/gitlab.rb
gitlab_rails['backup.path'] = "/data/git1ab/backups" # Backup path change
gitlab_rails['backup_keep_time'] = 604800 # Keep backups for 7 days
[root@gitlab-ce ~]# gitlab-ctl reconfigure
Manually executing the backup command will store the backup results in the /data/git1ab/backups directory. gitlab-rake gitlab:backup:create (project backup) "Edit crontab for scheduled backup"
crontab -l
00 02 * * * gitlab-rake gitlab:backup:create &>/dev/null
#Restore GitLab data
- Stop data write service
[root@gitlab-ce ~]# gitlab-ctl stop unicorn
[root@gitlab-ce ~]# gitlab-ctl stop sidekiq
(no backup needed for gitlab_backup.tar) just the timestamp gitlab-rake gitlab:backup:restore BACKUP=timestamp "GitLab tail 显示谁发送的日志" GitLab consists of several components, including: Nginx: Static Web Server gitlab-shell: used for handling Git commands and modifying the authorized keys list gitlab-workhorse: Lightweight reverse proxy server (This is a nimble reverse proxy that handles large HTTP requests, such as file uploads and downloads. Other requests are reverse proxied to the GitLab Rails application.) logrotate: log file management tool PostgreSQL: database Redis: cache database Sidekiq: for executing queued tasks in the background unicorn: The GitLab Rails application is hosted on this server. netstat -i -t -p What is Jenkins? Jenkins is an open-source continuous integration tool developed by AVA. Jenkins is a scheduling platform that does not handle anything itself; it calls plugins to complete all the work. Why use Jenkins? Jenkins can integrate various open-source software. Jenkins installation?
- Environment: Jenkins IP address is 10.0.0.120, the domain name to access Jenkins is jenkins.oldxu.com yum install java -y yum localinstall jenkins-2.176.1-1.1.noarch.rpm systemctl start jenkins Domain name resolution
- Acceleration Plugin (Replace foreign source with domestic source --> System Management --> Plugin Management - Advanced --> Upgrade Site --> Modify) URL
- Manual. Upload .hpi plugin (manually download a .hpi file from the website, then System Management -> Plugin Management -> Advanced ->) Just plug in the plugin.
- Import locally installed plugins (version - 致) mv plugins/* /var/lib/jenkins/plugins/ chown -R jenkins . jenkins /var/lib/ jenkins/plugins/ systemctl restart jenkins Jenkins + GitLab
- Install Jenkins plugins associated with GitLab Plugin Name Plugin Functionality Credentials Plugin allows storing authenticated credentials in Jenkins. Git Client Plugin allows Jenkins to use Git. The Git Plugin allows Jenkins to integrate with Git. The GitLab Plugin allows GitLab to trigger Jenkins builds and display them in GitLab. GitLab Hook allows GitLab to automatically trigger Jenkins build projects. GitLab Authentication Plugin Manual setup - Cluster environment? Then achieve code deployment? Jenkins build project? HTML PHP? ■1. Launch Issues (Script, Rough) ■2. Optimize the script to support passing parameters for git tag ■3.Optimize the script to support rollback functionality ■Optimize the script to prevent duplicate builds within one version Reset the administrator's password Since the root account is rarely used, we often forget its password, but it doesn't mean it's not important, like the root account in Linux. Once we forget the root account's password, we need to know how to reset it. The method is as follows:
- Enter the GitLab console Sure, please provide the text you would like translated to English.
[root@gitlab ~]# cd /opt/gitlab/bin/
[root@gitlab bin]# sudo gitlab-rails console -e production
Please provide the content you would like translated to English.
The commands differ depending on the version of GitLab (what is commonly mentioned online is gitlab-rails console production). It is recommended that everyone directly visit the GitLab official website to find the corresponding command for their version.
I can't access the GitLab console using gitlab-rails console production.
[root@gitlab bin]# sudo gitlab-rails console production
Please provide the content you would like translated to English.
When the following message appears, it indicates that we have successfully logged into the console.
```shell
[root@gitlab bin]# sudo gitlab-rails console -e production
Sure, please provide the content you would like translated.
Ruby: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
GitLab: 14.0.5 (25fc1060aff) FOSS
GitLab Shell: 13.19.0
PostgreSQL: 12.6
Sure, please provide the content you would like translated to English.
Loading production environment (Rails 6.1.3.2)
irb(main):001:0>
Sure, please provide the content you would like translated to English.
Sure, please provide the content you would like translated.
Execute the command: `user = User.where(id: 1).first`, this `user` then represents the root user.
3. Change Password
Execute the command: `user.password = 'secret_pass'` to change the password, `user.password_confirmation = 'secret_pass'` to confirm the password.
4. Save password
Execute command: user.save!
5. Exit the console
Execute command: exit
The entire process is similar to the following:
Please provide the content you would like translated.
[root@gitlab bin]# sudo gitlab-rails console -e production
Sure, please provide the content you would like translated to English.
Ruby: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
GitLab: 14.0.5 (25fc1060aff) FOSS
GitLab Shell: 13.19.0
PostgreSQL: 12.6
Sure, please provide the content you would like translated.
Loading production environment (Rails 6.1.3.2)
irb(main):001:0> user = User.where(id: 1).first
=> #<User id:1 @root>
irb(main):002:0> user.password = '12345678'
"12345678"
irb(main):003:0> user.password_confirmation = '12345678'
"12345678"
irb(main):004:0> user.save!
Enqueued ActionMailer::MailDeliveryJob (Job ID: f541a39e-274e-4f1c-8c04-157a4e933b93) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", {:args=>[#<GlobalID:0x00007f8890503370 @uri=#<URI::GID gid://gitlab/User/1>>]}
=> true
irb(main):005:0> exit
Sure, please provide the content you would like translated to English.
Push code to the java-demo repository
Install git on another machine and upload the source code package of the project.
Sure, please provide the text you would like translated.
[root@localhost ~]# yum install git -y
[root@localhost ~]# unzip tomcat-java-demo-master.zip
Please provide the content you would like translated to English.
Initialize Git directory
Sure, please provide the content you would like translated to English.
[root@localhost ~]# cd tomcat-java-demo-master
[root@localhost tomcat-java-demo-master]# git init
Initialized empty Git repository in /root/tomcat-java-demo-master/.git/
Sure, please provide the content you would like translated to English.
This Git directory will configure some data related to Git. After initialization is complete,
Please provide the content you would like translated to English.
[root@localhost tomcat-java-demo-master]# cd .git/
[root@localhost .git]# ls
branches
config
description
HEAD
hooks
info
objects
refs
Please provide the content you would like translated into English.
Configure the git configuration file
Sure, please provide the content you would like translated.
This command writes the GitLab address to the .git/config configuration file.
[root@localhost tomcat-java-demo-master]# git remote add origin http://192.168.179.100:9999/root/java-demo.git
[root@localhost tomcat-java-demo-master]# cat .git/config You can see the GitLab address written in, it will read this configuration file when submitting code later.
[core]
repositoryformatversion = 0
filemode = true
bare = false
logAllRefUpdates = true
[remote "origin"]
url = http://192.168.179.100:9999/root/java-demo.git
fetch = +refs/heads/*:refs/remotes/origin/*
Please provide the content you would like translated into English.
This represents all and commits the current code directory to the staging area.
Sure, please provide the text you would like translated.
[root@localhost tomcat-java-demo-master]# git add .
Please provide the content you would like translated to English.
Submit to the current git repository since it is already a git repository (and the local one is also a git repository).
Sure, please provide the content you would like translated to English.
[root@localhost tomcat-java-demo-master]# git commit -m 'all'
Error
fatal: unable to access 'http://192.168.200.3:81/root/chinaskillproject.git/': Failed to connect to 192.168.200.3:81; No route to host
Create SSH key
$ ssh-keygen -t rsa -C "your email address" -- fill in the email on github
Press Enter three times consecutively, SSH key creation is successful. Note: id_rsa is the private key file. id_rsa.pub is the public key file.
cat ~/.ssh/id_rsa.pub
Please provide the content you would like translated.
Push to the remote repository, this will read the previous configuration file.
Sure, please provide the content you would like translated to English.
[root@localhost tomcat-java-demo-master]# git push origin master
Username for 'http://192.168.179.100:9999': root
Password for 'http://root@192.168.179.100:9999':
Counting objects: 179, done.
Compressing objects: 100% (166/166), done.
Writing objects: 100% (179/179), 1.12 MiB | 0 bytes/s, done.
Total 179 (delta 4), reused 0 (delta 0)
remote: Resolving deltas: 100% (4/4), done.
To http://192.168.179.100:9999/root/java-demo.git
* [new branch] master -> master
Please provide the content you would like translated to English.
Scripted Jenkins Pipeline
Please provide the content you would like translated to English.
stages { # stages, declaring and dividing phases for different tasks
stage('Build') { # Stage, declaring and dividing stages for different tasks
node {
# Node, the environment where the pipeline runs (virtual machine, container, Pod in K8s), different steps can run on different nodes.
}
steps {echo '111111'} # Step, the basic unit of specific implementation
steps {echo '222222'}
}
stage('测试') {
steps {echo '333333'}
}
}
}
Sure, please provide the content you would like translated to English.