With Jenkins set as your CI/CD automation tool, you’ll want to know how to create a new build job for a project.
If you’re considering Jenkins as your go-to CI/CD automation tool, chances are you’re going to want to know how this particular piece of the puzzle functions. Why would you want Jenkins as a part of your workflow? If you use Kubernetes, or another means to deploy and manage containers, then you’ll probably want to include a tool that will help to automate those deployments. Jenkins is one such tool.
Once you have Jenkins up and running (and GitHub support added), what’s next? You need to know how to create a new job. During the process of adding GitHub support, you must create a job in order to connect your GitHub account. But what happens after you’ve created that initial (very likely) test job? It’s time to create a new job. Let’s find out how.
SEE: Hiring kit: Database administrator (TechRepublic Premium)
What you’ll need
The only things you’ll need to make this work are a running instance of Jenkins and a Jenkins admin account. With those at the ready, let’s create a job.
How to create the job
Log in to your Jenkins dashboard. Once on that page (Figure A), you won’t find a button for “Create a job.” Why? Because a job is an item and there are various types of items that can be created.
In order to create a new item, click New Item. Give the new item a name and from the resulting window (Figure B), select from a number of different items (including Freestyle Project, Pipeline, Multi-configuration Project, Folder, GitHub Organization, or Multibranch Pipeline).
If you already have your GitHub account connected to Jenkins and you have your code saved in a repository, click on GitHub Organization.
Note: In order to create a GitHub Organization item, your GitHub repository must already contain buildable projects.
Click OK after you’ve selected GitHub Organization. In the resulting window (Figure C), click the Credentials drop-down and select the GitHub account you want to use.
After selecting the proper credentials, both Save and Apply buttons will appear. Complete the rest of the page and when finished, click Save.
If you’re not ready to create a full GitHub Organization (aka, if your repository doesn’t contain a full buildable project), you might opt for a Freestyle Project item. In this item type (Figure D), you can configure a large number of build aspects, such as:
- Build triggers (such as remote build)
- Build environment (such as deleting the workspace before build starts)
- Post-build actions (such as email notifications, archival of artifacts, and more)
- Source code management (such as Git or Subversion)
How to build the project
Once you’ve created the project, you will be informed there is no workspace yet. In order to access the workspace, you must first build the project. This doesn’t mean the project must be in its completed stage. What this will do is run a pull from the source to add the project to Jenkins. To do this, click the Build Now button (Figure E).
At this point, you are ready to complete the project. You aren’t able to add code from within the Jenkins job, as that is not the purpose of Jenkins. To complete the project, manage your code at the source (such as GitHub), and then re-run the build. At any time, you can click Configure (within the item) to edit the settings of the project. For example, after you’ve uploaded the completed code, you could then set build triggers for the project.
And that’s the gist of creating a new job with Jenkins. If you’re looking for CI/CD automation, this is a great place to start.