You can learn about setting up the build and deployment jobs in Jenkins.
About this task
To set up a build and deployment jobs in Jenkins, you must create and configure the
following jobs in Jenkins to automate the various stages for the pipeline:
- Build_Input: Job for building the application.
- Deploy_DEV: Job for deploying the application to the DEV environment.
- Deploy_QA: Job for deploying the application to the QA environment.
- Deploy_PROD: Job for deploying the application to the PROD environment.
Procedure
-
Perform the following steps to create the Build_Input job:
-
Sign in to your Jenkins application with valid login credentials.
-
Click New Item.
-
Type Build_Input in the Enter an item
name field.
-
Select Freestyle project.
-
Click Ok.
The Build_Input job is created and configuration page is displayed.
-
In the General section, select This project is
parametrised check box.
-
Click Add parameter, and then select String
Parameter from the list.
-
Type the name for the String Parameter. For example,
build number.
-
Optional: Type the default value for the parameter in the Default
Value field.
-
Optional: Type the description for the parameter in the Description
field.
-
In the Source Code Management section, select
Git.
-
Type the URL of the GitHub repository in the Repository URL
field. For example, https://github.com/username/reponame.
-
In the Credentials section, click the drop down list, and
then select credentials.
If you are selecting the credentials for the first time, then you must add the
credentials to Jenkins, and then select them from the
Credentials section.
-
In the Branch Specifier field, add the GitHub branch name.
For example */main.
-
In the Build Steps section, click Add build
step, and then select Execute shell from the
list.
-
Type the following command in the Command field:
-
Click Save.
You have created a Build_Input job in Jenkins.
-
Perform the following steps to create the Deploy_DEV job:
-
Sign in to your Jenkins application with valid login credentials.
-
Click New Item.
-
Type Deploy_DEV in the Enter an item
name field.
-
Select Freestyle project.
-
Click Ok.
The Deploy_DEV job is created and configuration page is displayed.
-
In the General section, select This project is
parametrised check box.
-
Click Add parameter, and then select String
Parameter.
-
Type the name for the String Parameter. For example,
build number.
-
Optional: Type the default value for the parameter in the Default
Value field.
-
Optional: Type the description for the parameter in the Description
field.
-
In the Build Steps section, click Add build
step and then select Execute shell from the
list.
-
Type the following command in the Command field:
-
Click Save.
You have created a Deploy_DEV job in Jenkins.
-
Perform the following steps to create the Deploy_QA job:
-
Sign in to your Jenkins application with valid login credentials.
-
Click New Item.
-
Type Deploy_QA in the Enter an item
name field.
-
Select Freestyle project.
-
Click Ok.
The Deploy_QA job is created and configuration page is displayed.
-
In the General section, select This project is
parametrised check box.
-
Click Add parameter, and then select String
Parameter.
-
Type the name for the String Parameter. For example,
build number.
-
Optional: Type the default value for the parameter in the Default
Value field.
-
Optional: Type the description for the parameter in the Description
field.
-
In the Build Steps section, click Add build
step and then select Execute shell from the
list.
-
Type the following command in the Command field:
-
Click Save.
You have created a Deploy_QA job in Jenkins.
-
Perform the following steps to create the Deploy_PROD job:
-
Sign in to your Jenkins application with valid login credentials.
-
Click New Item.
-
Type Deploy_PROD in the Enter an item
name field.
-
Select Freestyle project.
-
Click Ok.
The Deploy_PROD job is created and configuration page is displayed.
-
In the General section, select This project is
parametrised check box.
-
Click Add parameter, and then select String
Parameter.
-
Type the name for the String Parameter. For example,
build number.
-
Optional: Type the default value for the parameter in the Default
Value field.
-
Optional: Type the description for the parameter in the Description
field.
-
In the Build Steps section, click Add build
step and then select Execute shell from the
list.
-
Type the following command in the Command field:
-
Click Save.
You have created a Deploy_PROD job in Jenkins.
In this lesson, you have learned to setting up the build and deployment jobs in
Jenkins.
What to do next
You can learn about adding a Jenkins application in the
pipeline and configuring the build and deploy Jenkins jobs to the different environments in
the pipeline. See Lesson 7: Adding a Jenkins application in the pipeline.