Wednesday 20 December 2017

Installing Jenkins

The procedures on this page are for new installations of Jenkins on a single/local machine.
Jenkins is typically run as a standalone application in its own process with the built-in Java servlet container/application server (Jetty).
Jenkins can also be run as a servlet in different Java servlet containers such as Apache Tomcat or GlassFish. However, instructions for setting up these types of installations are beyond the scope of this page.
Note: Although this page focusses on local installations of Jenkins, this content can also be used to help set up Jenkins in production environments.

Prerequisites

Minimum hardware requirements:
  • 256 MB of RAM
  • 1 GB of drive space (although 10 GB is a recommended minimum if running Jenkins as a Docker container)
Recommended hardware configuration for a small team:
  • 1 GB+ of RAM
  • 50 GB+ of drive space
Sofware requirements:
  • Java 8 - either a Java Runtime Environment (JRE) or a Java Development Kit (JDK) is fine
    Note: This is not a requirement if running Jenkins as a Docker container.

On macOS and Linux

  1. Open up a terminal window.
  2. Download the jenkinsci/blueocean image and run it as a container in
    Docker using the following docker run command:
    docker run \
      -u root \
      --rm \  
      -d \ 
      -p 8080:8080 \ 
      -v jenkins-data:/var/jenkins_home \ 
      -v /var/run/docker.sock:/var/run/docker.sock \
      jenkinsci/blueocean 
    On Windows
  1. Open up a command prompt window.
  2. Download the jenkinsci/blueocean image and run it as a container in Docker using the following docker run command:
    docker run ^
      -u root ^
      --rm ^
      -d ^
      -p 8080:8080 ^
      -v jenkins-data:/var/jenkins_home ^
      -v /var/run/docker.sock:/var/run/docker.sock ^
      jenkinsci/blueocean
    For an explanation of each of these options, refer to the macOS and Linux instructions above.
  3. Proceed to the Post-installation setup wizard.

Accessing the Jenkins/Blue Ocean Docker container

If you have some experience with Docker and you wish or need to access the jenkinsci/blueocean container through a terminal/command prompt using the docker exec command, you can add an option like --name jenkins-blueocean (with the docker run above), which would give the jenkinsci/blueocean container the name "jenkins-blueocean".
This means you could access the container (through a separate terminal/command prompt window) with a docker exec command like:
docker exec -it jenkins-blueocean bash

macOS

To install from the website, using a package:
Jenkins can also be installed using brew:
  • Install the latest release version
brew install Jenkins
  • Install the LTS version
brew install jenkins-lts

Jenkins

Jenkins is a self-contained, open source automation server which can be used to automate all sorts of tasks related to building, testing, and delivering or deploying software.
Jenkins can be installed through native system packages, Docker, or even run standalone by any machine with a Java Runtime Environment (JRE) installed.

Getting Started with the Guided Tour.
 Prerequisites:

Download and run Jenkins

  • A machine with:
    • 256 MB of RAM, although more than 512MB is recommended
    • 10 GB of drive space (for Jenkins and your Docker image)
  • The following software installed:
    • Java 8 (either a JRE or Java Development Kit (JDK) is fine)
    • Docker (navigate to Get Docker at the top of the website to access the Docker download that’s suitable for your platform)

  1. Download Jenkins.
  2. Open up a terminal in the download directory.
  3. Run java -jar jenkins.war --httpPort=8080.
  4. Browse to http://localhost:8080.
  5. Follow the instructions to complete the installation.
When the installation is complete, you can start putting Jenkins to work!

How to delete a message from JMS queue

connect('weblogic', 'weblogic', 't3://localhost:7003')
serverRuntime()
cd('/JMSRuntime/MS1.jms/JMSServers/dizzyworldJMSServer/Destinations/DizzyworldJMSModule!dizzyworldqueue')
cmo.deleteMessages('')

Changing password for existing user (passwordchange.py)

DomainName = "base_domain"

ADMINUrl = "t3://localhost:7001"

ADMINUser = "pavan"

oldPassword = "pavan123"

newPassword = "pavan456"

print  '*****************'
connect(ADMINUser,oldPassword,ADMINUrl)

cd('/SecurityConfiguration/'+DomainName+'/Realms/myrealm/AuthenticationProviders/DefaultAuthenticator')

cmo.resetUserPassword(ADMINUser,newPassword)

print  '*****************'

disconnect()

print '*** connecting with new password***......................................'


connect(ADMINUser,newPassword,ADMINUrl)

Creating users and assigning to groups (usercreation.py)

connect('weblogic','weblogic','t3://localhost:7001')
serverConfig()
cd('/SecurityConfiguration/base_domain/Realms/myrealm/AuthenticationProviders/DefaultAuthenticator')
cmo.createUser('pavan','pavan123',"")
cmo.addMemberToGroup('Administrators','pavan')
disconnect()
exit()

Starting admin server using Nodemanger/ From remote location

Open nodemanager.properties file which is located at /home/bea/weblogic91/common/nodemanager  and change the below entry
SecureListener=false

Loging to console : Navigate to Machines->Machine-1->Node Manager-> Type : Plain



Step 1) cd /home/bea/weblogic92/common/bin
           ./wlst.sh
Step 2) Start Node manager :
           i) /home/bea/weblogic92/server/bin/startNodeManager.sh
            or
           ii)  startNodeManager(verbose='true', NodeManagerHome='/home/bea/weblogic92/common/nodemanager',ListenPort='5556', ListenAddress='localhost')
Step 3) Connect to Nodemanager
        wls:/offline> nmConnect('weblogic', 'weblogic', 'localhost', '5556', 'dev_domain','/home/bea/user_projects/domains/dev_domain','plain')
Connecting to Node Manager ...
Successfully Connected to Node Manager.

Step 4) start AdminServer
     wls:/nm/dev_domain>  prps = makePropertiesObject('weblogic.ListenPort=7001')
wls:/nm/dev_domain>  nmStart('AdminServer',props=prps)
Starting server AdminServer ...
Successfully started server AdminServer ...

Checking the server status using nodemanager


wls:/nm/dev_domain> nmServerStatus('AdminServer')

RUNNING


To Kill server using Nodemanager

wls:/nm/dev_domain> nmKill('AdminServer')
Killing server AdminServer ...
Successfully killed server AdminServer ...


To check nodemanager version

wls:/nm/dev_domain> nmVersion()
The Node Manager version that you are currently connected to is 9.2.3.0.

To stop nodemanger

stopNodeManager()

Disconnect from nodemanger


nmDisconnect()

Checking the server health using WLST

connect('weblogic','weblogic','t3://localhost:7001')
domainRuntime()
cd('ServerRuntimes')
servers=domainRuntimeService.getServerRuntimes()
for server in servers:
        serverName=server.getName();
        print '**************************************************\n'
        print '##############   ',serverName,    '###############'
        print '**************************************************\n'
        print '##### Server State           #####', server.getState()
        print '##### Server ListenAddress   #####', server.getListenAddress()
        print '##### Server ListenPort      #####', server.getListenPort()
        print '##### Server Health State    #####', server.getHealthState()
exit()


Running WLST in Online mode:
wls:/(offline)> connect('username','password', 't3://localhost:7001')
Connecting to weblogic server instance running at t3://localhost:7001 as username weblogic ...
Successfully connected to Admin Server 'myserver' that belongs to domain 'mydomain'.

wls:/mydomain/serverConfig>

Creating an script:

middleware_home=' /usr/weblogic/wlserver '
# Open a domain template.
readTemplate (middleware_home + '/common/templates/domains/wls.jar')
cd('Servers/AdminServer')
set('ListenPort', 7001 )
set('ListenAddress','192.168.10.1')
create('AdminServer','SSL')
cd('SSL/AdminServer')
set('Enabled', 'True')
set('ListenPort', 7002)
cd('/')
cd('Security/base_domain/User/WebLogic')
cmo.setName('WebLogic')
cmo.setPassword('secretPassword123 ')
setOption('OverwriteDomain', 'true')
setOption('ServerStartMode', 'prod')
writeDomain(domaintarget)
closeTemplate()



Creating Domain using WLST

print "Reading existing domain....."
readDomain('/home/bea/user_projects/domains/prod_domain')
print "Writing the existing domain into template file...."
writeTemplate('/home/bea/user_projects/domains/prod_new_domain.jar')
print "closing the Domain ..........."
closeDomain()
print "Creating new domain with newly created template file.............."
createDomain('/home/bea/user_projects/domains/prod_new_domain.jar','/home/bea/user_projects/domains/prod_new_domain','weblogic','weblogic')

Deployed Application status using wlst

print "deployed application status"
connect('weblogic','weblogic','t3://localhost:8001')
print "**************Deployed application status****************"
ls('AppDeployments')
print "*********************************************************"
disconnect()
exit()

Undeploying Application using wlst

./wlst.sh undeploy.py

connect('weblogic','weblogic','t3://localhost:8001')
print "undeploying application........."
undeploy('benefits')
print "........................."
disconnect()
exit()

Deployment using WLST.

deploy.py 

print '***********************************************************************'
connect('weblogic','weblogic','t3://localhost:7001')
print '***********************************************************************'
edit()
print '***********************************************************************'
startEdit()
print '***********************************************************************'
print '***********************************************************************'
deploy('benefits','/home/application/benefits.war',targets="ms1,ms2")
print '***********************************************************************'
save()
print '***********************************************************************'
activate()
print '***********************************************************************'
disconnect()