[JAVA] Steps to set up Jenkins on your local Mac, create one job and succeed
Overview
The procedure to set up jenkins on the local mac, execute one job, and succeed is described below.
procedure
Install Java
- Java version check was executed with the following command
java -version
- Since Java was already installed, the Java version was displayed as shown below.
openjdk version "14.0.2" 2020-07-14
OpenJDK Runtime Environment (build 14.0.2+12-46)
OpenJDK 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)
Homebrew installation
- Check the version of Homebrew with the following command
brew -v
- Since Homebrew was already installed, the version of Homebrew was displayed as below.
Homebrew 2.4.13
Homebrew/homebrew-core (git revision b022a; last commit 2020-08-26)
Homebrew/homebrew-cask (git revision 408c61; last commit 2020-08-26)
Jenkins installation
- Execute the following command to install jenkins
brew install jenkins
Start Jenkins
- Execute the following command to start jenkins
brew services start jenkins
Jenkins default settings
- To access the jenkins setup screen, first open the configuration file with the following command and change the port number to an arbitrary number
vim /usr/local/Cellar/jenkins/2.258/homebrew.mxcl.jenkins.plist
- After that, access the following URL and confirm that the setup screen is displayed.
http://localhost:20000/
- You will be asked for a password on the first screen, but I opened the path on that screen and got it. The command used below
vim /Users/owner/.jenkins/secrets/initialAdminPassword
Create a new job
- Created by building a freestyle project with the name
java_compile_and_run
Create java file
public class Main{
public static void main(String[] args){
System.out.println("Hello World");
}
}
Creating a shell script
- Created with the following code
#Move to the hierarchy with the source code
cd /Users/owner/work/study
# Main.Compile java file
javac Main.java
#Program execution
java Main
Run build
- Executed the created job
- The console output screen on success is as follows
Reference site
- https://it-rev-env.com/mac_in_jenkins_install/
- https://qiita.com/shirasaya0201/items/863a05117c934856e532
- https://qiita.com/enuesutea/items/45527625362e5f3cc17b
- https://qiita.com/fftcy-sttkm/items/d6616d7b6f8a4a58dfe4
- https://qiita.com/makoto_kw/items/cbe93d4ebbc35f3b43fd
- https://qiita.com/beliefarrow/items/6862b4a6726fc3b24944
- https://eng-entrance.com/jenkins-use
- https://qiita.com/yuuman/items/622347f86e444b8218b3
- https://techacademy.jp/magazine/17597