Jenkins-git-php

1864 ワード

1.環境準備
    git   : 10.10.95.2   
    web   : 10.10.95.3
    jenkins   :10.10.95.4

2.git倉庫を作成し、ローカルPipelineプロファイルを受信する
    su - git
    mkdir  -p  /home/git/repos/jenkinsfile
    git --bare init   #     

3.webサーバフォルダを作成しgitサーバを引っ張る
    /root/sxw/jenkinsfile
    vi jenkinsfile
    git clone [email protected]:/home/git/repos/jenkinsfile
    vi jenkinsfile-php     #   Pipeline   
    git add .
    git commit -m ""
    git push origin master

4.jenkinsfile内容
node ("web") {          //  slave   
   stage('git checkout') { 
      checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [],
 submoduleCfg: [], userRemoteConfigs: [[url: '[email protected]:/home/git/repos/wordpress.git']]])   //      
   }
   stage('code copy') {
        sh '''rm -rf ${WORKSPACE}/.git
        mv /usr/share/nginx/html/www.compress.com /data/backup/www.compress.com-$(date +"%F_%T")
        cp -rf ${WORKSPACE} /usr/share/nginx/html/www.compress.com'''
   }
   stage('test') {
       sh "curl http://www.compress.com/status.html"
   }
}

5.EPELソースのインストール
    yum install -y epel-release

6.EPELソースインストールnginx php
    yum install -y nginx  php-fpm

7.PHP mysql拡張オプションのインストール
    yum install -y php-mysql

8.mysqlサービスをインストールする
    yum install mariadb-server -y

9.起動
    systemctl start php-fpm
    systemctl start nginx
    systemctl start mariadb

10.データベースへのログイン
    mysqladmin -uroot  password “123456”

11.ローカルhostパラメータを変更し、ローカルアクセスドメイン名を構成する