0% found this document useful (0 votes)
62 views49 pages

Jenkins

Uploaded by

DILEEPKUMARRR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views49 pages

Jenkins

Uploaded by

DILEEPKUMARRR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 49

JENKINS

• Jenkins installation steps


• 1 pwd
• 2 sudo yum update
• 3 sudo yum update -y
• 4 sudo su -
• 5 java -version
• 6 sudo yum install java-1.8.0
• 7 clear
• 8 java -version
• 9 sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-
• stable/jenkins.repo
• 10 sudo yum update
• 11 sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
• 12 sudo yum upgrade
• 13 sudo yum install jenkins java-11-openjdk-devel
• 14 sudo systemctl daemon-reload
• 15 sudo service jenkins start
• 16 sudo cat /var/lib/jenkins/secrets/initialAdminPassword
• To change Jenkins port in redhat linux 
• Go to /etc/sysconfig – goto Jenkins file – change port from 8080 to new port

• To reset admin username/password -- got to Jenkins home directory(/var/lib/Jenkins)– go


to config.xml file – change use security from true to false – restart Jenkins service –
systemctl restart Jenkins – systemctl status Jenkins – refresh Jenkins UI page—with out
login we can find all jobs details – go to configure global security – check the box on
Jenkins Own user database – Save. – now we will get manage users option – got to users
• Select admin user – select configure – scroll down we can see admin password – change
PW and save– goto configure global security– select loggedin users can do anything—
disable allow ananomous user can do anything—save. Now we can login with new
password
• Mvn clean package :: it will compile the code execute the test cases and it will create a
package like war file
CI TOOLS

• Bomboo
• Jenkins – very popular- 100s plugins+good community support+open source
• Teamcity
MAVEN LIFECYCLE
• Clean
• Site
• Default
• Default life cycle has following:
• Validate: Validate the project is correct and all necessary information is available
• Compile: Compile the source code of he project
• Test: Runs suitable test cases. These tests should not be required code be packaged or deployed
• Package: Take the compiled code and packageit in istributable form like Jar, War, Ear
• Install: Install the package into the local repository, for use as a dependency in other projects locally
• Deploy: Copies the final package to the remote repositorys for sharing with other developers and projects
• Clean lifecycle: Removes all files generated by other project

• Site lifecycle: Generates projects site documentation

• Maven Goals:
• To invoke a maven build you set a life cycle goal
• Mvn install: it invokes validate, compile, test, package, install
• Mvn clean: it invokes just clean
• Mvn clean compile: clean old builds and execute validate and compile
• Mvn compile install: invokes validate compile test package install
• Mvn test clean: invokes validate compile test clean
• How to create Users + Manage + Assign Roles
• Step 1 : Create new users
• Step 2 : Configure users
• Step 3 : Create and manage user roles Role Based Authorization Strategy Plugin -
Matrix Authorization Strategy Plugin- download - restart jenkins
• Step 4 : Manage Jenkins - Configure Global Security - Authorization - Role Based
Strategy –Apply-Save
• Step 5 : To Create Roles and Assign roles to users-Manage Jenkins-Manage and Assign
roles-
• Step 6 : Validate authorization and authentication are working properly
• Create the first github Job on Jenkins
• How to connect to Git Remote Repository in Jenkins (GitHub)
• Install Credentials plugin
• Goto Credentials in Jenkins
• Click on Jenkins
• Click on add credentials
• Select KIND as username and password
• Add github credentials
• Get the url of the remote repository
• Add the git credentials on Jenkins
• In the jobs configuration goto SCM and provide git repo url in git section
• Add the credentials
• Run job and check if the repository is cloned
• Chain Jobs
• Upstream
• Downstream
• Checkout from github
• Build periodically
• Shell command
• Install maven
• Maven invoker plugin
• Chain jobs
• Build pipeline plugin- for chian jobs
• Pipeline
MAVEN
• install maven - https://maven.apache.org/download.cgi
• Cd /opt/maven
• wget
https://mirrors.estointernet.in/apache/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz
• tar -xvzf apache-maven-3.8.1-bin.tar.gz
• cd apache-maven-3.8.1/
• pwd
• cd /
• vi .bash_profile
• echo $PATH
• mvn –version
• Vi .bash_profile
• # User specific environment and startup programs
• PATH=$PATH:$HOME/bin
• JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.302.b08-0.amzn2.0.1.x86_64/jre"
• M2_HOME=/opt/maven/apache-maven-3.8.1
• M2=$M2_HOME/bin

• PATH=$PATH:$JAVA_HOME:$M2_HOME:$M2:$HOME/bin

• export PATH
• Stage1-Git checkout- mention github
• Stage2- Build project- mvn/ant-
• Stage3- Test-Junit/seli
• Stage4-Deploy config
• Stage5- Post-push artifacts
• Install maven invoker plugin
• Install github plugin
• Install pipeline plugin

• pipeline {
• agent any
• stages {
• stage("HELLO"){
• steps{
• echo "Hello Welcome to Devops"
• }
• }
• }
• }
• pipeline {
• agent any
• stages {
• stage('NORMAL Stage') {
• steps {
• echo 'I am one' }
• }
• stage('Parallel Stage') {
• steps { echo "Me in stage one"
• }
• }
• stage('Stage two') {
• steps {
• echo "Me in stage two"
• }
• }
• stage('Stage three') {
• steps {
• echo "Me in stage three" } } } }
• Parameterized builds
•  Tihs project is parameterized – add parameter – string parameter --
•  Enter name(parameter name) and default value

•  Goto build section – Execute shell –


• “${parametername}”/ ${parametername}/ $parametername/
•  ex- echo “${NAME}”/ ${NAME}/ $NAME/
• For Choice parameter- select choice parameter and give some name then enter choice one by one
• Like Choice1
• Choice2 etc
EMAIL NOTIFICATIONS
• Manage Jenkins  Configure system  Email notifications SMTP server-
smtp.gmail.com Select use smtp authentication username(enter any email id) and
password of that mail.  Select use SSL  SMTP port-(465/587 for gmail)  Test
sending email – give any email and test
• Jenkins Interview questions

• 1. What is CICD – continuous deployment and continuous delivery


• 2. Which CI tool you are using – Jenkins,Teamcity,Bomboo
• 3. What are different tools of CI tools - – Jenkins,Teamcity,Bomboo
• 4. What type of jobs(projects) you configured – Freestyle , Pipeline, Maven
• Can you create CICD pipeline from scratch - yes
• What is Jenkins file – to automate or to create pipeline through script
• 5. What is pipeline and types of pipelines – Scripted, Declarative
• 6. Difference between declarative and scripted pipeline-
• What are the stages you have in jenkinsfile
• 7. Write pipeline syntax --
• 8. What is use of master slave config – to distribute load
• 9. Explain security in Jenkins – through matrix based and project based security
• 10. What type of artifactory tool you are using -Jfrog, Nexus,S3
• 11. What is DSL language - domain specific language-groovy
• 12. What is upstream and down stream jobs -
• 13. How can you configure maven, jdk etc –global tool config-
• 14. What plugins you are using – Maven invoker, github, build
pipeline, pipeline , Role based strategy , Credentials
• 15. What is jenkins home directory - /var/lib/Jenkins/workspace/
• 16. what are different ways of scheduling(Automating) jobs- Build
periodically,poll scm, Hook trigger.
• 17. Where the jobs source code saved – Jenkins Home dir
• 18.
• How to install plugin –
• Which type of issues you are getting from Jenkins – build fails-
• Configuration issues(java8 but java9 ), code issues
• For every 2 hours – crontab syntax- * H/2 * * *
• Explain maven goals– mvn compile,install,test,clean
• Explain maven life cycle- repository information
• What is pom.xml-
• Have you written script with Jenkins-
• How to change Jenkins Port- /etc/sysconfig-- jenkins

You might also like