title
Complete Jenkins Pipeline Tutorial | Jenkinsfile explained

description
In this complete Jenkins Pipeline Tutorial, I explain everything you need to know about Jenkinsfile. ► Subscribe To Me On Youtube: https://bit.ly/2z5rvTV This complete Jenkins Pipeline Tutorial will help you configure build pipeline for your own project using Jenkinsfile. Gitlab Link: https://gitlab.com/nanuchi/techworld-js-docker-demo-app/-/blob/dev/Jenkinsfile ▬▬▬▬▬▬ T I M E S T A M P S ⏰ ▬▬▬▬▬▬ 0:00 Intro 0:11 What is Jenkinsfile? 0:50 From Scripted to Declarative Pipeline Syntax 2:48 Basic Structure of Jenkinsfile 8:40 Post Build Actions in Jenkinsfile 10:15 Define Conditionals / When expression 12:45 Using Environmental Variables in Jenkinsfile 20:13 Using Tools attribute for making build tools available 22:30 Using Parameters for a Parameterized Build 27:29 Using external Groovy scripts #devops #jenkins #docker #techworldwithnana #devopstools ▬▬▬▬▬▬ Want to learn more? 🚀 ▬▬▬▬▬▬ Complete Docker and Kubernetes tutorial ► https://bit.ly/2YGeRp9 What is Kubernetes? ► https://youtu.be/VnvRFRk_51k Docker 🐳 vs Kubernetes ► https://youtu.be/9_s3h_GVzZc Complete Jenkins Pipeline Tutorial ► https://youtu.be/7KCS70sCoK0 ▬▬▬▬▬▬ Courses & Bootcamp & Ebooks 🚀 ▬▬▬▬▬▬ ► Become a DevOps Engineer - full educational program 👉🏼 https://bit.ly/45mXaer ► High-Quality and Hands-On Courses 👉🏼 https://bit.ly/3BNS8Kv ► Kubernetes 101 - compact and easy-to-read ebook bundle 👉🏼 https://bit.ly/3Ozl28x ▬▬▬▬▬▬ Connect with me 👋 ▬▬▬▬▬▬ Join private Facebook group ► https://bit.ly/32UVSZP DEV ► https://bit.ly/3h2fqiO INSTAGRAM ► https://bit.ly/2F3LXYJ TWITTER ► https://bit.ly/3i54PUB LINKEDIN ► https://bit.ly/3hWOLVT

detail
{'title': 'Complete Jenkins Pipeline Tutorial | Jenkinsfile explained', 'heatmap': [{'end': 422.293, 'start': 334.997, 'weight': 0.73}], 'summary': 'This tutorial covers understanding jenkins files, configuring stages, conditional stage execution, environmental variables, using credentials, tools attribute, and parameters in jenkins pipelines, as well as leveraging external scripts and groovy for improved build process and efficiency.', 'chapters': [{'end': 217.956, 'segs': [{'end': 93.984, 'src': 'embed', 'start': 51.71, 'weight': 0, 'content': [{'end': 57.675, 'text': "So I have this demo project here that I'm going to use to demonstrate Jenkins file and configure a build with it.", 'start': 51.71, 'duration': 5.965}, {'end': 61.238, 'text': 'The first step is to create Jenkins file in your repository.', 'start': 58.156, 'duration': 3.082}, {'end': 68.064, 'text': "So I'm going to create a new file in my dev branch and call it Jenkins file.", 'start': 61.659, 'duration': 6.405}, {'end': 70.667, 'text': 'So code is where your Jenkins file lives.', 'start': 68.284, 'duration': 2.383}, {'end': 80.815, 'text': 'Now, how do you create a Jenkins file? How does syntax look like? And this is the most basic Jenkins file that basically does nothing.', 'start': 71.247, 'duration': 9.568}, {'end': 82.436, 'text': 'But this is a basic syntax.', 'start': 81.095, 'duration': 1.341}, {'end': 86.158, 'text': "But here I'm going to explain you the required attributes for Jenkins file.", 'start': 82.676, 'duration': 3.482}, {'end': 93.984, 'text': 'So the first thing is that Jenkins file can be written as a scripted pipeline or a declarative pipeline.', 'start': 86.439, 'duration': 7.545}], 'summary': 'Demonstrating jenkins file creation for a demo project.', 'duration': 42.274, 'max_score': 51.71, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7KCS70sCoK0/pics/7KCS70sCoK051710.jpg'}, {'end': 192.3, 'src': 'embed', 'start': 166.683, 'weight': 3, 'content': [{'end': 174.508, 'text': 'So what we saw here, the note definition is basically same as these two lines here.', 'start': 166.683, 'duration': 7.825}, {'end': 179.7, 'text': 'So in a declarative pipeline, you declare that you are writing a pipeline.', 'start': 175.037, 'duration': 4.663}, {'end': 186.937, 'text': 'An agent any basically means that this build is going to run on any available Jenkins agent.', 'start': 180.453, 'duration': 6.484}, {'end': 189.038, 'text': 'An agent can be a note.', 'start': 187.417, 'duration': 1.621}, {'end': 192.3, 'text': 'It could be executed on that note, whatever.', 'start': 189.259, 'duration': 3.041}], 'summary': "Declarative pipeline uses 'agent any' to run on any available jenkins agent.", 'duration': 25.617, 'max_score': 166.683, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7KCS70sCoK0/pics/7KCS70sCoK0166683.jpg'}], 'start': 0.249, 'title': 'Jenkins files and declarative pipeline', 'summary': "Covers understanding jenkins files, creating and configuring them, discussing syntax, attributes, and differences between scripted and declarative pipelines, and explaining 'agent any' in declarative pipeline for jenkins clusters.", 'chapters': [{'end': 70.667, 'start': 0.249, 'title': 'Understanding jenkins files', 'summary': 'Explains what jenkins file is, its purpose, and how to create and configure it, emphasizing its role as pipeline as code and the process of creating a jenkins file in a repository.', 'duration': 70.418, 'highlights': ['Jenkins file is a scripted pipeline, which is part of infrastructure as code concept, enabling the configuration of builds in a file instead of on the Jenkins user interface.', 'Creating a Jenkins file in the repository with the code allows for the configuration of builds and their settings.', "Demonstrating the process of creating a Jenkins file in a repository using a demo project and creating the file in the 'dev' branch."]}, {'end': 166.083, 'start': 71.247, 'title': 'Jenkins file syntax and attributes', 'summary': 'Discusses the syntax and attributes of a jenkins file, highlighting the differences between scripted and declarative pipelines, and emphasizing the ease of use of the declarative pipeline for beginners.', 'duration': 94.836, 'highlights': ['Declarative pipeline syntax for Jenkins file is easier to get started with The declarative pipeline syntax is highlighted as easier to get started with, providing a pre-given structure to follow, which is beneficial for beginners.', 'Scripted pipeline allows writing the whole configuration using groovy script The scripted pipeline allows writing the entire Jenkins file configuration using groovy script, providing flexible configuration options.', 'Scripted pipeline is more powerful but may be difficult for those unfamiliar with groovy syntax The scripted pipeline is noted as more powerful than the declarative pipeline but may be challenging for individuals unfamiliar with groovy syntax to start with.']}, {'end': 217.956, 'start': 166.683, 'title': 'Declarative pipeline agent definition', 'summary': "Explains the usage of 'agent any' in a declarative pipeline, emphasizing its relevance when working with jenkins clusters and the requirement to always include it, ensuring the build runs on any available agent.", 'duration': 51.273, 'highlights': ["The usage of 'agent any' in a declarative pipeline is necessary to specify that the build can run on any available Jenkins agent, particularly relevant in Jenkins clusters with master and slaves.", "In a declarative pipeline, 'agent any' is equivalent to explicitly specifying a node and is a required attribute for the pipeline, ensuring the build runs on the next available agent."]}], 'duration': 217.707, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7KCS70sCoK0/pics/7KCS70sCoK0249.jpg', 'highlights': ['Creating a Jenkins file in the repository with the code allows for the configuration of builds and their settings.', 'Declarative pipeline syntax for Jenkins file is easier to get started with, providing a pre-given structure to follow, which is beneficial for beginners.', 'The scripted pipeline allows writing the entire Jenkins file configuration using groovy script, providing flexible configuration options.', "The usage of 'agent any' in a declarative pipeline is necessary to specify that the build can run on any available Jenkins agent, particularly relevant in Jenkins clusters with master and slaves."]}, {'end': 457.507, 'segs': [{'end': 379.748, 'src': 'embed', 'start': 349.566, 'weight': 1, 'content': [{'end': 350.427, 'text': 'And I have to again.', 'start': 349.566, 'duration': 0.861}, {'end': 356.39, 'text': "And I'm going to call it my app pipeline.", 'start': 352.408, 'duration': 3.982}, {'end': 362.014, 'text': "And I'm going to create a multi branch pipeline.", 'start': 359.552, 'duration': 2.462}, {'end': 368.96, 'text': 'And here is the configuration where I select the repository that I want to build.', 'start': 363.291, 'duration': 5.669}, {'end': 372.726, 'text': "So I'm going to configure the repository.", 'start': 370.222, 'duration': 2.504}, {'end': 379.748, 'text': "credentials If you don't know how credentials work in Jenkins, I have a separate video about that.", 'start': 374.926, 'duration': 4.822}], 'summary': 'Creating a multi-branch app pipeline in jenkins for repository building.', 'duration': 30.182, 'max_score': 349.566, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7KCS70sCoK0/pics/7KCS70sCoK0349566.jpg'}, {'end': 457.507, 'src': 'heatmap', 'start': 334.997, 'weight': 0, 'content': [{'end': 339.7, 'text': 'OK, so I have the Jenkins file and that just basically echoes some stuff.', 'start': 334.997, 'duration': 4.703}, {'end': 344.323, 'text': "And now let's see how to actually use that in a Jenkins pipeline.", 'start': 340.54, 'duration': 3.783}, {'end': 348.505, 'text': 'So the second step will be to go to Jenkins to create a new build.', 'start': 345.123, 'duration': 3.382}, {'end': 350.427, 'text': 'And I have to again.', 'start': 349.566, 'duration': 0.861}, {'end': 356.39, 'text': "And I'm going to call it my app pipeline.", 'start': 352.408, 'duration': 3.982}, {'end': 362.014, 'text': "And I'm going to create a multi branch pipeline.", 'start': 359.552, 'duration': 2.462}, {'end': 368.96, 'text': 'And here is the configuration where I select the repository that I want to build.', 'start': 363.291, 'duration': 5.669}, {'end': 372.726, 'text': "So I'm going to configure the repository.", 'start': 370.222, 'duration': 2.504}, {'end': 379.748, 'text': "credentials If you don't know how credentials work in Jenkins, I have a separate video about that.", 'start': 374.926, 'duration': 4.822}, {'end': 384.43, 'text': 'What scopes of credentials there are in Jenkins, how to create them and use them, et cetera.', 'start': 379.908, 'duration': 4.522}, {'end': 386.211, 'text': 'And that would be it.', 'start': 385.07, 'duration': 1.141}, {'end': 393.234, 'text': 'So basically this is my configuration and here I can specify which branches I want to build.', 'start': 386.271, 'duration': 6.963}, {'end': 397.536, 'text': "So I'm going to leave it at all the branches and let's see what happens.", 'start': 393.634, 'duration': 3.902}, {'end': 409.587, 'text': 'So here you see that it just basically went through all the branches that I have master dev.', 'start': 402.884, 'duration': 6.703}, {'end': 418.211, 'text': 'I have some test branches there and it scanned all the branches for Jenkins file and it only found things while in dev branch.', 'start': 409.907, 'duration': 8.304}, {'end': 422.293, 'text': "because that's where I created it and it built dev branch.", 'start': 418.211, 'duration': 4.082}, {'end': 424.914, 'text': "And let's see that actually see.", 'start': 422.613, 'duration': 2.301}, {'end': 431.617, 'text': 'that branch was built by Jenkins file and the stages that we define in the Jenkins file are this one here.', 'start': 424.914, 'duration': 6.703}, {'end': 435.36, 'text': 'so we said build, test and deploy into each one of them.', 'start': 431.617, 'duration': 3.743}, {'end': 437.641, 'text': 'You can see this echo command that we define.', 'start': 435.54, 'duration': 2.101}, {'end': 441.825, 'text': 'So building the application, testing the application, et cetera.', 'start': 437.681, 'duration': 4.144}, {'end': 449.911, 'text': 'So the first step here, which is declarative checking out SEM basically comes from this configuration here.', 'start': 442.385, 'duration': 7.526}, {'end': 457.507, 'text': 'So this implicitly defines the first stage of the pipeline, which is checking out the code.', 'start': 451.601, 'duration': 5.906}], 'summary': 'Setting up jenkins pipeline to build and deploy a multi-branch application, testing and deploying the code.', 'duration': 47.6, 'max_score': 334.997, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7KCS70sCoK0/pics/7KCS70sCoK0334997.jpg'}], 'start': 218.657, 'title': 'Jenkins pipeline stages and configuration', 'summary': 'Covers the definition of stages in a jenkins pipeline, enabling the execution of various commands in different stages, and configuring a multi-branch pipeline in jenkinsfile for building, testing, and deploying an application while scanning branches.', 'chapters': [{'end': 276.69, 'start': 218.657, 'title': 'Defining stages in jenkins pipeline', 'summary': 'Explains how to define stages in a jenkins pipeline, allowing for the execution of various commands in different stages, with the ability to define multiple stages and steps within each stage.', 'duration': 58.033, 'highlights': ['You can define multiple stages within a Jenkins pipeline, such as build, test, and deploy stages, to execute various commands (quantifiable data: multiple stages).', 'Each stage contains steps, where the script is defined to execute commands on the Jenkins server or agent (quantifiable data: script execution).']}, {'end': 457.507, 'start': 277.19, 'title': 'Jenkins pipeline configuration', 'summary': 'Explains how to configure a jenkins pipeline, create a multi-branch pipeline, and define stages for building, testing, and deploying an application, using jenkinsfile and jenkins. it also demonstrates the scanning of branches and executing the defined stages.', 'duration': 180.317, 'highlights': ['The chapter explains how to configure a Jenkins pipeline and create a multi-branch pipeline, using Jenkinsfile and Jenkins.', 'It demonstrates the scanning of branches and the execution of the defined stages for building, testing, and deploying an application.', "The Jenkinsfile defines stages for building, testing, and deploying the application, with echo commands specifying the actions like 'building the application', 'testing the application', and 'deploying the application'.", 'The scanning of branches for Jenkinsfile results in the execution of the defined stages, such as build, test, and deploy, for the identified branches, like master and dev.']}], 'duration': 238.85, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7KCS70sCoK0/pics/7KCS70sCoK0218657.jpg', 'highlights': ['You can define multiple stages within a Jenkins pipeline, such as build, test, and deploy stages, to execute various commands (quantifiable data: multiple stages).', 'The scanning of branches for Jenkinsfile results in the execution of the defined stages, such as build, test, and deploy, for the identified branches, like master and dev.', 'Each stage contains steps, where the script is defined to execute commands on the Jenkins server or agent (quantifiable data: script execution).', "The Jenkinsfile defines stages for building, testing, and deploying the application, with echo commands specifying the actions like 'building the application', 'testing the application', and 'deploying the application'.", 'The chapter explains how to configure a Jenkins pipeline and create a multi-branch pipeline, using Jenkinsfile and Jenkins.']}, {'end': 711.945, 'segs': [{'end': 535.144, 'src': 'embed', 'start': 457.767, 'weight': 0, 'content': [{'end': 464.834, 'text': 'And the second question is why or how is it configured that my pipeline looks for Jenkins file in those projects?', 'start': 457.767, 'duration': 7.067}, {'end': 466.976, 'text': 'And that configuration is right here.', 'start': 465.234, 'duration': 1.742}, {'end': 469.378, 'text': 'Build configuration, which is default.', 'start': 467.316, 'duration': 2.062}, {'end': 472.661, 'text': "I didn't set it or I didn't configure it by default.", 'start': 469.458, 'duration': 3.203}, {'end': 475.884, 'text': 'It looks for file called Jenkins file.', 'start': 472.741, 'duration': 3.143}, {'end': 478.945, 'text': 'And this is the path in the project.', 'start': 476.384, 'duration': 2.561}, {'end': 481.846, 'text': 'And I have Jenkins file in the root directory.', 'start': 479.746, 'duration': 2.1}, {'end': 483.907, 'text': "So I didn't change any of this.", 'start': 482.347, 'duration': 1.56}, {'end': 489.65, 'text': 'So this is all you need to do in order to configure a pipeline to build from Jenkins file.', 'start': 484.307, 'duration': 5.343}, {'end': 497.473, 'text': 'The rest of the configuration of individual steps of built pipeline will be done in the Jenkins file itself.', 'start': 489.93, 'duration': 7.543}, {'end': 508.951, 'text': "So let's go back to the Jenkins file and how can we see what attributes we can use to configure different parts of the build.", 'start': 501.161, 'duration': 7.79}, {'end': 517.562, 'text': 'So this is the basic syntax where we have the base construct inside the stages where we defined three different stages.', 'start': 509.672, 'duration': 7.89}, {'end': 525.577, 'text': 'So another thing you can do with Jenkins file is that at the end of it, you can define post attribute.', 'start': 518.351, 'duration': 7.226}, {'end': 535.144, 'text': 'So what it does is basically executes some kind of logic or some kind of scripts after all the stages are done.', 'start': 526.798, 'duration': 8.346}], 'summary': 'Configuring pipeline to build from jenkins file with basic syntax and post-attribute for executing scripts after stages.', 'duration': 77.377, 'max_score': 457.767, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7KCS70sCoK0/pics/7KCS70sCoK0457767.jpg'}, {'end': 618.234, 'src': 'embed', 'start': 584.297, 'weight': 5, 'content': [{'end': 585.258, 'text': 'And there are a couple of more.', 'start': 584.297, 'duration': 0.961}, {'end': 594.643, 'text': 'But to generalize in the post block, you basically define expressions of either build status or build status change.', 'start': 585.618, 'duration': 9.025}, {'end': 601.666, 'text': "So, for example, if the last bill change and now it's green again, you can use that condition as well here.", 'start': 595.003, 'duration': 6.663}, {'end': 605.888, 'text': "So now it's actually switched to the editor so that we can see the highlighting as well.", 'start': 602.106, 'duration': 3.782}, {'end': 607.469, 'text': "And let's continue from here.", 'start': 606.328, 'duration': 1.141}, {'end': 618.234, 'text': 'Another thing you can do in Jenkins, well, which is very useful, is define expressions or conditionals for each stage.', 'start': 608.249, 'duration': 9.985}], 'summary': 'In jenkins, you can define expressions for build status and stage conditionals.', 'duration': 33.937, 'max_score': 584.297, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7KCS70sCoK0/pics/7KCS70sCoK0584297.jpg'}], 'start': 457.767, 'title': 'Jenkins pipeline configuration and conditional stage execution', 'summary': 'Covers configuring a jenkins file for pipeline, including default build configuration and syntax for defining stages, as well as utilizing when expressions to conditionally execute stages based on branch name, improving build efficiency and reducing unnecessary test runs.', 'chapters': [{'end': 607.469, 'start': 457.767, 'title': 'Configuring jenkins file for pipeline', 'summary': 'Discusses the configuration of a jenkins file in a pipeline, including the default build configuration that looks for a file named jenkins file, the basic syntax and attributes for defining stages, and the use of post attributes to execute scripts based on different build conditions.', 'duration': 149.702, 'highlights': ['The default build configuration looks for a file named Jenkins file in the root directory of the project. The default build configuration automatically looks for a file called Jenkins file in the root directory of the project.', 'The basic syntax for Jenkins file involves defining stages and using the post attribute to execute scripts after all stages are completed. The basic syntax for Jenkins file includes defining stages and utilizing the post attribute to execute scripts after all stages are completed.', 'The post attribute allows the execution of scripts based on different build conditions such as success, failure, and always. The post attribute enables the execution of scripts based on different build conditions, including success, failure, and always.']}, {'end': 711.945, 'start': 608.249, 'title': 'Jenkins conditional stage execution', 'summary': 'Discusses utilizing when expressions in jenkins to conditionally execute stages based on the branch name, aiding in improving the efficiency of the build process and reducing unnecessary test runs.', 'duration': 103.696, 'highlights': ['You can use when expressions in Jenkins to define conditions for each stage, such as running tests only on the development branch, leading to improved build process efficiency.', 'The branch name in the build is always available in Jenkins file through an environmental variable called branch name, enabling conditional execution based on the current branch.', 'Utilizing when expressions enables skipping stages based on conditions, contributing to reducing unnecessary test runs and improving overall build efficiency.']}], 'duration': 254.178, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7KCS70sCoK0/pics/7KCS70sCoK0457767.jpg', 'highlights': ['The default build configuration automatically looks for a file called Jenkins file in the root directory of the project.', 'The basic syntax for Jenkins file includes defining stages and utilizing the post attribute to execute scripts after all stages are completed.', 'The post attribute enables the execution of scripts based on different build conditions, including success, failure, and always.', 'Utilizing when expressions enables skipping stages based on conditions, contributing to reducing unnecessary test runs and improving overall build efficiency.', 'You can use when expressions in Jenkins to define conditions for each stage, such as running tests only on the development branch, leading to improved build process efficiency.', 'The branch name in the build is always available in Jenkins file through an environmental variable called branch name, enabling conditional execution based on the current branch.']}, {'end': 894.599, 'segs': [{'end': 810.974, 'src': 'embed', 'start': 711.945, 'weight': 0, 'content': [{'end': 717.106, 'text': 'you only want to build your application if their code changes made in the project.', 'start': 711.945, 'duration': 5.161}, {'end': 728.67, 'text': "So, for example, in the build step, I can do something like if it's a death and code changes equals true.", 'start': 717.626, 'duration': 11.044}, {'end': 735.292, 'text': "And this could be a variable that you define yourself at the beginning, let's say outside the pipeline.", 'start': 729.87, 'duration': 5.422}, {'end': 744.367, 'text': 'And that basically has logic where gets keyed changes or something like this.', 'start': 737.642, 'duration': 6.725}, {'end': 754.915, 'text': 'So basically, this will be a groovy script that checks whether there has been any changes made in the code and sets the value of this Boolean.', 'start': 745.888, 'duration': 9.027}, {'end': 756.676, 'text': "So let's clear all this up again.", 'start': 755.175, 'duration': 1.501}, {'end': 764.902, 'text': 'And talk about environmental variables in Jenkins file, which is very important concept.', 'start': 760.078, 'duration': 4.824}, {'end': 774.988, 'text': 'So as I just showed, Jenkins provides some environmental variables out of the box for you to use them in Jenkins file like current branch name.', 'start': 766.283, 'duration': 8.705}, {'end': 778.67, 'text': 'But there are some other stuff that you might need for the logic.', 'start': 775.228, 'duration': 3.442}, {'end': 785.934, 'text': 'For example, you want to know which build number the current build has so you can use it in your versioning or some other stuff.', 'start': 779.01, 'duration': 6.924}, {'end': 790.797, 'text': 'So how do you know what variables you have available from Jenkins?', 'start': 786.275, 'duration': 4.522}, {'end': 797.766, 'text': 'The location where you can find that, which I find pretty practical, is In your Jenkins.', 'start': 791.257, 'duration': 6.509}, {'end': 798.468, 'text': "there's a U.R.L.", 'start': 797.766, 'duration': 0.702}, {'end': 801.918, 'text': 'in bars to HTML.', 'start': 799.411, 'duration': 2.507}, {'end': 809.474, 'text': 'that basically provides you with the list of all the environmental variables and you can use them in your Jenkins file.', 'start': 803.271, 'duration': 6.203}, {'end': 810.974, 'text': 'This is the one that we used.', 'start': 809.794, 'duration': 1.18}], 'summary': 'In jenkins file, use groovy script to check for code changes and leverage environmental variables for build logic.', 'duration': 99.029, 'max_score': 711.945, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7KCS70sCoK0/pics/7KCS70sCoK0711945.jpg'}, {'end': 894.599, 'src': 'embed', 'start': 860.135, 'weight': 1, 'content': [{'end': 861.876, 'text': "But I'm just going to write it like this.", 'start': 860.135, 'duration': 1.741}, {'end': 867.521, 'text': 'And the way that you can use that environmental variable in your script is like this.', 'start': 862.357, 'duration': 5.164}, {'end': 869.542, 'text': "So let's see.", 'start': 868.181, 'duration': 1.361}, {'end': 872.225, 'text': 'Building version.', 'start': 870.763, 'duration': 1.462}, {'end': 883.976, 'text': 'version And you also see the syntax highlighting that this is interpreted as a variable.', 'start': 878.695, 'duration': 5.281}, {'end': 892.359, 'text': 'And important thing to note here is that if I copy that and I put this in single quotes, this is what happens.', 'start': 884.837, 'duration': 7.522}, {'end': 894.599, 'text': 'And this is a syntax of groovy.', 'start': 893.139, 'duration': 1.46}], 'summary': 'Demonstrating the use of environmental variables and groovy syntax for scripts.', 'duration': 34.464, 'max_score': 860.135, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7KCS70sCoK0/pics/7KCS70sCoK0860135.jpg'}], 'start': 711.945, 'title': 'Jenkins and pipeline environmental variables', 'summary': 'Discusses using groovy script in jenkins to check for code changes, accessing environmental variables provided by jenkins, defining custom environmental variables in a jenkins file, and defining and using environmental variables in a pipeline. it also provides an example of defining a version variable and using it in a script, while highlighting the syntax and potential issues.', 'chapters': [{'end': 828.042, 'start': 711.945, 'title': 'Jenkins file environment variables', 'summary': 'Discusses using a groovy script in jenkins to check for code changes, accessing environmental variables provided by jenkins and defining custom environmental variables in a jenkins file.', 'duration': 116.097, 'highlights': ['Jenkins provides environmental variables like current branch name and build number for use in Jenkins file.', 'A groovy script can be used to check for code changes and set a Boolean value accordingly.', 'The URL in Jenkins provides a list of all environmental variables and their descriptions.']}, {'end': 894.599, 'start': 832.688, 'title': 'Pipeline environmental variables', 'summary': 'Discusses defining and using environmental variables in a pipeline, with an example of defining a version variable and using it in a script, highlighting the syntax and potential issues.', 'duration': 61.911, 'highlights': ['The chapter explains how to define environmental variables in a pipeline, emphasizing their availability for all stages and providing an example of defining a version variable.', 'It mentions the importance of properly using environmental variables in scripts, highlighting the syntax for accessing them and the potential issue of incorrect usage within single quotes.', 'The speaker suggests calculating the version variable from code, indicating a best practice for defining environmental variables.', 'The chapter showcases the syntax highlighting for the environmental variable usage in the script, demonstrating its interpretation as a variable.', 'The speaker briefly mentions the syntax of Groovy, which is relevant to understanding the usage of environmental variables in the pipeline scripts.']}], 'duration': 182.654, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7KCS70sCoK0/pics/7KCS70sCoK0711945.jpg', 'highlights': ['A groovy script can be used to check for code changes and set a Boolean value accordingly.', 'The chapter explains how to define environmental variables in a pipeline, emphasizing their availability for all stages and providing an example of defining a version variable.', 'Jenkins provides environmental variables like current branch name and build number for use in Jenkins file.', 'The URL in Jenkins provides a list of all environmental variables and their descriptions.', 'The speaker suggests calculating the version variable from code, indicating a best practice for defining environmental variables.']}, {'end': 1347.697, 'segs': [{'end': 1283.813, 'src': 'embed', 'start': 1214.333, 'weight': 0, 'content': [{'end': 1219.316, 'text': 'Another useful thing that you can use in your file is tools attribute.', 'start': 1214.333, 'duration': 4.983}, {'end': 1225.599, 'text': 'So what tools does is basically provides you with build tools for your projects.', 'start': 1220.456, 'duration': 5.143}, {'end': 1232.362, 'text': 'So if you have a front and back end application, you would have some build tools configured for.', 'start': 1226.519, 'duration': 5.843}, {'end': 1236.104, 'text': 'that could be Maven Gradle or some other tool that you use.', 'start': 1232.362, 'duration': 3.742}, {'end': 1242.088, 'text': "And obviously, when you're building an application, you want to have those tools available.", 'start': 1236.624, 'duration': 5.464}, {'end': 1252.076, 'text': 'So, for example, in build, you would run something like Maven install or Gradle build, whatever, and you need to have those tools available.', 'start': 1242.148, 'duration': 9.928}, {'end': 1255.899, 'text': 'And one way to have those tools available is through these tools attribute.', 'start': 1252.316, 'duration': 3.583}, {'end': 1260.223, 'text': 'And there are three tools right now that Jenkins supports.', 'start': 1256.6, 'duration': 3.623}, {'end': 1263.645, 'text': "That's Gradle, Maven and JDK.", 'start': 1260.683, 'duration': 2.962}, {'end': 1269.349, 'text': 'If you need yarn or NPM, for example, you have to do it In another way.', 'start': 1264.026, 'duration': 5.323}, {'end': 1278.551, 'text': 'if you want to have a complete overview of how tools work and how we can use any built tool in your Jenkins file from your Jenkins configuration,', 'start': 1269.349, 'duration': 9.202}, {'end': 1283.813, 'text': 'I have made a separate video on that, where I explain the whole thing in detail, so you can check it out.', 'start': 1278.551, 'duration': 5.262}], 'summary': 'Jenkins supports gradle, maven, and jdk as build tools, but for yarn or npm, another method is needed.', 'duration': 69.48, 'max_score': 1214.333, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7KCS70sCoK0/pics/7KCS70sCoK01214333.jpg'}], 'start': 894.719, 'title': 'Using environmental variables, withcredentials wrapper, and tools attribute in jenkins', 'summary': 'Covers the use of environmental variables to access jenkins credentials, the withcredentials wrapper for secure credential usage in jenkins files, and utilizing the tools attribute for providing build tools, including the necessity of specific plugins and limitations in jenkins support.', 'chapters': [{'end': 1057.189, 'start': 894.719, 'title': 'Using environmental variables in jenkins', 'summary': 'Explains how to use environmental variables in jenkins to access credentials defined in jenkins, which can be used to connect to a development server and deploy a newly built application, including the method and plugin required for binding the credentials and the parameter for referencing the credentials.', 'duration': 162.47, 'highlights': ['The chapter explains how to use environmental variables in Jenkins to access credentials defined in Jenkins, which can be used to connect to a development server and deploy a newly built application.', 'It introduces the method or function that binds the credentials defined in Jenkins to environmental variables and the separate plugin called credentials binding plugin required for this purpose.', 'It discusses using the ID reference of the credentials in Jenkins as a parameter for the credentials binding plugin, enabling the usage of Jenkins credentials inside the Jenkins file.', 'The transcript also covers a practical example of using environmental variables for credentials, such as accessing the development server to copy the newly built artifact.']}, {'end': 1213.292, 'start': 1057.489, 'title': 'Using withcredentials wrapper in jenkins', 'summary': 'Discusses the usage of the withcredentials wrapper in jenkins to securely access credentials and use them in jenkins files, and emphasizes the need for the credentials and credentials binding plugins in jenkins.', 'duration': 155.803, 'highlights': ['The withCredentials wrapper allows direct definition of credentials in Jenkins files, providing a secure way to access them. The withCredentials wrapper allows direct definition of credentials in Jenkins files, providing a secure way to access them.', 'The withCredentials wrapper takes an object parameter, employing object syntax in Groovy to retrieve and use individual username and password credentials. The withCredentials wrapper takes an object parameter, employing object syntax in Groovy to retrieve and use individual username and password credentials.', 'The usage of the Credentials and Credentials Binding plugins in Jenkins is essential for creating and utilizing credentials securely in Jenkins files through environmental variables. The usage of the Credentials and Credentials Binding plugins in Jenkins is essential for creating and utilizing credentials securely in Jenkins files through environmental variables.']}, {'end': 1347.697, 'start': 1214.333, 'title': 'Using tools attribute in jenkins files', 'summary': 'Explains how to use the tools attribute in jenkins files to provide build tools for projects, such as maven, gradle, and jdk, and highlights the limitation of jenkins supporting only gradle, maven, and jdk as tools and the option to configure additional tools in the global tool configuration.', 'duration': 133.364, 'highlights': ['Jenkins supports three tools: Gradle, Maven, and JDK, making them available for use in Jenkins files.', 'Maven is pre-installed and configured in most recent versions of Jenkins, making it readily available for use in Jenkins files.', 'A separate video explains in detail how to work with and use any built tool in Jenkins files and Jenkins configuration.']}], 'duration': 452.978, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7KCS70sCoK0/pics/7KCS70sCoK0894719.jpg', 'highlights': ['The withCredentials wrapper allows direct definition of credentials in Jenkins files, providing a secure way to access them.', 'The usage of the Credentials and Credentials Binding plugins in Jenkins is essential for creating and utilizing credentials securely in Jenkins files through environmental variables.', 'The chapter explains how to use environmental variables in Jenkins to access credentials defined in Jenkins, which can be used to connect to a development server and deploy a newly built application.', 'Jenkins supports three tools: Gradle, Maven, and JDK, making them available for use in Jenkins files.', 'It introduces the method or function that binds the credentials defined in Jenkins to environmental variables and the separate plugin called credentials binding plugin required for this purpose.']}, {'end': 1644.651, 'segs': [{'end': 1505.578, 'src': 'embed', 'start': 1458.659, 'weight': 0, 'content': [{'end': 1464.603, 'text': 'And this could be, for example, you want to skip a certain stage on some builds and you can do that here.', 'start': 1458.659, 'duration': 5.944}, {'end': 1467.665, 'text': "So let's say you execute tests.", 'start': 1464.863, 'duration': 2.802}, {'end': 1478.464, 'text': "Parameter default value will be true and description, let's leave it here.", 'start': 1469.046, 'duration': 9.418}, {'end': 1479.906, 'text': 'So we can delete one of those two.', 'start': 1478.664, 'duration': 1.242}, {'end': 1487.326, 'text': "So now we've defined the parameters and we can actually see in practice how they're displayed in Jenkins built.", 'start': 1481.963, 'duration': 5.363}, {'end': 1492.49, 'text': 'And now you can use these parameters in any of your stages, which is pretty straightforward.', 'start': 1487.567, 'duration': 4.923}, {'end': 1494.251, 'text': 'You remember the expression that we used.', 'start': 1492.59, 'duration': 1.661}, {'end': 1498.534, 'text': 'So parameters are suitable usage for expressions.', 'start': 1494.431, 'duration': 4.103}, {'end': 1505.578, 'text': 'So, for example, here we want to define that whenever expression.', 'start': 1499.074, 'duration': 6.504}], 'summary': 'Jenkins allows skipping stages and using parameters in builds.', 'duration': 46.919, 'max_score': 1458.659, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7KCS70sCoK0/pics/7KCS70sCoK01458659.jpg'}], 'start': 1347.697, 'title': 'Using parameters in jenkins pipelines', 'summary': 'Illustrates the usage of parameters in jenkins pipelines, covering the ability to change behavior, define parameter types, default values, and predefined choices, as well as their impact on the jenkins build process, including the ability to skip certain stages based on parameter settings.', 'chapters': [{'end': 1451.715, 'start': 1347.697, 'title': 'Using parameters in pipelines', 'summary': 'Illustrates the usage of parameters in pipelines, where external configuration can be provided to change behavior, such as selecting a version for deployment, with examples of defining parameter types, default values, and predefined choices.', 'duration': 104.018, 'highlights': ['Parameters in pipelines allow for providing external configuration to change behavior, such as selecting a version for deployment.', 'The chapter provides examples of defining parameter types, default values, and predefined choices for parameters in pipelines.', 'Different types of parameters are supported, including string, choice, and boolean.']}, {'end': 1644.651, 'start': 1458.659, 'title': 'Using parameters in jenkins', 'summary': 'Covers how to define and use parameters in a jenkinsfile, demonstrating the usage of parameters in various stages and their impact on the jenkins build process, including the ability to skip certain stages based on parameter settings.', 'duration': 185.992, 'highlights': ['Parameters can be defined in a Jenkinsfile using default values and descriptions, and can be used in any stage of the build process. The transcript discusses how parameters with default values and descriptions can be defined in a Jenkinsfile and used across different stages of the build process.', "Using parameters in 'when' expressions allows for conditional execution of stages based on parameter settings, enabling the ability to skip certain stages. The transcript explains how parameters can be used in 'when' expressions to conditionally execute stages, demonstrating the ability to skip certain stages based on parameter settings.", 'Parameters defined in the Jenkinsfile apply to all branches, allowing for individual usage in every branch when building. The transcript highlights that parameters defined in the Jenkinsfile are applicable to all branches, providing individual usage in every branch during the build process.']}], 'duration': 296.954, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7KCS70sCoK0/pics/7KCS70sCoK01347697.jpg', 'highlights': ['Parameters in pipelines allow for providing external configuration to change behavior, such as selecting a version for deployment.', "Using parameters in 'when' expressions allows for conditional execution of stages based on parameter settings, enabling the ability to skip certain stages.", 'The chapter provides examples of defining parameter types, default values, and predefined choices for parameters in pipelines.', 'Parameters can be defined in a Jenkinsfile using default values and descriptions, and can be used in any stage of the build process.', 'Different types of parameters are supported, including string, choice, and boolean.', "Using parameters in 'when' expressions allows for conditional execution of stages based on parameter settings, enabling the ability to skip certain stages."]}, {'end': 2104.529, 'segs': [{'end': 1777.29, 'src': 'embed', 'start': 1748.537, 'weight': 1, 'content': [{'end': 1754.659, 'text': 'So I have this groovy script here that just defines one function, just echo something very simple and return.', 'start': 1748.537, 'duration': 6.122}, {'end': 1758.139, 'text': "This is important because otherwise you can't import it in Jenkins file.", 'start': 1754.699, 'duration': 3.44}, {'end': 1762.82, 'text': 'So how do I import and use that groovy function in Jenkins file?', 'start': 1758.619, 'duration': 4.201}, {'end': 1770.262, 'text': "So I'm going to go ahead and create an init section or init stage here in which I'm going to load that groovy script.", 'start': 1763.26, 'duration': 7.002}, {'end': 1777.29, 'text': 'And in order to load that, I need a script block because this is going to be groovy command.', 'start': 1771.223, 'duration': 6.067}], 'summary': 'Creating a jenkins file to import and use a groovy function defined in a script to be loaded in an init stage.', 'duration': 28.753, 'max_score': 1748.537, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7KCS70sCoK0/pics/7KCS70sCoK01748537.jpg'}, {'end': 1956.93, 'src': 'embed', 'start': 1928.128, 'weight': 0, 'content': [{'end': 1936.596, 'text': 'So whenever, for example, your logic of building the application changes and you have some complex logic here for example, in build application,', 'start': 1928.128, 'duration': 8.468}, {'end': 1941.001, 'text': 'you may want to extract the version from your palm file or from your gradle file.', 'start': 1936.596, 'duration': 4.405}, {'end': 1948.726, 'text': 'or maybe some other place and you have to build a new version construct depending on how you version your application.', 'start': 1941.481, 'duration': 7.245}, {'end': 1956.93, 'text': 'So all that logic will live in groovy script and Jenkins file will have more slim and simple structure.', 'start': 1949.046, 'duration': 7.884}], 'summary': 'Groovy script stores complex logic for building application versions in jenkins.', 'duration': 28.802, 'max_score': 1928.128, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7KCS70sCoK0/pics/7KCS70sCoK01928128.jpg'}, {'end': 2104.529, 'src': 'embed', 'start': 2089.664, 'weight': 5, 'content': [{'end': 2093.886, 'text': 'If you want to be notified whenever a new video comes out, then subscribe to my channel.', 'start': 2089.664, 'duration': 4.222}, {'end': 2101.648, 'text': "If you have any questions, if something wasn't clear in the video, please post them in the comment section below and I will try to answer them.", 'start': 2094.946, 'duration': 6.702}, {'end': 2104.529, 'text': 'So thank you and see you in the next video.', 'start': 2102.068, 'duration': 2.461}], 'summary': 'Encourage viewers to subscribe, ask questions, and thank them.', 'duration': 14.865, 'max_score': 2089.664, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7KCS70sCoK0/pics/7KCS70sCoK02089664.jpg'}], 'start': 1645.251, 'title': 'Using external scripts and groovy in jenkins', 'summary': 'Discusses the advantages of using external scripts and groovy in jenkins, including reducing file size, leveraging groovy scripts, simplifying file structure, enabling easier testing, version control, and branch-specific builds, with examples of global function import and testing changes without committing.', 'chapters': [{'end': 1902.079, 'start': 1645.251, 'title': 'Using external scripts in jenkins', 'summary': 'Explains the benefits of using external scripts in jenkins to manage complex pipeline steps, such as reducing the jenkins file size and leveraging the power of groovy scripts, with an example of importing and utilizing a groovy function globally across stages.', 'duration': 256.828, 'highlights': ['The chapter explains the benefits of using external scripts in Jenkins to manage complex pipeline steps. Using external scripts in Jenkins can help manage complex pipeline steps, such as building front end, running tests, building back end, creating Docker images, and pushing to repositories.', 'The chapter emphasizes leveraging the power of Groovy scripts to write more powerful logic in Jenkins files. Jenkins files support Groovy scripts, enabling the writing of more powerful logic, defining variables, and calling Gradle functions.', 'The chapter provides a detailed example of importing and utilizing a Groovy function globally across stages in Jenkins. A detailed example is provided on how to import and use a Groovy function globally across stages in Jenkins by creating an init section, loading the Groovy script, and making it globally available.']}, {'end': 2104.529, 'start': 1902.479, 'title': 'Using external groovy scripts in jenkins', 'summary': 'Explains how to use external groovy scripts in jenkins to simplify jenkins file structure and allows for easier testing and version control, while also demonstrating the practicality of branch-specific builds and testing changes without committing.', 'duration': 202.05, 'highlights': ['You can use all environmental variables in Groovy scripts without additional configuration, simplifying the Jenkins file structure. Accessing environmental variables through parameters or environment attributes in Groovy scripts eliminates the need for additional configuration, simplifying the Jenkins file structure.', 'Complex logic for building applications, such as extracting version from files, can be encapsulated in Groovy scripts, leading to a more concise Jenkins file structure. Complex logic for building applications, like extracting version from files, can be encapsulated in Groovy scripts, leading to a more concise Jenkins file structure.', 'The practicality of branch-specific builds is demonstrated, allowing for testing changes in the Jenkins file without committing. The practicality of branch-specific builds is demonstrated, allowing for testing changes in the Jenkins file without committing.']}], 'duration': 459.278, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/7KCS70sCoK0/pics/7KCS70sCoK01645251.jpg', 'highlights': ['Using external scripts in Jenkins can help manage complex pipeline steps, such as building front end, running tests, building back end, creating Docker images, and pushing to repositories.', 'Jenkins files support Groovy scripts, enabling the writing of more powerful logic, defining variables, and calling Gradle functions.', 'A detailed example is provided on how to import and use a Groovy function globally across stages in Jenkins by creating an init section, loading the Groovy script, and making it globally available.', 'Accessing environmental variables through parameters or environment attributes in Groovy scripts eliminates the need for additional configuration, simplifying the Jenkins file structure.', 'Complex logic for building applications, like extracting version from files, can be encapsulated in Groovy scripts, leading to a more concise Jenkins file structure.', 'The practicality of branch-specific builds is demonstrated, allowing for testing changes in the Jenkins file without committing.']}], 'highlights': ['The scripted pipeline allows writing the entire Jenkins file configuration using groovy script, providing flexible configuration options.', 'The declarative pipeline syntax for Jenkins file is easier to get started with, providing a pre-given structure to follow, which is beneficial for beginners.', "The usage of 'agent any' in a declarative pipeline is necessary to specify that the build can run on any available Jenkins agent, particularly relevant in Jenkins clusters with master and slaves.", 'You can define multiple stages within a Jenkins pipeline, such as build, test, and deploy stages, to execute various commands (quantifiable data: multiple stages).', 'The scanning of branches for Jenkinsfile results in the execution of the defined stages, such as build, test, and deploy, for the identified branches, like master and dev.', 'The post attribute enables the execution of scripts based on different build conditions, including success, failure, and always.', 'Utilizing when expressions enables skipping stages based on conditions, contributing to reducing unnecessary test runs and improving overall build efficiency.', 'The branch name in the build is always available in Jenkins file through an environmental variable called branch name, enabling conditional execution based on the current branch.', 'A groovy script can be used to check for code changes and set a Boolean value accordingly.', 'The chapter explains how to define environmental variables in a pipeline, emphasizing their availability for all stages and providing an example of defining a version variable.', 'The withCredentials wrapper allows direct definition of credentials in Jenkins files, providing a secure way to access them.', 'The usage of the Credentials and Credentials Binding plugins in Jenkins is essential for creating and utilizing credentials securely in Jenkins files through environmental variables.', 'Parameters in pipelines allow for providing external configuration to change behavior, such as selecting a version for deployment.', "Using parameters in 'when' expressions allows for conditional execution of stages based on parameter settings, enabling the ability to skip certain stages.", 'Using external scripts in Jenkins can help manage complex pipeline steps, such as building front end, running tests, building back end, creating Docker images, and pushing to repositories.', 'Jenkins files support Groovy scripts, enabling the writing of more powerful logic, defining variables, and calling Gradle functions.']}