What is CI/CD Pipeline? what is jenkins?
CI/CD is a Methodology - that helps in SDLC(s/w delvr lifecycle)/ and its automate the process.
Continuous Integration/ Continuous Delivery
Continuous Deployment
Before CI
Dev(code) 3 days --push code -- Repo (git) -- Integration
|
testing( 4 days)
|
got error
|
send email to dev (total 7 days)
After CI
Dev(code) --push code -- Repo (git) -- CI Server-Intergration(Build - Test - deploy)
|
got error
|
send email/notify right away to dev
Continuous Integration=(Continuous Build + Continuous Testing)
CI/CD pipeline
Dev- version control - Build - Unit test- Deploy- auto test - Prod env - Measure & validate
| | | | | | | |
-<---<---------------------<------------<-- --<-------<---------<-------------<-
Feedback
Devops Lifecycle
Plan Deploy
Code
Build Jenkins(Heart) Operate
Test Monitor
Like Jenkins Tools
Bamboo
Travis CI
BuildBot
Jenkins
- Jenkins is an open source project written in Java that runs on windows, macOS and other unix-like operating systems. it is free, community supported and might be your first choice tool for CI. - lots of plugins available.
- Jenkins automate the entire s/w development life cycle(SLDC).
- Jenkins was originally developed by Sun Microsystem in 2004 under the name hudson.
- The project was later named jenkins when oracle bought microsystems.
- It can run on any major platform without any compatibility issues.
- Whenever developers write code, we integrate all that code of all developers at that point of time and we build, test and deliver/Deploy to the client This process is called CI/CD.
- Jenkins help us to achieve this.
- Because of CI, Now bugs will be report fast and get Rectified fast, so the Entire S/W development happens fast.
Workflow of Jenkins
- We can attach git, Maven, Selenium and Artifactory plug-ins to jenkins
- Once developers puts code in github, jenkins pull that code & send to Maven for build.
- Once build is done, jenkins pull that code and send to selenium for testing.
- Once testing is done, then jenkins will pull that code and send to artifactory as per requirement and so on.
- We can also deploy with jenkins.
Advantages of Jenkins
- It has lots of plug-ins available.
- You can write your own plug-in.
- You can use Community Plug-in.
- Jenkins is not just a tool. It is a Framework i.e. you can do whatever you want. All you need is plug-ins.
- We can attach slaves(nodes) to jenkins master. It instruct others (slave) to do job. If slaves are not available, Jenkins itself does the job.
- Jenkins also behave as crone server replacement i.e can do scheduled task.
- It can create labels.
Build
Compile - Code Review - Unit Testing - Integration Testing - Packaging(WAR,JAR)
Plugins
Plugins are small libraries that add new abilities to jenkins and can provide integration points to others tools.
Go to manage Jenkins on left side of jenkins dashboard -> Manage Plugins -> Available -> Select Maven Integration & Green balls -> Install without Restart
Maven Project (by jenkins)
Now go to Jenkins -> New item -> Entername -> MyMavenProject
Then select Maven Project -> OK
Source Code Management -> git
-> Repository URL
Build option -> Root Pom -> pom.xml
Goals & Options -> clean Package -> Save
Go to jenkins home page -> click on MyMavenProject -> Build Now
It will run periodically, like we can run every min, but we are wasting our resource, so new concept cam is SCM, in SCM it will start build only when changes happened in the code.
Scheduled Project
Click on any project -> configure -> build triggers -> build periodically
-> * * * * * -> Save
Can see automatic builds after every 1 min.
You can manually trigger build as well
Source Code Polling (Poll SCM)
-> Now go to jenkins HomePage
-> go to My MavenProject -> configure
Now go to build trigger
☑ Poll SCM
schedule * * * * * * -> Save
Now go to github account -> do some changes in ReadMe.md -> commit changes
You can see, after 1 min. it build automatically.
Upstream Linked Project
USER -> Job A -> My Maven Job
|
(Post)
Build Action
|
My Maven Job
Downstream Linked Project
USER -> Job A -> My Maven Job
|
Build Action
|
Job A finish start yourself
User Management
Go to Jenkins Homepage -> Manage Jenkins -> Manage Users
Create two users -> bhupindra
Now login as -> bhupindra
{By default, you have all the permissions}
login as "admin" again
Go to manage Jenkins -> Manage Plugins
-> search "Role-based authorization strategy"
-> install without restart
Go to jenkins home -> Manage Jenkins
-> Configure Global Security
-> Select Role Based Strategy -> Save
login as "bhupinder" -> Access denied
Now, Attach permissions
go to jenkins -> Manage Jenkins -> Manage
and assign Role -> Manage Roles
Role to add -> Employee
go to item project -> add developer & Tester
| |
pattern ->dev test
Then Assign roles
user/group to add - bhupinder, rajput
item Roles
user developer Tester
Bhupinder
do practical for role creation and assignment.
do install of jenkins on Linux system
What is Maven, why we use it?
Build Tool
Manages Dependencies
Project Management Tool
Java Project
Java Project Structure
- Source Code
- Test Code
- Project Structure (assets, directories, Resources)
- Dependencies/ Library
- Configuration
- Task Runner - Build, test, Run
- Reporting
Maven
- Maven is an Automation and Project management tool developed by Apache software foundation. It is based on POM(Project object Model).
- Maven can build any number of projects into desired output such as .jar, .war, metadata
- Mostly used for Java based projects.
- It was initially released on 13 july 2004 .
- Maven is written in Java.
- Meaning of Maven is "Accumulator of knowledge".
- Maven helps in getting the right jar file for each project as there may be different version of separate Packages.
- To download dependencies it is no more needed to visit the official website of each s/w. It could now be easily done by visiting "mvnrepository.com"
Dependencies - It refers to the Java libraries that are needed for the project.
Repositories - Refers to the directories of packaged jar files.
Build Tools
C, C++ - Make file
.Net : Visual Studio
Java : Ant, Maven, gradle
Problems without Maven
In case of stubs, spring, we need to add jar files in each project. It must include all the dependencies of jars also.
2. Creating the right Project structure ->
We must create the right project structure in servlet, struts etc, otherwise it will not be executed.
For eg -> .war file layout
new jar
|
|-------index.hml
|-------web-INF
| |
| |-------web.xml
| |-------weblogic.xml
| |-------classes
3. Building and deploying the project -> we must have to build and deploy the project so that it may work.
What Maven does?
- It makes a project easy to build
- It provides project information (for eg. log document, cross reference source, mailing list, dependency list, unit test)
- Easy to add new dependencies Therefore, Apache Maven helps to Manage:-
- build
- Dependencies.
- Reports
- Releases
- Distribution
Architecture of Maven
Diff b/w Ant and Maven
Ant
Ant does not has formal conventions, so we need to provide information of the project structure in build.xml file
- Ant is procedural, you need to provide info about what to do and when to do through code.
- There is no lifecyle in Ant
- It is a tool box
- It is mainly a build tool
- It is less preferred than Maven
Maven
Maven has a convention to place source code, Compiled code etc, so we don't need to provide information about the project structure in pom.xml file.
- Maven is declarative, everything you define in the pom.xml file
- There is a life-cycle in Maven
- It is a framework
- It is mainly a project Management tool
- It is more preferred.









No comments:
Post a Comment