Jenkins
Jenkins
First login to portal.azure.com, here we can see dashboard where all cloud services are
available
Select Virtual Machines
To create Virtual Machine click on create option we get three options they are:
Once installed, verify the Java version using the following command:
java --version
Add the Jenkins Debian repository.
Import the GPG keys of the Jenkins repository using the following wget command:
Fix: -
Site: https://stackoverflow.com/questions/70541720/jenkins-has-no-installation-candidate-error-while-
trying-to-install-jenkins-on
Jenkins service will automatically start after the installation process is complete. You can verify it by
printing the service status:
systemctl status Jenkins
we need to create Inbound port rule with highest priority to access jenkins
After adding Inbound port rule successfully copy the VM ip address and paste in new tab and add :8080
at end of the ip address.
We need to enter the Administrator password for the first attempt, later we need to create login
account.
Copy the password from your terminal, paste it into the Administrator password field and click
Continue.
On the next screen, the setup wizard will ask you whether you want to install suggested plugins or you
want to select specific plugins. Click on the Install suggested plugins box, and the installation process
will start immediately.
After installation
Once the plugins are installed, you will be prompted to set up the first admin user. Fill out all required
information and click Save and Continue.
Enter the vm ip address with port number and click on Save and Finish.
Click on the Start using Jenkins button and you will be redirected to the Jenkins dashboard.
After maven plugin installation verify that is available in installed plugins or not
We need to add path of java and maven in tools which are located in our vm.
Create a new pipe line name it as javapipline and select Freestyle project and click ok.
Open java github repo and copy the github repo url.
Paste the github url in Dashborad/javapipeline/Configuration
Select source code management in that choose git if the repo is public only url needed to paste
otherwise if repo is private we need to enter the github repo credentials also using Advanced option.
sudo su –
cd /var/lib/jenkins/workspace/javapipeline/webapp/target/
ls
After typing ls we can see webapp.war file
Create another vm or can do this process in same vm also . while doing on same vm make sure that
to increase the size of vm and it will restart again then continue this process.
cd /opt
wget https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.81/bin/apache-tomcat-8.5.81.tar.gz
After installation type to following command to entire into the tomcat directory
cd apache-tomcat-8.5.100/
ps -ef | grep tomcat
cd bin/
ls -la
After changing the permissions we have to create to shortcut to start and stop tomcat server instead
to coming to this directory .
Commands are:
ln -s /opt/apache-tomcat-8.5.81/bin/startup.sh /usr/local/bin/tomcatup
ln -s /opt/apache-tomcat-8.5.81/bin/shutdown.sh /usr/local/bin/tomcatdown
tomcatup
Using unique ports for each application is a best practice in an environment. But tomcat and Jenkins
runs on ports number 8080. Hence lets change tomcat port number to 8090. Change port number in
conf/server.xml file under tomcat home
Commands are:
ls
cd ..
cd conf/
vi server.xml
Type ‘ i ‘ enter into insert mode
Change the port number 8080 to 9000 in Connector port and press esc+:+wq! to save and exit from
the file.
click on add .
copy the ip address to vm and add port number 9000 at end to ip address
Now click on the host manager.
we get Acess Denied. We need to add the roles to view the deployment.
After adding code click esc+:+wq! to save and exit the changes.
cd .. -> Go to webapps
cd manager/META-INF
vi context.xml
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="admin" password="admin" roles="manager-gui, manager-script,
manager-jmx, manager-status"/>
<user username="deployer" password="deployer" roles="manager-script"/>
<user username="tomcat" password="s3cret" roles="manager-gui"/>
Add details Deploy to container as above shown figure.In details of container give your credentials
and Tomcat url and click on apply and save
If you want to schedule your project build periodically then you should select the
Build periodically option from the build triggers.
This field follows the syntax of cron (with minor differences). Specifically, each line
consists of 5 fields separated by TAB or whitespace:
Poll SCM:
Poll SCM periodically polls the SCM to check whether changes were made (i.e. new
commits) and builds the project if new commits were pushed since the last build.
*/2 * * * * (Every 2 mins )
Click on Build
Deployed successfully.