{"id":8643,"date":"2020-01-11T10:20:44","date_gmt":"2020-01-11T10:20:44","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=8643"},"modified":"2021-11-13T12:04:29","modified_gmt":"2021-11-13T12:04:29","slug":"jenkins-interview-questions-and-answers-part-6","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/jenkins-interview-questions-and-answers-part-6\/","title":{"rendered":"Jenkins Interview Questions and Answers \u2013 Part 6"},"content":{"rendered":"\n<p><strong>What are the parts of the task lifecycle<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Execution<\/li><li><strong>Initialization, Configuration, Execution (Ans)<\/strong><\/li><li>Initialization, Configuration, Execution, Finalization <\/li><li>Configuration, Execution <\/li><\/ul>\n\n\n\n<p><strong>How do you declare a typed task?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>task copyImages (type: Copy) (Ans)<\/strong><\/li><li>Copy copyImages<\/li><li>task copyImages (Copy)<\/li><\/ul>\n\n\n\n<p><strong>In a multi project build which two files do I need to add to the top level project?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>build.gradle and build.settings<\/li><li>multi.gradle and settings.gradle<\/li><li><strong>build.gradle and settings.gradle (Ans)<\/strong><\/li><li>build.gradle and settings.properties <\/li><\/ul>\n\n\n\n<p><strong>What does the wrapper task do?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Wraps up the code so that any exceptions are caught<\/li><li>Wraps gradle so it can be used from an IDE such as Eclipse<\/li><li>Installs an extra set of Java tasks to make testing easier<\/li><li><strong>Ensures that all developers use the same version of Gradle to build the code (Ans) <\/strong><\/li><\/ul>\n\n\n\n<p><strong>What is the syntax for filtering tests in gradle?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>add a test { filter {} } closure (Ans)<\/strong><\/li><li>build only the tests you want to run<\/li><li>you have to run all the tests, you cannot filter<\/li><li>add the test-filter plugin<\/li><\/ul>\n\n\n\n<p><strong>What does taskA.finalizedBy taskB do?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Causes taskB to run before taskA<\/li><li>Nothing, this is not yet available in Gradle<\/li><li><strong>Causes taskB to run after taskA (Ans)<\/strong><\/li><li>Causes taskA and taskB to run in parallel <\/li><\/ul>\n\n\n\n<p>How do you declare a task?<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Task taskName (Ans)<\/strong><\/li><li>Task.withName taskName<\/li><li>taskName: Task<\/li><li>Task: taskName<\/li><\/ul>\n\n\n\n<p><strong>When copying files you can use which method to replace text?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>expand (Ans)<\/strong><\/li><li>replace<\/li><li>insert<\/li><li>regex <\/li><\/ul>\n\n\n\n<p><strong>How do you declare dependencies between tasks?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>taskA : taskB<\/li><li>taskB.runsBefore taskA<\/li><li>taskA.depends taskB<\/li><li><strong>taskA.dependsOn taskB  (Ans)<\/strong><\/li><\/ul>\n\n\n\n<p><strong>Which of the following is valid gradle syntax to add a compile dependency on junit?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>compile name=junit version=4.1.2<\/li><li><strong>compile &#8216;junit:junit:4.1.12&#8217; (Ans)<\/strong><\/li><li>compile &#8216;junit:4.12&#8217;<\/li><li>compile &#8216;junit:version:4.1.12&#8217; <\/li><\/ul>\n\n\n\n<p><strong>What is the syntax for defining a repository in Gradle?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>use jcenter()<\/li><li><strong>repositories { jcenter() } (Ans)<\/strong><\/li><li>repository: jcenter() <\/li><li>repositories: jcenter() <\/li><\/ul>\n\n\n\n<p><strong>When you call doLast on a task twice passing different closures what happens?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Only the first closure is executed<\/li><li>Neither closure is executed, it is an error<\/li><li>Only the last closure is executed<\/li><li><strong>Both closures are executed (Ans)<\/strong><\/li><\/ul>\n\n\n\n<p><strong>How do you add the java plugin?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>apply java plugin<\/li><li><strong>apply plugin &#8216;java&#8217; (Ans)<\/strong><\/li><li>java &#8216;plugin&#8217;<\/li><li>Do nothing. The plugin is always enabled <\/li><\/ul>\n\n\n\n<p><strong>If you use the gradle-testsets-plugin how do you add an integrationTest sourceset in gradle?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>testSets { integrationTest = &#8216;myDir&#8217; }<\/li><li>integrationTest { dirName=&#8217;myDir&#8217;}<\/li><li><strong>testSets { integrationTest { dirName=&#8217;myDir&#8217; } } (Ans)<\/strong><\/li><li>testSets { dirName=&#8217;myDir&#8217;} <\/li><\/ul>\n\n\n\n<p><strong>When you use the &lt;&lt; syntax which method on the task is executed?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>last<\/li><li>first<\/li><li>doFirst<\/li><li><strong>doLast  (Ans)<\/strong><\/li><\/ul>\n\n\n\n<p><strong>When you taskA.mustRunAfter taskB<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>taskB always runs after<\/li><li>taskA always runs after taskB<\/li><li><strong>taskA runs after taskB only if both tasks are scheduled to run  (Ans)<\/strong><\/li><\/ul>\n\n\n\n<p><strong>If I want to run a java application which plugin do I use?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>java-runner<\/li><li>java<\/li><li>run<\/li><li><strong>application (Ans)<\/strong><\/li><\/ul>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_41723\"><iframe loading=\"lazy\"  id=\"_ytid_80127\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_41723\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>What are the parts of the task lifecycle Execution Initialization, Configuration, Execution (Ans) Initialization, Configuration, Execution, Finalization Configuration, Execution How do you declare a typed task? task copyImages (type: Copy)&#8230; <\/p>\n","protected":false},"author":1,"featured_media":8681,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[42],"tags":[641,766,145,482],"class_list":["post-8643","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jenkins","tag-answers","tag-interview","tag-jenkins","tag-questions"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/8643","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=8643"}],"version-history":[{"count":3,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/8643\/revisions"}],"predecessor-version":[{"id":25154,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/8643\/revisions\/25154"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/8681"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=8643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=8643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=8643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}