sexta-feira, 3 de junho de 2016

Install SVN 1.8 on CentOS

1. Introduction


This post shows how to install SVN 1.8 into CentOS 6.5.


2. Pre-conditions

2.1. Install Apache HTTP Server

# echo "Check if httpd (Apache Server) is installed and running ..."
# service httpd status
httpd (pid  1665) is running...
#
# echo "Install httpd (apache server) if needed ..."
# yum install httpd
# service httpd restart
# chkconfig httpd on


2.2. Setup Yum Repository for SVN Subversion

# vim /etc/yum.repos.d/wandisco-svn.repo
[WandiscoSVN]
name=Wandisco SVN Repo
baseurl=http://opensource.wandisco.com/centos/$releasever/svn-1.8/RPMS/$basearch/
enabled=1
gpgcheck=0

2.3.  Install Subversion Package

Before installing latest package remove existing subversion
# yum remove subversion*
# yum clean all
# yum install subversion
# svn --version
svn, version 1.8.16 (r1740329)
   compiled Apr 26 2016, 13:16:01 on x86_64-unknown-linux-gnu
Copyright (C) 2016 The Apache Software Foundation.
This software consists of contributions made by many people;
see the NOTICE file for more information.
Subversion is open source software, see http://subversion.apache.org/
                                                                     
The following repository access (RA) modules are available:
                                                                     
* ra_svn : Module for accessing a repository using the svn network protocol.
  - with Cyrus SASL authentication
  - handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
  - handles 'file' scheme
* ra_serf : Module for accessing a repository via WebDAV protocol using serf.
  - using serf 1.3.7
  - handles 'http' scheme
  - handles 'https' scheme


2.4.  Install Subversion with Apache - Mod_Dav_SVN

# yum install subversion mod_dav_svn
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: mirror.globo.com
 * epel: mirror.globo.com
 * extras: mirror.globo.com
 * updates: mirror.globo.com
Setting up Install Process
Package subversion-1.8.16-1.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package mod_dav_svn.x86_64 0:1.8.16-1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
 Package             Arch           Version           Repository           Size
================================================================================
Installing:
 mod_dav_svn         x86_64         1.8.16-1          WandiscoSVN          77 k
Transaction Summary
================================================================================
Install       1 Package(s)
Total download size: 77 k
Installed size: 216 k
Is this ok [y/N]: y
Downloading Packages:
mod_dav_svn-1.8.16-1.x86_64.rpm                          |  77 kB     00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : mod_dav_svn-1.8.16-1.x86_64                                  1/1
Stopping httpd: [  OK  ]
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[  OK  ]
  Verifying  : mod_dav_svn-1.8.16-1.x86_64                                  1/1
Installed:
  mod_dav_svn.x86_64 0:1.8.16-1
Complete!


2.5. Configure Subversion with Apache - MOD_DAV_SVN

# vim /etc/httpd/conf.d/subversion.conf
+------------------------------------------------------------+
| LoadModule dav_svn_module     modules/mod_dav_svn.so       |
| LoadModule authz_svn_module   modules/mod_authz_svn.so     |
|                                                            |
| Alias /svn /var/svn                                        |
|                                                            |
| <Location /svn>                                            |
|   DAV svn                                                  |
|   SVNPath  /var/svn/myrepo/                                |
|   AuthType Basic                                           |
|   AuthName "SVN Repo"                                      |
|   AuthUserFile /etc/svn-users                              |
|   Require valid-user                                       |
| </Location>                                                |
+------------------------------------------------------------+


2.6. Create First SVN Repository

# cd /var
# mkdir /var/svn
# cd /var/svn
# svnadmin create myrepo

# echo "don't forget to give permission to apache"
don't forget to give permission to apache

# chown apache:apache -R /var/svn


2.7. Create SVN Users ( /etc/svn-users )

# touch /etc/svn-users
# htpasswd -m /etc/svn-users admin
# htpasswd -m /etc/svn-users user1
# htpasswd -m /etc/svn-users user2


2.8. Create SVN Authorizations ( /etc/svn-users )

vim /etc/svn-authz
#
# Define groups
#
[groups]
admins = admin
users = user1, user2
devteams = user1, user2

#
# Default access rule for ALL repositories: 
# - Everyone can read, admins can write, hacker is excluded.
#
[/]
* = r
@admins = rw
hacker =

# echo "restart httpd service"
restart httpd service
# service httpd stop; service httpd start
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

2.9. Create your first project on SVN repository

# svn mkdir http://localhost/svn/_templateSvnProject -m "Creating default _templateSvnProject"
Committed revision 1.
#
# echo "You don't need to execute following commands! It's only for demo purpose"
You don't need to execute following commands! It's only for demo purpose
#
svn mkdir http://localhost/svn/testing-remove -m "Creating project only for testing remove project"
Committed revision 2.
#
svn delete http://localhost/svn/testing-remove -m "Deleting a created project only for testing"
Committed revision 3.

2.9. Create your project structure using best practices

# cd ~
# mkdir my-svn-working-copy
# mkdir my-svn-working-copy/_templateSvnProject
# mkdir my-svn-working-copy/_templateSvnProject/branches
# mkdir my-svn-working-copy/_templateSvnProject/tags
# mkdir my-svn-working-copy/_templateSvnProject/trunk
# echo "Project Template using SVN best practices" > my-svn-working-copy/_templateSvnProject/trunk/README.txt
# ls -R my-svn-working-copy/
my-svn-working-copy/:                            
_templateSvnProject                              
                                                 
my-svn-working-copy/_templateSvnProject:         
branches  tags  trunk                            
                                                 
my-svn-working-copy/_templateSvnProject/branches:
                                                 
my-svn-working-copy/_templateSvnProject/tags:    
                                                 
my-svn-working-copy/_templateSvnProject/trunk:   
README.txt                                       


2.10. Import your project structure and contents to repository

# echo "Go to working directory"
Go to working directory
cd ~/my-svn-working-copy
echo "Go to project directory"
Go to project directory
cd _templateSvnProject
# pwd
/root/my-svn-working-copy/_templateSvnProject
ls
branches tags trunk
#
svn import -m "First Check-in" --username  admin  --password  admin  http://localhost/svn/_templateSvnProject
Adding         branches        
Adding         tags            
Adding         trunk           
Adding         trunk/README.txt
                               
Committed revision 4.          


2.11. Access repository in your browser

  • Access  http://127.0.0.1/svn/myrepo/
+--------------------------------------------+
| URL:  http://127.0.0.1/svn/myrepo/    |GO| |
+--------------------------------------------+
|                                            |
|      +----------------------------+        |
|      | Autenticacao obrigatória   |        |
|      |        +------------+      |        |
|      |  Nome: | admin      |      |        |
|      |        +------------+      |        |
|      | Senha  | admin      |      |        |
|      |        +------------+      |        |
|      +----------------------------+        |
|                                            |
+--------------------------------------------+

  • Subversion shows repository
+--------------------------------------------------------------+
| svn - Revision 4: /                                          |
|                                                              |
|  _templateSvnProject/                                        |
|                                                              |
|                                                              |
| Powered by Apache Subversion version 1.8.16 (r1740329).      |
+--------------------------------------------------------------+


  • Click on link "_templateSvnProject"
+--------------------------------------------------------------+
svn - Revision 4: /_templateSvnProject                       |
|                                                              |
|  ..                                                          |
|  branches/                                                   |
|  tags/                                                       |
|  trunk/                                                      |
|                                                              |
|                                                              |
| Powered by Apache Subversion version 1.8.16 (r1740329).      |
+--------------------------------------------------------------+


  • And after on link "trunk"
+--------------------------------------------------------------+
svn - Revision 4: /_templateSvnProject/trunk                 |
|                                                              |
|  ..                                                          |
|  README.txt                                                  |
|                                                              |
|                                                              |
| Powered by Apache Subversion version 1.8.16 (r1740329).      |
+--------------------------------------------------------------+


2.12. Check out your project from repository

Now you must have faith. You will remove all your local files and check project out from repository in your SVN local copy

echo "Go to working directory"
Go to working directory
cd ~/my-svn-working-copy
# ls
drwxr-xr-x 5 root root 4096 Sep 12 15:13 _templateSvnProject
# rm -rf ./_templateSvnProject
# ls -la
drwxr-xr-x 2 root root 4096 Sep 12 15:26 .
dr-xr-x---. 7 root root 4096 Sep 12 15:13 ..
# echo "Oh my God! Be calm. You believe in repository, don't you?"
echo "Oh my God! Be calm. You believe in repository, don't you?"
# svn checkout --username admin --password admin http://localhost/svn/_templateSvnProject
A _templateSvnProject/trunk
A _templateSvnProject/branches
A _templateSvnProject/tags
A _templateSvnProject/trunk/README.txt
Checked out revision 4.
cd ~/my-svn-working-copy
# ls -lR
.:                                                          
total 4                                                     
drwxr-xr-x 6 root root 4096 Sep 12 15:31 _templateSvnProject
./_templateSvnProject:                                      
total 12                                                    
drwxr-xr-x 2 root root 4096 Sep 12 15:31 branches           
drwxr-xr-x 2 root root 4096 Sep 12 15:31 tags               
drwxr-xr-x 2 root root 4096 Sep 12 15:31 trunk              
./_templateSvnProject/branches:                             
total 0                                                     
./_templateSvnProject/tags:                                 
total 0                                                     
./_templateSvnProject/trunk:                                
total 4                                                     
-rw-r--r-- 1 root root 42 Sep 12 15:31 README.txt           




2.13. Import your project using TortoiseSVN

  • #1 - Create your project best practice structure

  • #2 - Create a _READ-ME.txt file under 'trunk'

  • #3 - Positioned into your project structure, Right Click on Windows Explorer and choose menu option TortoiseSVN Import

  • #4 - Define repository URL

  • #5 - Authenticate with 'admin'

  • #6 - Check import finished message

  • #7 - Check browsing HTTP

3. References



quinta-feira, 2 de junho de 2016

Installing Jenkins - CentOs 6.5

Installing Jenkins for CentOS 6.5


1. Introduction


This post shows how to install Jenkins for CentOS 6.5


2. Step by Step


2.1. Check/Install JDK or JRE

Check if JDK 1.6 or greather is available on machine. Depending on the purpouse of your Jenkins instalation, you will need to instal JDK (I strongly recommend). If you just want to take a look in Jenkins, so you can install JRE.

# java -version
java version "1.7.0_65"
OpenJDK Runtime Environment (rhel-2.5.1.2.el6_5-x86_64 u65-b17)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)         
                                                                # echo "Execute following command if JRE is not installed ..." 
# yum install java
        :
        :
#
# echo "I decided to install more than a simple JRE because I will compile code"
I decided to install more than a simple JRE because I will compile code
# yum install java-1.7.0-openjdk-devel
        :
        :



2.2. Add Jenkins repository to machine

# wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
# sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
# sudo yum install jenkins


2.3. Install Jenkins

# yum install jenkins
  :
Dependencies Resolved
===========================================================================================================================
 Package                      Arch                        Version                       Repository                    Size
===========================================================================================================================
Installing:
 jenkins                      noarch                      2.3-1.1                       jenkins                       63 M
Transaction Summary
===========================================================================================================================
Install       1 Package(s)
Total size: 63 M
Installed size: 64 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : jenkins-2.3-1.1.noarch                                                                                  1/1
  Verifying  : jenkins-2.3-1.1.noarch                                                                                  1/1
Installed:
  jenkins.noarch 0:2.3-1.1
Complete!
  :



2.4. Add Jenkins to system boot


# chkconfig jenkins on


2.5. Start Jenkins service

# service jenkins start
Starting Jenkins                                           [  OK  ]
# service jenkins status
jenkins (pid  1310) is running...


2.6. Check Jenkins services

a. Checking Port Service

# echo "Jenkins default port is 8080. Check port listening ..."
# netstat -tnlp | grep 8080


b. Checking firewall rules

# echo "Check if port 8080 is listening ..."
# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:80
2    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:10050
:      :         :           :                   :                 :

# echo "Add listening rule to 8080 - Save rules - restart services ..."
# iptables -I INPUT 2 -p tcp --dport 8080 -j ACCEPT
# service iptables save 
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]
# service iptables restart
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:80
2    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:8080


2.7. Configure Jenkins administrator password


  • Open first time your Jenkins server on browser
  • http://127.0.0.1:8080/

Getting Started 
  Unlock Jenkins
    To ensure Jenkins is securely set up by the administrator, a password ....
    /var/lib/jenkins/secrets/initialAdminPassword                             
    Please copy the password from either location and paste it below.         
                                                                              
# cat /var/lib/jenkins/secrets/initialAdminPassword                           



2.8. Configure Jenkins - Installing Plugins recommended

Getting Started 
  Customize Jenkins
    Plugins extend Jenkins with additional features to support many different needs.
      Install suggested plugins


2.9. Configure Jenkins - Configure first admin user

Getting Started 
  Create First Admin User
    username: admin
    password: admin
    e-mail  : admin@yourdomain.com

2.10. Configure Jenkins - Jenkins is ready

Getting Started 
  Jenkins is ready!


3. References