20. RhodeCodeとJenkinsを利用したSphinxのWebサイト作成

20.1. 概要

  • SphinxのプロジェクトをMercurial/RhodeCodeで管理する
  • JobサーバのJenkinsでリポジトリ更新を感知し、Webサイト更新を自動的にかける

20.2. Mercurialの導入

  • 作業端末にMercurialを導入する
  • ローカルのSphinxプロジェクトをMercurialで管理する
    • TortoiseHG

20.3. Jobサーバの構築 基本設定

  • OSのインストール
    • CentOS6.3
    • ssh
    • ntp

20.4. Jobサーバの構築 Pythonの導入

  • Pythonのパッケージ管理ツールをインストール

20.5. Jobサーバの構築 Mercurialの導入

  • サーバでMercurialのインストール

20.6. Jobサーバの構築 Sphinxの導入

  • Sphinxの導入
    • Sphinxと各種プラグイン

20.7. RhodeCodeの構築

  • RhodeCodeのインストール

    pip install rhodecode -U

  • RhodeCodeの設定

    • 検証機見てconfig張る
    • ログの設計、設定
    mkdir -p /var/rhodecode/
    cd /var/rhodecode/
      paster make-config RhodeCode production.ini
      ls
        production.ini

paster setup-rhodecode production.ini

Are you sure to destroy old database ? [y/n]y

Enter a valid absolute path to store repositories. All repositories in that path will be added automatically:

/var/rhodecode/repo

Specify admin username:nesapo-admin

Specify admin password (min 6 chars):netsupport

Specify admin email:education@n-support.jp

  • 起動

    paster serve production.ini

  • 起動スクリプト作成

    • 別紙
  • アカウント作成

    • kyoshimi
    • goyamada
    • ituka
    • saeki
    • matsui
    • sanpei
    • nesapo-admin
  • リポジトリ作成

hg clone http://goyamada@172.30.18.5:8888/rhodecode/education/sitetop

hg push http://goyamada@172.30.18.5:8880/rhodecode/test_repositry

hg clone http://goyamada@172.30.18.5:8880/rhodecode/education/taiki-report

20.8. Jobサーバの構築 Jenkinsのインストール

  • yumでJenkinsインストール

  • Javaインストール:

    wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
    rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
    yum install jenkins
    yum -y install java-1.6.0-openjdk.i686

20.9. Jobサーバの構築 Jenkinsの設定

  • nesapo-admin

セキュリティの有効

https://wiki.jenkins-ci.org/display/JA/Standard+Security+Setup

vim /etc/sysconfig/jenkins 19 JENKINS_JAVA_CMD=”” 29 JENKINS_USER=”jenkins” 47 JENKINS_PORT=”8080” 57 JENKINS_AJP_PORT=”8009” 最終行 JENKINS_ARGS=”–prefix=/jenkins”

パーミッションを変更 chown -R “jenkins”:”jenkins” /var/log/jenkins

jenkinsユーザのシェル変更

jenkinsユーザーがパスワードなしでsudo出来るように設定 visudo —— jenkins ALL=(ALL) NOPASSWD:ALL ——

起動 sudo /etc/init.d/jenkins start sudo chkconfig jenkins on

chkconfig –add paste-serve-rhodecode chkconfig –level 345 paste-serve-rhodecode on

  • ワークスペースの作成
  • Mercurialのプラグインインストール

jenkinsの管理 プラグインの管理

ワークスペース⇒設定⇒ビルド処理後の手順 成果物を保存 _build/html/**

成果物の確認方法 状態⇒ 最新成功ビルドの成果物

20.10. Jobサーバの構築 Webサーバの構築

  • Apacheインストール、設定
    • リバースプロクシ * Jenkins basic認証有り * RhodeCode basic認証無し ※アカウント認証有り
パスワードファイルの作成 htpasswd -c /etc/httpd/conf/rproxy_passwd nesapo-admin

/etc/httpd/conf/rproxy_passwd

<VirtualHost *:8880>
  ServerAdmin admin@example.com

  CustomLog /var/log/httpd/rproxy/rproxy_access_log combined
  ErrorLog /var/log/httpd/rproxy/rproxy_error_log

  <Proxy *>
    AllowOverride FileInfo AuthConfig Limit
    Options MultiViews Indexes SymLinksIfOwnerMatch

    AuthType Basic
    AuthName "Password for Jenkins"
    AuthUserFile /etc/httpd/conf/rproxy_passwd
    Require valid-user
  </Proxy>

  # Reverse Proxy
  ProxyPass /jenkins http://localhost:8080/jenkins
  ProxyPassReverse /jenkins http://localhost:8080/jenkins

</VirtualHost>*



   <VirtualHost *:80>
     ServerAdmin admin@example.com
     DocumentRoot /data/example
     ServerName www.example.com

     #
     CustomLog logs/example_access_log combined
     ErrorLog logs/example_error_log

     <Proxy *>
       AllowOverride FileInfo AuthConfig Limit
       Options MultiViews Indexes SymLinksIfOwnerMatch

       AuthType Basic
       AuthName "Password for Jenkins"
       AuthUserFile /etc/httpd/conf/jenkins_passwd
       Require valid-user
     </Proxy>

     # Reverse Proxy
     ProxyPass /jenkinsn http://localhost:9080/jenkins
     ProxyPassReverse /jenkinsn http://localhost:9080/jenkins

   </VirtualHost>*

20.11. Jobサーバの構築 sshの設定

  • 鍵の作成
  • アクセスを許可するユーザの作成 ※Mercurialリポジトリの利用について

20.12. 作業項目

  • RhodeCodeのインストール
  • Jenkinsインストール
  • Jenkins設定 ⇒ Webへのアップロード