Why use Jenkins or any other CI/CD Engine
- Refer the image below
- There are many alternatives to jenkins
- Azure DevOps (VSTS)
- Bamboo
- TeamCity
- Circle CI
- From Jenkins we need to create a pipeline to
- get the latest version of the code
- build the code into some package
- run some code quality tools
- upload the package to some repository
- deploy the application into various test environments
Lets understand how jenkins works and important terms of jenkins
- Lets start the Jenkins server
- Jenkins Job: This is sequence of actions to be performed to realize a ci/cd pipeline or part of pipeline
- To create a Jenkins job, in jenkins we need to create a jenkins project which specifies the steps to be performed as part of jenkins build.
- So when we execute a jenkins job/project then jenkins runs the steps mentioned in the job as a system user (default is jenkins) and shows the results
- Jenkins will store all of its configurations in JENKINS HOME Directory, In this case the jenkins home directory is /var/lib/jenkins
- The jenkins project which we create will be stored as an xml file in
JENKINS_HOME/jobs/<jobname>/config.xml
- When we run the jenkins job, jenkins uses workspace folder to store the build generated files
- Lets change the hellojenkins job to create some file and build the jenkins job
- Lets create a jenkins job which will clone git repository Refer Here
- So if we know manual steps for building the application, creating test environment and executing tests can we do that in jenkins
- So jenkins can be looked as scheduler which can run commands provided by user
- Jenkins has other features to make this simple. To make them simple Jenkins uses Plugins. A Plugin is a feature extension for jenkins which provides the user interface (in many cases) and some functionality
- Now lets create a jenkins job to clone a game of life repository using these plugins
- Now lets try to create a jenkins job to update ubuntu packages
sudo apt update
- This fails as jenkins user does not have permissions to execute sudo commands
- Now lets add jenkins user to sudoers group and then execute the same job
- Now, Can we run python –version in jenkins job. But the result whether this will be success or not depends on
- Whether python is installed or not on the Jenkins Machine
- Whether the user jenkins has permission to execute python or not.
- Next Steps:
- Lets learn how to build java code using maven