Tuesday, June 27, 2006

Continuous Integration - JENKINS


Jenkins Installation:

Automatic Installation:

1. To use repository, run the following command:
    $ sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
     $ sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
If you've previously imported the key from Jenkins, the "rpm --import" will fail because you already have a key. Please ignore that and move on, with that set up, the Jenkins package can be installed with:
    $ yum install jenkins

Manual Installation:

1. Download Jenkins[http://pkg.jenkins-ci.org/redhat/] latest version jenkins-1.535-1.1.noarch.rpm
2. $ rpm -ivh rpm -ivh jenkins-1.535-1.1.noarch.rpm as root user. If not root you will receive exception : [error: can't create transaction lock on /var/lib/rpm/.rpm.lock (Permission denied)
     rpm -qa | grep -i webmin
     rpm -e <package name>
     /etc/sysconfig/jenkins saved as /etc/sysconfig/jenkins.rpmsave
3. Re-install latest package:
     [root@cmputl-dt-4d jenkins]# rpm -ivh jenkins-1.535-1.1.noarch.rpm
      warning: jenkins-1.535-1.1.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID d50582e6: NOKEY
      Preparing...                ########################################### [100%]
      1:jenkins                ########################################### [100%]
4. Check Configuration at vi /etc/sysconfig/jenkins
      JENKINS_HOME="/var/lib/jenkins"
      JENKINS_JAVA_CMD=""
      JENKINS_USER="jenkins"
      JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true"
      JENKINS_PORT="8080"
      JENKINS_LISTEN_ADDRESS=""
      JENKINS_HTTPS_PORT=""
      JENKINS_HTTPS_LISTEN_ADDRESS=""
      JENKINS_AJP_PORT="8009"
      JENKINS_AJP_LISTEN_ADDRESS=""
      JENKINS_DEBUG_LEVEL="5" # 1 -9
      JENKINS_ENABLE_ACCESS_LOG="no"
      JENKINS_HANDLER_MAX="100"
      JENKINS_HANDLER_IDLE="20"
      JENKINS_ARGS=""
5. Jenkins Startup Script: /etc/init.d/jenkins.
1. Jenkins will be launched as a daemon up on start. See /etc/init.d/jenkins for more details.
2. The 'jenkins' user is created to run this service.
3. Log file will be placed in /var/log/jenkins/jenkins.log. Check this file if you are troubleshooting Jenkins.
/etc/default/jenkins will capture configuration parameters for the launch.
4. By default, Jenkins listen on port 8080. Access this port with your browser to start configuration.
If your /etc/init.d/jenkins file fails to start jenkins, on line 108 you may change su -l <username> -c <command> with sudo -u <username> <command>. This fixed init.d script for me (icarito, July 2013).
6. Run: service jenkins start as root to start the instance, once service is started you can see jenkins instance running at "http://cmputl-dt-4d.ula.comcast.net:8080/".
7. Download plugin[https://updates.jenkins-ci.org/download/plugins] and place them under <jenkinsHome>/plugins/ directory. Sometimes when you download plugins you may get (.zip) files then just rename with (.hpi) and then extract all the plugins and move to <jenkinsHome>/plugins/ directory.
/var/lib/jenkins/.ssh/id_rsa

WAR Installation: 

refer here

I don't remember my Jenkins password. How do I change it?

Issue: When creating a Jenkins application, the client (Web Console or rhc client) will print the admin password for your new Jenkins instance as well as recommend that you change it. The password, however, will not be stored in any environment variables.
Resolution: If the password is lost/forgotten, there are a few ways around it.
1. Since this is your own Jenkins instance, and you know there have been limited customizations that you can recreate, just destroy the Jenkins app and recreate another.  A new password for your new Jenkins instance will be set and printed to your client.  Don't forget to remove/re-add the jenkins-client-1.4 cartridge to those applications that you want Jenkins to help build and test.
> rhc app delete -a jenkins
> rhc app create -a jenkins -t jenkins-1.4
> rhc cartridge remove jenkins-client-1.4 -a {appUnderTest}
> rhc cartridge add jenkins-client-1.4 -a {appUnderTest}
2. ssh onto the gear and set the user password.  Since this is done with a hashcode, you can hand-set it to 'admin' with the following hashcode in file ~/jenkins/data/users/admin/config.xml:
 <passwordHash>oxulLC:aa38a78fabb46033263e7aa7bd2446d627ff4651e3c99eb1b6fc226f704cbc03</passwordHash>
Then you can proceed to login with admin/admin and alter your password at: https://jenkins-{yourDomain}.rhcloud.com/me/configure
3. ssh onto the gear, disable authentication, set the password via the Jenkins Web UI, then enable authentication:
- ssh onto the gear
- backup your config.xml
> cp ~/jenkins/data/config.xml ~/jenkins/data/config.xml.bak
- modify: ~/jenkins/data/config.xml from <useSecurity>true</useSecurity> to <useSecurity>false</useSecurity>
- remove the tag block: <authentication strategy>
- restart jenkins with "ctl_app restart"
> NOTE:  at this point, jenkins is not secure.  
- access Jenkins instance with browser and modify the admin password.
- copy backup of config.xml:
> cp ~/jenkins/data/config.xml.bak ~/jenkins/data/config.xml
- restart jenkins

Trouble logging in as jenkins (centos that rpm install created) user after changing password

1. What happened was that my user was not part of AllowUsers within the /etc/ssh/ssh_config file. Adding that user and restart sshd healed the pain.
2. The Jenkins RPM install creates the dedicated user a no-login user, with /bin/false as the default login shell. To fix this, do
$ sudo usermod -s /bin/bash jenkins and then check this with
$ grep jenkins /etc/passwd which should show bash, not false. After setting the default shell to allow the jenkins user to log in, be sure to assign a password with
$ sudo passwd jenkins and provide the new password at the prompt.


No comments:

Post a Comment