2 Answers

0 votes
by
Jenkins - Setup Build Jobs

Let's create and run a job in Jenkins for simple HelloWorld in Java.

Step 1: Go to the Jenkins dashboard and click on the New Item.

Jenkins Setup Build Jobs

Step 2: In the next page, enter the item name, and select the 'Freestyle project' option. And click OK. Here, my item name is HelloWorld.

Jenkins Setup Build Jobs

Step 3: When you enter the OK, you will get a configuration page. Enter the details of the project in the Description section.

Jenkins Setup Build Jobs

Step 4: On the Source Code Management section, select the Git option, and specify the Repository URL.

To do that you should have proper github setup on your system. To do the github setup:

First, you have to create a project in java. Here, I created a simple HelloWorld program and saved it to one folder i.e. C:\GitRepo. Compile the HelloWorld.java file.

Jenkins Setup Build Jobs

Now create a project in your GitHub account and give the Repository name. Here my repository name is HelloWorld.

Jenkins Setup Build Jobs

Click on Create repository.

Jenkins Setup Build Jobs

Your repository is created. Copy the repository URL. My repository URL is: https://github.com/Nikitakesharwani9/HelloWorld.git

Open the command prompt in your Windows and go to the path where your java file is created.

Then run the following command.

git init  

git status  

git add .  

git status  

Jenkins Setup Build Jobs

Configure your GitHub account in your system.

git config --global user.email "your@email"  

git config --global user.name "username"  

Jenkins Setup Build Jobs

Commit it and add the repository URL.

git commit -m "added HelloWorld program"  

git remote add origin https://github.com/Nikitakesharwani9/HelloWorld.git  

git push -u origin master  

Jenkins Setup Build Jobs

Now, when you refresh your GitHub account, the helloWorld file will be added in your repository.

Jenkins Setup Build Jobs

Step 5: Add the Repository URL in the Source Code Management section.

Jenkins Setup Build Jobs

You can also use a local repository. And if your GitHub repository is private, Jenkins will first validate your login credentials with GitHub and only then access the source code from your GitHub repository.

Step 6: Now, it is time to build the code. Click on "Add build step" and select the "Execute Windows batch command".

Jenkins Setup Build Jobs

Step 7: Enter the following command to compile the java code.

javac HelloWorld.java  

java HelloWorld  

Jenkins Setup Build Jobs

Step 8: Click Apply and then Save button.

Step 9: Once you saved the configuration, then now can click on Build Now option.

Jenkins Setup Build Jobs

Step 10: After clicking on Build Now, you can see the status of the build on the Build History section.

Jenkins Setup Build Jobs

Once the build is completed, a status of the build will show if the build was successful or not. If the build is failed then it will show in red color. Blue symbol is for success.

Jenkins Setup Build Jobs

Click on the build number #1 in the Build History section to see the details of the build.

Jenkins Setup Build Jobs

Step 11: Click on Console Output from the left side of the screen to see the status of the build you run. It should show the success message.

Jenkins Setup Build Jobs
0 votes
by
Java and Tomcat Setup for Jenkins

Java Setup

Since Jenkins is written in Java. Therefore, Java must be installed on your system. To download and install the Java, go to our previous chapter of this tutorial.

Now, to set up the Java_Home environment variable on Windows click here.

Once the java has been installed properly on your system and Java environment variable has been set, then you can verify it by using the following commands:

C:\ echo %JAVA_HOME%  

  

C:\ javac -version  

  

C:\ java -version  

The following output should come:

Java and Tomcat Setup for Jenkins

Tomcat Setup

Download Tomcat:

The official website to download the tomcat is http://tomcat.apache.org/.

When you click the given link, you will get the home page of the official tomcat website as given below:

Java and Tomcat Setup for Jenkins

Go to the link https://tomcat.apache.org/download-90.cgi to download the latest version of tomcat.

Java and Tomcat Setup for Jenkins

Go to the "Binary Distributions" section and download the file according to your platform. Here I am using 64-bit Windows zip for my 64-bit Windows operating system.

Unzip the contents of the downloaded zip file.

Jenkins and Tomcat Setup

Copy the downloaded Jenkins.war file (downloaded from the previous section) and copy it to the webapps folder of the tomcat directory.

Java and Tomcat Setup for Jenkins

Now open the command prompt. From the command prompt, browse to the directory where the tomcat is located. Then, go to the bin directory of this tomcat folder and run the startup.bat file.

C:\apache-tomcat-9.0.21\bin>startup.bat  

When you run the above command then following output will come:

Java and Tomcat Setup for Jenkins

And two more windows will open. i.e., "Tomcat" window and "Windows Security Alert" window. Click on Allow access button in Windows Security Alert Window.

Java and Tomcat Setup for Jenkins

Java and Tomcat Setup for Jenkins

Once the processing is completed, the following line will come in the output of the Tomcat Window:

INFO [hudson initialization thread] hudson.TcpSlaveAgentListener.<init> JNLP slave agent listener started on TCP port 61779  

Now, open the browser and go the link: http://localhost:8080/jenkins. The following page will open:

Java and Tomcat Setup for Jenkins

The setup of Jenkins with Tomcat is successfully done.

Related questions

0 votes
asked Sep 8, 2019 in Jenkins by ivor2019
0 votes
asked Sep 8, 2019 in Jenkins by ivor2019
...