Skip to content
TheChatArchiveThe Chat Archive
gpt-4-turbo-2024-04-09· OpenAIAi2 WildChat-4.8M (AI2)

i am going tp give u the subtitles of a lecture on jenkins first job creation so please…

  1. User

    i am going tp give u the subtitles of a lecture on jenkins first job creation so please make notes from the subtitles but keep in mind that notes are in good format and only from this lecture not from web based

  2. Assistant

    Of course! Please provide the subtitles from the Jenkins first job creation lecture, and I will start making notes from them in a well-organized format.

  3. User

    Okay, now we are going to create an actual build job that is going to fetch the source code from GitHub

    and build the artifact by using MVN install command.

    So click on Create Job.

    And as you know, first we are learning freestyle.

    Later we'll migrate to Pipeline.

    So let's give this job a name.

    I will just call it as build and click on Freestyle and say, Okay.

    We'll give some description.

    Build artifact.

    From V profile source code.

    Okay, so we need Git Maven and JDK.

    Right.

    We have all those things.

    You get the option of selecting JDK here itself.

    You can select dropdown and you can say Oracle JDK 11.

    I'm going to select that one.

    But our job runs with both JDK 11 and eight.

    It works.

    Then selecting the source code Git.

    And here you can mention the URL.

    Now whenever you're confused, you're using different plugins which you have used, you know, first

    time, right?

    So what to enter where there is a small question mark if you click on that.

    It will give you a small help, not specify the URL or path of the git repository so you know what you

    have to put there.

    Most of the times the settings are self explanatory, but if you need any help.

    Let's click on that question mark and you get the help.

    So here we have to mention the URL of profile source code.

    So you can use this one GitHub.com slash coder slash profile hyphen project.

    Put this URL in the browser and here in the dropdown in the code, get the https URL.

    Okay, copy that.

    Go to our job and paste this URL over here.

    Now, this is a public repository and it can be cloned by anybody without giving any credentials, But

    if it's a private repository, then you need to mention the credentials over here.

    You have to click on this dropdown.

    Don't do it.

    Just see we are going to use the credentials later, so click on the dropdown.

    There is no credentials.

    You can add credentials.

    Drop down here, click on Jenkins.

    And there are different kinds of credentials.

    You can mention username and password.

    Or you can mention ssh private key secret file, secret text, different kinds of thing.

    We will see this later.

    Okay.

    For now, just cancel it.

    Now, keep that in mind.

    You can mention the credentials over here.

    Either username, password, ssh keys or tokens based on what kind of URL you are using for https.

    It will be definitely username and password.

    Okay, so this one is going to fetch the source code.

    Let's come down and here you have the branch to mention.

    Now master is not any branch over here.

    If you click on this drop down here, there is no branches master, you have branches main and few other

    branches.

    Let's use main.

    Okay.

    Star slash main.

    That's how you mention the branch name.

    You see, there are few other settings.

    We are not going to use it now.

    Come down, build triggers.

    As I told you, we'll do this later.

    Build environment, build step now drop down and we can click on execute Shell and we can mention the

    command MVN install, but not here.

    Okay.

    That's not the right way to do it.

    The right way is always through.

    The plugin.

    So you see here invoke top level maven targets.

    Click on that.

    So whenever you have plug in, use it.

    Don't use commands.

    Use commands only when there is no option of using any plugin.

    Otherwise always go with plugin because plugins gives you many more features you get you get to know,

    you get to mention different kinds of settings.

    It's also convenient and easy.

    For example, in here you can select which version of Maven you want.

    Default, which is from the system.

    Or you can say Maven three.

    That's what we added, remember?

    And in the goal in Maven especially sorry specifically for this one we have the goal as install.

    Make sure you write it install or you can say clean install, also clean install.

    So this is going to run the command mvn clean install.

    Now you see the other benefits of using plugin.

    You click on this dropdown advance.

    You see you can mention a different Pom.xml file.

    We have a Pom.xml file in our source code which it will fetch and that's the default one.

    But if you want you can mention other pom.xml file, you can mention different properties JVM options.

    Sometimes developers give you different option to mention.

    If you have to do it through command, it will be very long command, not so convenient and reusable.

    So many things are here.

    We are not going to change anything over here.

    We'll just save this before we save check.

    Once again, Goals Clean install maven version.

    Branch.

    Main.

    Repository URL.

    Oracle JDK 11.

    Okay, let's save this.

    And let's click on Build Now, now.

    Now this is going to create files, right?

    First you will have the source code and then it's going to build the artifact.

    You'll have the artifacts also.

    So you will see all those things in the workspace.

    You can click on this loading bar.

    It will take you directly to the console output.

    Now you can see the console output live.

    Okay.

    This is taking a very long time.

    I think the Jenkins is not able to handle all the load with T2 micro instance type.

    So let's wait for a moment.

    If it doesn't work out, we'll shut down Jenkins and we'll increase its instance type from T2 Micro

    to T2 Small.

    Okay.

    I think it's time.

    I'm not even able to log in to Jenkins, so I'm going to go to EC2 console.

    Select your Jenkins instance instance State Stop.

    Stop.

    Now, this might not stop also and we might need to use force.

    Stop also.

    Okay.

    It's not stopping.

    Let's go to monitoring.

    Okay.

    You see the CPU utilization in the monitoring section.

    Okay.

    It is spiking right high and it's not stopping the instance also.

    So I'm going to use force stop instance state for stop instance stop.

    Now, the reason I'm showing you all this, because you may also see the same problem and this is how

    you can solve it.

    Okay, it's stopped.

    I'm going to select it and going to go to action instance setting.

    And change instance type.

    Click on that.

    And from T2 Micro we'll go to T2, small T2.

    Scroll down.

    T too small.

    Okay.

    Carefully select T too small.

    Not anything else.

    Apply.

    And let's start.

    Jenkins.

    Now, what happened to that job?

    That job would have failed or cancelled?

    Well, look it.

    After logging in and when you stop and power on its IP will also change.

    So don't try to refresh the same IP.

    Just can close that tab.

    And you get a new public IP.

    Wait for a minute.

    After waiting for around three minutes, let's try again.

    Because Jenkins service also takes a little while to come up.

    Right.

    So new public IP, Colon 88.

    Okay, let's log in.

    Okay, that's our build job.

    Let's click on that.

    And it says no build history.

    You might see a failed one or a cancelled job.

    But for me, it's saying just no history.

    So I'm going to run this now.

    Okay, but gives the build ID number to the one did not save over there.

    Let's look at the console output now.

    Okay, Moving on.

    Okay, so first it's fetching the source code and that got completed successfully.

    And then you see it is using the tool that we mentioned at this path.

    It has saved the Maven three tool.

    So it's not just MVN clean install, it's the complete path of the tool and clean install.

    Let's come down.

    Okay.

    You should see the dependency getting downloaded.

    This is the similar output we have seen in Maven lecture.

    And at the end it says a success.

    Good.

    Got completed successfully.

    Let's go to the build job again.

    Let's check in the workspace.

    You should have the source code and you should have a target folder.

    And there you should have the artifact.

    We profile v2 dot var.

    Now you cannot view this right click on it and it should be downloading.

    You're not going to do anything with this artifact just showing you that you can download it from here.

    There are many other things which we are going to learn in coming lectures like unit testing and other

    things.

    Now I want to show you one more step in the job.

    Let's click on Configure.

    Okay, before that, just.

    Just one moment.

    Let's go back to build workspace.

    Okay, So we have the artifact here, right?

    But this is not really a very good way of storing the artifact.

    We will learn that when we use Nexus, we are going to store the artifact outside of Jenkins.

    This.

    Consider this a temporary storage.

    Okay.

    Many times we need to even clean the workspace like by wipe out current workspace.

    You can click on that.

    It's going to delete everything.

    From the workspace.

    When you click on workspace, you'll see you'll get no workspace error and you run the job.

    It creates the workspace once again.

    So click on Build now and wait for a moment.

    Okay, that got completed successfully.

    If you click on workspace, you should see the data again.

    And it's a new data.

    It fetched the source code again if there are any changes in the source code.

    It's going to pull the difference.

    If there is no data at all, it's going to definitely clone the source code.

    So that git plugin in the job is going to clone.

    Sorry, fetch the differences.

    It's not going to every time clone the source code again and again.

    Just fetch the difference.

    Whenever developer makes changes to the source code, you run the job, fetch the difference, build

    the artifact and see if it works or not.

    You have all the build history to see what time, what was executed and what was the output.

    We are going to make more sense out of this output in coming lectures.

    For now, we're going to learn one more step.

    Click on configure, scroll down.

    At the end you see post Build Action.

    So what to do after your build step is completed?

    There are many things and this list can increase or decrease based on what plugins you have.

    You can send email notifications.

    You can also archive the artifacts I want to show you this one.

    Click on Archive the artifacts.

    So what files do you want to archive?

    Now, this means from the workspace, take the files that you mentioned and archive it and keep it in

    a different location.

    So I'm going to say star, star slash star dot var.

    All this means is look for any file that ends with dot var, which is our artifact, right?

    Star dot vary.

    That is simple to understand.

    Star Star slash in the beginning means recursively look in each and every folder a file that ends with

    dot var and archive it.

    Okay.

    What's the benefit?

    We'll see in a moment.

    Let's save this.

    Right.

    And let's click on Build now.

    Wait for a minute or so.

    Okay.

    That got completed successfully, right.

    We know what's going to happen.

    It's going to pull the differences, build the artifact, overwrite the file that are with the same

    name.

    So artifact will get overwritten once again, if you right click on Build Job, refresh this page.

    Okay, now you see here last successful artifact.

    This is the artifact that was archived.

    And even if you clean your workspace, wipe out workspace.

    At refresh.

    Right.

    You see in the workspace, there is nothing.

    But if you look in the job, this is the artifact that was archived.

    So basically it takes the file that you mentioned, archived and store it in a different location from

    where you can download.

    Okay, I'm showing you this concept, but we are going to use much, much better way of archiving the

    artifact and versioning it by using Nexus Sonatype repository.

    Okay, let's create one more job and select our different tools and see how this one works.

    So I'm going to click on Dashboard.

    And I'm going to create one more job.

    Click on New item.

    I will name this job as build hyphen test and I'm not going to write everything in the job.

    I'll just select here freestyle and I'm going to copy everything.

    You see that option here?

    Copy from You can mention a job.

    We have a job.

    Write, build job showing in the list, also build job.

    So it's going to copy all the settings from the build job and.

    And mention in this build test job.

    See that there is a description.

    There's JDK version.

    Git repository.

    Everything is same from the build job, but we will tweak few things over here just to see whether our

    job works or not.

    Let's change from JDK 11 to JDK eight.

    Let's come down.

    Don't change the branch because we have this branch and come down.

    And here, instead of Maven three, we'll go with default.

    Now, default means we do not have any Maven tool installed.

    Right.

    There is no default versions for Maven.

    Let's see what happens.

    Let's save this.

    Wait, let me remove this step.

    Archive the artifact.

    I don't want this.

    Let's save this and let's run this build Now let's see what happens.

    Okay.

    It failed, obviously.

    Check that.

    And says envision clean installed, no such file or directory.

    Now this is misleading and basically it is telling that Env and the Maven MVN command is not found.

    Now we can fix this.

    We can log in to our Jenkins instance, run APT install maven, and then there will be a default maven.

    So let's do that.

    Let's copy the Jenkins public IP.

    Let's.

    Make sure your security group rules are updated.

    Otherwise it will show you connection timed out.

    Okay, clear the screen pseudo hyphen.

    I and I'm going to say apt install maven hyphen y.

    Wait.

    We might also need to run apt update apt update ampersand and person.

    So Empress and Empress.

    So run both command apt update and then apt install maven.

    Okay.

    Now there is Maven we can see MVN hyphen version.

    All right.

    So there is a default maven and it is using Java 11.

    All right.

    Let's go back to our job.

    And let's run it once again.

    Well now.

    Okay, let's look at the console output.

    Look, it's again downloading the dependency.

    That is because there's a different maven.

    And it's a success.

    Okay.

    So go ahead, go to configure, change, different version change, different maven version.

    See, it works.

    Now you have Maven in the system.

    Also we have Maven in the Jenkins Tools also.

    So you can select any maven.

    You can select any JDK version.

    Our job will run if you have given all the settings correctly.

    Dashboard.

    Build.

    So this is where the you know, we started running our build.

    But you see, we can create multiple different, different build jobs for different different projects.

    Also, you can create different build jobs or you can test build jobs to see different tools are working

    or not.

    So go ahead and try all these things.

    So whatever.

    Doing whatever we are doing so far is just you get hang of Jenkins and the build process.

    Watch the lectures again, do the steps again, have a very good practice.

    This is going to get more complicated in coming lectures where we integrate multiple tools and technologies

    with Jenkins Nexus Sonatype Repository Sonarqube Unit Testing, deploying the artifact Containerizing

    Deploying containers to AWS so more and more technologies will get integrated with.

    Jenkins.

    So to get hang of other lectures or this lecture you need, you might need to watch them again and practice

    them again.

    If you master these this section, you will never have problem in understanding CI CD.

    You can use any tools and technology and create your own CI CD based on which project you're working.

    Initially, it might take time, but you will get the flow.

    You will know what you have to do.

    So please be patient.

    Wait some time for these concepts to getting settled in.

    Once you get comfortable with all these things, CI CD will be a piece of cake for you no matter what

    tools and technologies comes later

  4. Assistant

    Lecture: Jenkins First Job Creation

    Introduction

    • Objective: Create a Jenkins build job to fetch source code from GitHub and build the artifact using the MVN install command.

    Steps to Create a Freestyle Job in Jenkins

    1. Create a New Job:

      • Click on "Create Job".
      • Enter a job name (e.g., "build").
      • Choose "Freestyle" project.
      • Add a description (e.g., "Build artifact from V profile source code").
    2. Configure Job Settings:

      • Source Code Management:
        • Use Git to manage source code.
        • Repository URL: https://github.com/coder/profile-project
        • If private, specify credentials.
      • JDK Selection:
        • Select "Oracle JDK 11" from the dropdown. The job supports both JDK 11 and 8.
      • Maven Settings:
        • Use "Invoke top-level Maven targets" plugin.
        • Enter goal "clean install" to instruct Maven to clean the workspace and build the project from scratch.
      • Branch Specification:
        • Use */main for branch specification.
    3. Build Environment and Triggers:

      • Configure as needed (not covered in-depth in this lecture).
    4. Build Execution:

      • Do not use the Shell to execute Maven commands directly; prefer the Maven plugin for configuration flexibility and options.
    5. Post-Build Actions:

      • Optionally, archive artifacts or other post-build processes can be configured.

    Launching the Build

    • Click on "Build Now" to start the build process.
    • Monitor progress through console output. If Jenkins slow or unresponsive, consider upgrading server capacity (e.g., from T2 Micro to T2 Small).

    Managing Jenkins & System Performance

    • If experiencing performance issues, check CPU utilization and consider stopping the Jenkins instance to change instance type if necessary.

    Other Key Points

    • Ensure tools like JDK and Maven are specified correctly.
    • Utilize Jenkins plugins rather than scripting where possible for additional features.
    • Configure credentials for private repositories.
    • Understand workspace management, including cleaning or wiping the workspace to manage storage effectively.

    Troubleshooting and Optimization

    • If a build fails or Jenkins behaves unexpectedly, consider checking logs, adjusting system resources, or reviewing configuration settings.
    • Emphasize the importance of understanding and using various Jenkins settings and plugins to improve the efficiency of build processes.

    Conclusion

    • This lecture provides a foundation in building a basic Jenkins job that demonstrates fetching code and building artifacts.
    • Future topics will include deeper integration with other tools and technologies for comprehensive CI/CD pipelines.

    These notes synthesize the content of the lecture focused primarily on setting up and optimizing a Jenkins build job.