Jenkins

Install Jenkins on Raspberry Pi (Raspbian)

NOTE: Instructions can also be obtained here 
http://pkg.jenkins-ci.org/debian/ 
or 
https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu
  1. Open a terminal window
  2. Run wget -q -O – https://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add –
  3. Run sudo nano /etc/apt/sources.list
  4. Append to the file deb http://pkg.jenkins-ci.org/debian binary/
  5. Run sudo apt-get update
  6. Run sudo apt-get install jenkins
  • Jenkins will run up on start as a daemon via the script /etc/init.d/jenkins
  • The log file will be placed in /var/log/jenkins/jenkins.log
  • To change the default port of 8080 to something else can be done in /etc/default/jenkins
NOTE: Jenkins home directory can be found in Jenkins under 
Manage Jenkins > System Information > user.home property value 

Add Nexus user to Gradle profile

To upload to Nexus from Jenkins using Gradle then add the credentials like so:

  • Go to the .gradle folder in Jenkins home directory (e.g. /var/lib/jenkins/.gradle).
  • Create a file called gradle.properties (e.g. sudo vi gradle.properties)
  • Add
mavenUser=admin
mavenPassword=admin123
  • Change the owner and group of the file if necessary (e.g. to change from root to jenkins user)
  • In build.gradle one can now use the following authentication
authentication(userName: mavenUser, password: mavenPassword)

Remote ssh to application server

NOTE: If the .ssh folder does not exist on the application server 
then create it first using the below commands before beginning:
 - mkdir ~/.ssh
 - chmod 700 ~/.ssh
  1. On Jenkins server
    • cd ~ (As the Jenkins user e.g. sudo su jenkins)
    • ssh-keygen -t rsa to create public/private keys (select the defaults without entering passphrase by pressing Enter)
    • cd ./ssh
    • ssh-add id_rsa to add the identity to the local ssh authorizer
      • If message “Could not open a connection to your authentication agent.” appears, start “ssh-agent” using eval `ssh-agent`
    • scp id_rsa.pub remoteuser@remotehost.com:~/.ssh/ to copy the public key to the remote host (e.g. scp id_rsa.pub pi@192.168.1.33:~/.ssh/)
  2. On Application server (e.g. 192.168.1.33)
    • cd ~/.ssh
    • cat id_rsa.pub >> authorized_keys to add the public key to “authorized_keys”
    • chmod 600 authorized_keys

To test that it works on the Jenkins server run the command (should return a result without prompting for a password):

ssh remoteuser@remotehost uname -a (e.g. ssh pi@192.168.1.33 uname -a)

The above used the following link for information

Advertisements