11. What are the two major components which are integrated with Jenkins?
Ans: Below are the two major components:
- Build tools like Maven script.
- Version control system or source code repository like Git repository.
Pipeline Script Fundamentals
12. Can you write a pipeline script where you can call your Maven with
automation suite?
node { | |
stage ('SCM checkout'){ | |
git "https://gitlab.com/mbabilo/experitest" | |
} | |
stage ('Build'){ | |
dir("comtest") { | |
sh "mvn clean install" | |
} | |
dir("comtest/target") { | |
sh "java -jar com.test-1.0-SNAPSHOT.jar" | |
} | |
} | |
} |
13. How to control the flow in Jenkins?
Ans: Jenkins flow can be controlled using Stage, Lock and Milestone.
stage - the
stage
step remains but is now focused on grouping steps and providing boundaries for Pipeline segments.lock - the
lock
step throttles the number of concurrent builds in a defined section of the Pipeline.milestone - the
milestone
step automatically discards builds that will finish out of order and become stale.
Ans: When installing a service to run under a domain user account, the account must have the right to logon as a service. This logon permission applies strictly to the local computer and must be granted in the Local Security Policy.
Perform the following steps below to edit the Local Security Policy of the computer you want to define the ‘logon as a service’ permission:
Logon to the computer with administrative privileges.
Open the Administrative Tools and open the Local Security Policy
Expand Local Policy and click on User Rights Assignment
In the right pane, right-click Log on as a service and select properties.
Click on the Add User or Group… button to add the new user.
In the Select Users or Groups dialogue, find the user you wish to enter and click OK
Click OK in the Log on as a service Properties to save changes.
After completing the steps above, try logging in again with the added user.
16. How to send email notification in Jenkins using groovy script? VERY IMP
Ans: The amount of memory Jenkins needs is largely dependent on multiple factors, which is why the RAM allotted for it can range from 200 MB for a small installation to 70+ GB for a single and massive Jenkins controller. However, you should be able to estimate the RAM required based on your project build needs.
Each build node connection will take 2-3 threads, which equals about 2 MB or more of memory. You will also need to factor in CPU overhead for Jenkins if there are a lot of users who will be accessing the Jenkins user interface.
18. How you can Fail a build in JenkinsFile?
Ans: By using error step from pipeline DSL we can be able to Fail a build, like : error("Build failed due to ....")
error
: Error signal
throw new Exception()
, but this step will avoid printing a stack trace.19. What is Pipeline, Node and Stage in Jenkins?
ANS: Click Here for All Pipeline Concepts and Terminology
20. How to catch error in jenkins file and set build result to failure?
Ans: By using catchError.
If the body throws an exception, mark the build as a failure, but nonetheless continue to execute the Pipeline from the statement following the catchError
step. The behavior of the step when an exception is thrown can be configured to print a message, set a build result other than failure, change the stage result, or ignore certain kinds of exceptions that are used to interrupt the build.
node { catchError { sh 'might fail' } step([$class: 'Mailer', recipients: 'admin@somewhere']) }
To explore more, please refer: catchError()
OutOfMemoryError
messages that you might encounter while a Jenkins job runs:java.lang.OutOfMemoryError: Heap space
– this means that you need to increase the amount of heap space allocated to Jenkins when the daemon starts.java.lang.OutOfMemoryError: PermGen space
– this means you need to increase the amount of generation space allocated to store Java object metadata. Increasing the value of the-Xmx
parameter will have no affect on this error.
On Ubuntu 12.04 LTS, uncomment the JAVA_ARGS
setting on line ten of /etc/default/jenkins
:
- To add more Java heap space, increase the value of the
-Xmx
Java parameter. That sets the maximum size of the memory allocation pool (the garbage collected heap). - To add more PermGen space, add the parameter
XX:MaxPermSize=512m
(replace512
with something else if you want more. The permanent generation heap holds meta information about user classes.
No comments:
Post a Comment