Contents

  1. What is Jenkins and why is it used?

    Answer: Jenkins is a continuous integration (CI) tool for real-time testing and reporting of smaller builds in a large chunk of code. It is written in Java. It is used because it helps developers and testers work in tandem to detect and close defects early in the software development lifecycle and encourage automated testing of builds.

  2. List some features of Jenkins.

    Answer: Features of Jenkins are –
    Free and open source
    Excellent community and documentatio
    Exhaustive set of plugins and integrations
    Easy to set up, install and use on any platform because it is based on Java
    Supports distributed builds due to master-slave architecture, thus reducing the load on the CI server

  3. What are the advantages of using Jenkins?

    Answer: Advantages of Jenkins are –

    Provides great collaboration between development and operations team, making it into a single DevOps team
    Code errors can be detected as early as possible.
    Code deployment is easy and happens in minutes, along with the generation of reports.
    Automation of integration work, thereby reducing the number of integration issues.

  4. How did Jenkins come into existence?

    Answer: Originally called Hudson, Jenkins came into existence when Oracle took over the ownership to continue development of the product, by renaming it as Jenkins.

  5. How is continuous integration achieved using Jenkins?

    Answer: Here are the steps –
    All the developers commit their source code changes to the shared Git repository.
    Jenkins server checks the shared Git repository at specified intervals and detected changes are then taken into the build.
    The build results and test results are shared to the developers
    The built application is displayed on a test server like Selenium and automated tests are ran.
    The clean and tested build is deployed to the production server.
    Here is a diagram that clearly represents these steps –

  6. Do you know any other continuous integration tools? How is Jenkins better than any of those?

    Answer: There are many other CI tools, the prominent ones being –
    TeamCity
    Bamboo
    Perforce
    Circle CI
    Go
    Thought Works
    Integrity
    Travis CI
    There are many more. We cannot say if Jenkins is better than each because each have their own unique features. For example, TeamCity offers great .NET support but is complex and costly, Travis CI is free just like Jenkins and has good documentation too. Bamboo offers efficient and faster builds but is not completely free and so on.

  7. What is DevOps and in which stage does Jenkins fit in?

    Answer: DevOps is a software development practice which blends software development (Dev) with the IT operations (Ops) making the whole development lifecycle simpler and shorter by constantly delivering builds, fixes, updates, and features. Jenkins plays a great role because it helps in this integration by automating the build, test and deployment process.

  8. What are the system requirements to install Jenkins?

    Answer: The minimum configuration required is –
    256MB of RAM
    1 GB of drive space
    Java
    Web browser
    Question 8: How do you install Jenkins?
    Answer: To install Jenkins, make sure the following are installed –
    Java (version 8)
    Apache Tomcat (version 9)
    Download the Jenkins war file and deploy it using Tomcat. You can choose to install the plugins suggested by Jenkins during the installation itself. Once the installation is done, you will be able to see the Jenkins dashboard.

  9. Give some important plugins in Jenkins.

    Answer: Here you go –
    Maven 2
    Gits
    Amazon EC2
    Join
    Copy artifact
    Green Balls
    HTML Publisher

  10. What is Groovy?

    Answer: Groovy from Apache is a language for Java platform. It is the native scripting language for Jenkins. Groovy-based plugins enhance Jenkins with great interfaces and build reports that are dynamic and consistent.

  11. Give a simple use case/scenario to explain how Jenkins works.

    Answer:
    Let us say a developer is working on some code changes and eventually commits them to the repository.
    Jenkins server, which constantly checks for changes in the repository, detects the change and pulls the changes to trigger a build.
    The build can fail, in which case the developer is informed with reports.
    If the build passes, it is deployed on to the test server.
    Once the testing is complete, a test report is generated and sent to the developers. This process continues till all the tests are successful, after which code is deployed to production.

  12. Can you start Jenkins using command line? How?

    Answer: Yes, using jenkins.exe start

  13. What are the SCM tools that Jenkins supports?

    Answer: The SCM or Source Code Management tools Jenkins supports are SVN, ClearCase, CVS, Git, Accrue, Perforce, RTC, Mercurial.

  14. What is a job in Jenkins?

    Answer: A job or build job is a task or step in the entire build process. It could be compiling the source code, running unit tests, deploying the application to the web server and so on.

  15. How can you create a job?

    Answer: On the dashboard page, you can just select a ‘New Job’. When you create a job, you can choose options such as the SCM, triggers to control, the build script and notifications.

  16. What is meant by Jenkins pipeline?

    Answer: A pipeline is a group of interlinked jobs done one after the other in a sequence. To integrate and implement continuous delivery pipelines, Jenkins pipelines provides a combination of plugins. The instructions to be performed are given through code. A continuous delivery pipeline can be represented as –

  17. What are the types of pipelines in Jenkins?

    Answer: There are 3 types –
    CI CD pipeline (Continuous Integration Continuous Delivery)
    Scripted pipeline
    Declarative pipeline

  18. What syntax does Jenkins use to schedule build job or SVN polling?

    Answer: The cron syntax.
    Cron syntax is represented using five asterisks each separated by a space. The syntax is as follows – [minutes] [hours] [day of the month] [month] [day of the week]. Example, if you want to set up a cron for every Monday at 11.59 pm, it would be
    59 11 * * 1

  19. Have you created a build job in Jenkins? Explain how to do it.

    Answer: Yes. The simple steps are –
    Click on New Item on the Dashboard.
    Select the freestyle project option
    Specify the details of the job like SCM, build triggers, advanced options etc.…
    It is important to specify the location of files that should be built.
    Once all the settings are marked, click on ‘Add build step’ and select the appropriate option. For example, if you want to build a file, select the file name along with the build command.
    Click on Build now for saving the build and doing a test run.

  20. How does Jenkins authenticate users?

    Answer: There are 3 ways –
    The default way is to store user data and credentials in an internal database.
    Configure Jenkins to use the authentication mechanism defined by the application server on which it is deployed.
    Configure Jenkins to authenticate against LDAP server.

  21. How can you use a third-party tool in Jenkins?

    Answer: Let us say we want to use the third-party tool Node.
    First make sure Node is installed.
    Though the Jenkins admin console, install the Jenkins plugin for node.
    Go to manage in the admin console and configure the settings on the Tools tab.
    You can add any configured NodeJS tool to your build job in a pipeline
    For different third-party tools, the procedure may vary slightly, because of the difference in configuration settings.

  22. What is an agent?

    Answer: Agent specifies the execution point for a stage in the pipeline or the entire pipeline itself.

  23. How do you define parameters in Jenkins?

    Answer: A build can take several input parameters to execute. For example, if you have multiple test suites, but you want to run only one. You can set a parameter to decide which one should be run. To have parameters in a job, you need to specify the same while defining the parameter. The parameter can be a string, file or custom.

  24. What are the ways to configure Jenkins node agent to communicate with Jenkins master?

    Answer: There are 2 ways to start the node agent –
    Browser – if Jenkins node agent is launched from a browser, a JNLP (Java Web Start) file is downloaded. This file launches a new process on the client machine to run jobs.
    Command line – to start the node agent using the command line, the client needs the executable agent.jar file. When this file is run, it launches a process on the client to communicate with the Jenkins master to run build jobs.

  25. What is a trigger? Give an example of how the repository is polled when a new commit is detected.

    Answer: Triggers define when and how pipelines should be executed.
    When Jenkins is integrated with an SCM, for example, Git, the repository can be polled every time there is a commit.
    The Git plugin should be first installed and set up.
    After that, you can build a trigger that specifies when a new build should be started. For example, you can create a job that polls the repository and triggers a build when a change is committed.

  26. What is the use of JENKINS_HOME directory?

    Answer: All the settings, logs and configurations are stored in the JENKINS_HOME directory.

  27. What is a backup plugin? Why is it used?

    Answer: This is a useful plugin that backs up all the critical settings and configurations to be used in the future. This is especially useful when there is a failure so that we don’t lose the settings.

  28. If your project build is broken, what should you do?

    Answer: There are 2 ways to resolve a broken build –
    Open the console and double check if all the files are taken. If any changes are missing, place them correctly.
    Replicate the problem on your local set up to debug and fix the issue.

  29. Let us say, you have a pipeline. The first job was successful, but the second failed. What should you do next?

    Answer: You can restart the pipeline from the point where it failed by doing ‘restart from stage’.

  30. How do you move or copy Jenkins from an old server to a new one?

    Answer: All the configurations, settings are stored in the JENKINS_HOME (/var/lib/Jenkins) directory. You should copy the entire home directory to the new server. To do so, you can use the command ‘rsync’.

  31. What is the Git plugin?

    Answer: Git plugin is used when you are using Git as the repository.

  32. What is Maven? What is the benefit of integrating maven with Jenkins?

    Answer: Maven is a build management tool. Using a simple pom.xml, one can configure all the dependencies needed to build, test and run the code. Maven manages the full lifecycle of a test project. Once integrated with Jenkins, the maven Web driver will build the project and execute all tests efficiently.

  33. Have you run automated tests on Jenkins? How is it done?

    Answer: Yes. Automated tests can be run through tools like Selenium or maven. Developers can schedule the test runs. Jenkins displays the test results and sends a report to the developers.

  34. What is Kubernetes? How can you integrate Jenkins with Kubernetes?

    Answer: Kubernetes is a container orchestration tool. With Kubernetes, one can create multiple container instances to achieve more fault tolerance. You can use the Kubernetes deploy plugin to use it with Jenkins for continuous deploy.

  35. Do you know about cloud computing? How can Jenkins fit into a cloud computing environment? Explain with an example.

    Answer: Let us take the example of AWS cloud service. Cloud computing services use the CI/CD model so that they can push their work to the customers and constantly receive feedback. Jenkins is used to automating the CI/CD pipelines. For example, a lot of Jenkins plugins are available for many of the AWS services like Amazon EC2 and ECS.

  36. What is the programming language used to build Jenkins?

    Answer: Jenkins is an open source automation server written in Java.

  37. What are the features of Jenkins?

    Answer: Jenkins has many features like:
    Continuous Integration and Continuous Delivery – As an extensible automation server, Jenkins can be used as a simple CI server or turned into the continuous delivery hub for any project.
    Easy installation – Jenkins is a self-contained Java-based program, ready to run out-of-the-box, with packages for Windows, Mac OS X and other Unix-like operating systems.
    Easy configuration – Jenkins can be easily set up and configured via its web interface, which includes on-the-fly error checks and built-in help.
    Plugins – With hundreds of plugins in the Update Center, Jenkins integrates with practically every tool in the continuous integration and continuous delivery toolchain.
    Extensible – Jenkins can be extended via its plugin architecture, providing nearly infinite possibilities for what Jenkins can do.
    Distributed – Jenkins can easily distribute work across multiple machines, helping drive builds, tests and deployments across multiple platforms faster.

  38. What is Continuous Integration (CI)?

    Answer: Continuous integration (CI) is a software engineering practice in which isolated changes are immediately tested and reported on when they are added to a larger code base.
    Continuous Integration (CI) is a development practice where developers integrate code into a shared repository frequently, preferably several times a day. Each integration can then be verified by an automated build and automated tests.

  39. What is a Jenkins Pipeline?

    Answer: Jenkins Pipeline (or simply “Pipeline”) is a suite of plugins which supports implementing and integrating continuous delivery pipelines into Jenkins.

  40. What is a Continuous delivery pipeline?

    Answer: A continuous delivery pipeline is an automated expression of your process for getting software from version control right through to your users and customers.

  41. What is Jenkins file and what it does?

    Answer: The definition of a Jenkins Pipeline is typically written into a text file called a Jenkins file which in turn is checked into a project’s source control repository.

  42. Can you write a simple Jenkins Pipeline Code for Java?

    Answer: Here is the simple Jenkins Pipeline Code for Java:
    Jenkins file (Declarative Pipeline)
    pipeline {
    agent {docker ‘maven:3.3.3’}
    stages {
    stage(‘build’) {
    steps {
    sh ‘mvn –version’
    }
    }
    }
    }

  43. What is Declarative Pipeline in Jenkins?

    Answer: Declarative Pipeline is a relatively recent addition to Jenkins Pipeline which presents a more simplified and opinionated syntax on top of the Pipeline sub-systems.
    All valid Declarative Pipelines must be enclosed within a pipeline block, for example:
    pipeline {
    /* insert Declarative Pipeline here */
    }

  44. What is the agent directive in Jenkins?

    Answer: The agent directive tells Jenkins where and how to execute the Pipeline, or subset thereof. As you might expect, the agent is required for all Pipelines.
    Underneath the hood, there are a few things agent causes to happen:
    All the steps contained within the block are queued for execution by Jenkins. As soon as an executor is available, the steps will begin to execute.
    A workspace is allocated which will contain files checked out from source control as well as any additional working files for the Pipeline.

  45. What is agent in Jenkins?

    Answer: The agent section specifies where the entire Pipeline, or a specific stage, will execute in the Jenkins environment depending on where the agent section is placed. The section must be defined at the top-level inside the pipeline block, but stage-level usage is optional.

  46. What are Parameters in Jenkins?

    Answer: In order to support the wide variety of use-cases Pipeline authors may have, the agent section supports a few different types of parameters. These parameters can be applied at the top-level of the pipeline block, or within each stage directive.

  47. What is post?

    Answer: The post section defines one or more additional steps that are run upon the completion of a Pipeline’s or stage’s run (depending on the location of the post section within the Pipeline).
    post can support one of the following post-condition blocks: always, changed, failure, success, unstable, and aborted. These condition blocks allow the execution of steps within the post section depending on the completion status of the Pipeline or stage.

  48. What are stages?

    Answer: Containing a sequence of one or more stage directives, the stages section is where the bulk of the “work” described by a Pipeline will be located. At a minimum it is recommended that stages contain at least one stage directive for each discrete part of the continuous delivery process, such as Build, Test, and Deploy.

  49. What is environment directive?

    Answer: The environment directive specifies a sequence of key-value pairs which will be defined as environment variables for the all steps, or stage-specific steps, depending on where the environment directive is located within the Pipeline.

  50. What are triggers?

    Answer: The triggers directive defines the automated ways in which the Pipeline should be re-triggered. For Pipelines which are integrated with a source such as GitHub or Bitbucket, triggers may not be necessary as webhooks-based integration will likely already be present. The triggers currently available are corn, polls and upstream.

  51. What is input directive?

    Answer: The input directive on a stage allows you to prompt for input, using the input step. The stage will pause after any options have been applied, and before entering the stage`s `agent or evaluating its when condition. If the input is approved, the stage will then continue. Any parameters provided as part of the input submission will be available in the environment for the rest of the stage.

  52. What is Parallel in Jenkins?

    Answer: Stages in Declarative Pipeline may declare several nested stages within them, which will be executed in parallel. Note that a stage must have one and only one of either steps or parallel. The nested stages cannot contain further parallel stages themselves, but otherwise behave the same as any other stage. Any stage containing parallel cannot contain agent or tools, since those are not relevant without steps.

Write A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.