Notes--git/gitlab

    -------gitlab------- --Installation
        :
            rpm -i gitlab-ce-XXX.rpm
            systemctl enable gitlab-runsvdir.service
            systemctl start gitlab-runsvdir.service
            gitlab-ctl start/status/ stop
            configuration:
                vim /etc/gitlab/gitlab.rb
                    external_url'http : //172.19.2.191 '
            finished:
                patch -d /opt/gitlab/embedded/service/gitlab-rails </root/gitlab/hanhua/v9.5.10 -zh.diff
        
        --gitlab-runner
            1 Install gitlab-ci-multi-runner
            
            2 Register
                gitlab-ci-multi-runner register
                #The required url and token are obtained from the configuration of gitlab--》Runners
            
            3 Enable
                gitlab Runners, enable in the specified project
                
            4 Modify the configuration file working directory
                ]# cat /etc/gitlab-runner/config.toml
                concurrent = 1
                check_interval = 0

                [[runners]]
                  name = "191"
                  url = "http://192.168.80.191/"
                  token = "xxxxxxxxxxxxxxxxxx"
                  executor = "shell"
                  builds_dir = "/home/gitlab-runner/builds"
                  cache_dir = "/home/gitlab-runner/cache"
                  [runners.cache]
            
            5 在项目根目录下,vim .gitlab-ci.yml
            
            6 推送,如:
                git commit -am 'update gitlab-ci.yml'
                git push origin v1.0
            
        -- .gitlab-ci.yml
            简单示例:
                stages:
                  - build

                zip:
                  stage: build
                  script:
                   -export relend=`bash /home/gitlab-runner/scripts/serial.sh ${CI_PROJECT_NAME}_${CI_COMMIT_REF_NAME}`
                   -zip ${CI_PROJECT_NAME}_${CI_COMMIT_REF_NAME}.${relend }.zip
                   ./* # $CI_PROJECT_NAME project name
                   # $CI_COMMIT_REF_NAME branch name
                   # $CI_PIPELINE_ID Pipeline ID
                   # More variables https://docs.gitlab.com/ee/ci/variables/predefined_variables.html-scp
                   *.zip cscloud @172.17.1.1:/home/smbuser/tmp/MyProject/ #After packaging, the push location needs to be configured with the password-free login
            
            example of the gitlab-runner user . The serial number generation script serial.sh in the example:
                #! /bin/bash
                version=$1                 #The
                version name names a file
file="/home/gitlab-runner/cache/${version}" #Add
                1 to the serial number for each build
                if [-f "${file}" ];then
                        i= `cat ${file}`
                        let i++
                else
                        i=1
                fi

                echo $i >${file}
                echo $i

    git ------ -------
        - initialize
            git the init
            . the Add git
            git Checkout -b 'v2020.05.20' # we must first create a branch, and then commit, otherwise there will be master branch
            git commit -m "Initial commit"
            git remote add origin [email protected]:shell/sqlscripts.git
            git push -u origin --all --clear
        all changes, re-pull the code
            git reset --hard
            git pull

Guess you like

Origin blog.csdn.net/weixin_42573277/article/details/114996447