This series is for super beginners who want to practice CI / CD. We hope that you will get a sense of "What is CI / CD?" When introducing the enterprise level and production level. The tools to be used are selected here, so if you want to use another tool, please check accordingly. The general content is as follows.
- Environment construction
-
GitHub
remote and local repository settings --Automatic installation of Jenkins Plugin --Create, execute, and check results of jobs
To understand the usage examples of CI / CD tools, [Introduction to Jenkins Practice](https://www.amazon.co.jp/%E6%94%B9%E8%A8%82%E7%AC%AC3%E7 % 89% 88-Jenkins% E5% AE% 9F% E8% B7% B5% E5% 85% A5% E9% 96% 80-% E2% 80% 95% E2% 80% 95% E3% 83% 93% E3% 83% AB% E3% 83% 89% E3% 83% BB% E3% 83% 86% E3% 82% B9% E3% 83% 88% E3% 83% BB% E3% 83% 87% E3% 83% 97% E3% 83% AD% E3% 82% A4% E3% 82% 92% E8% 87% AA% E5% 8B% 95% E5% 8C% 96% E3% 81% 99% E3% 82% We will use the model project of 8B% E6% 8A% 80% E8% A1% 93-PRESS-plus / dp / 4774189286).
First, register the project data (Create a GitHub account and log in in advance) As shown in the figure below, click the `` `Fork``` button on the upper right at the link destination
Then, `` `
Then get the project data in the local repository
Click <GitHub account> / Jenkins_Practical_Guide_3rd_Edition
on the remote registry and then copy the link pointing to the branch on the remote registry
Execute the following command on terminal
$ pwd
$ mkdir <demo directory> //Create directory for demo development as appropriate
$ cd <demo directory>
$ git clone https://github.com/tem-individual/Jenkins_Practical_Guide_3rd_Edition.git sampleproject
Success if:
$ cd sampleproject
$ ls -a
. .. .git Jenkinsfile LICENSE build.gradle config pom.xml readme.md src
$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = https://github.com/<GitHub account>/Jenkins_Practical_Guide_3rd_Edition.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
In this demo development, install the following 4 plugins
- JaCoCo Plugin
There are two ways to install the Jenkins Plugin
-Install via update site --Download and install by yourself
Note
When performing "Download and install by yourself", it is necessary to check the dependency of the Jenkins Plugin to be installed. In "Install via update site", other Plugins that depend on it will be installed automatically, so basically select the former.
Since the environment allows internet access, the former is used. Click here for the procedure
`Jenkins Management`
in the left pane`Plugin Management`
`in the center pane`Available`
tab selectionAfter returning to the top page, install other plugins as well
Let's actually use Jenkins Various operations other than manual build will be introduced from the next time onwards.
** The implementation flow is as follows **
** Job settings **
"Create a new job"
dashboard> Create a new job` `> Name the Item "Jenkins JOB", select `` `FreeStyle project
and click OK
"VCS settings"
Input as shown in the figure below
Also, if your GitHub project is `privacy```, you will need to enter the Credential (This time, we are forking the
`publish``` project, so no input is required.)
"Build Trigger Settings" Not set this time because it is a manual build
"Build task settings" Enter as shown in the figure below and click "Save"
"Post-build processing settings" Not set this time because it is a manual build
** Run build ** Select `` `Build Now``` as shown below to execute the build. If the build result is successful, it will be ● </ font> * 1 as surrounded by the red frame.
※1 ● </ font>: No problem ● </ font>: Build successful. There is a problem with test results and code analysis ● </ font>: Build failure ● </ font>: Build not executed
When checking build history or specific build information
``
in the left pane
--You can check the list of build history Workspace
, you can check the contents of the project in the directory structure.
--Only the latest changes can be confirmed from `` `Recent Change```
--In addition, you can check who executed it, test results, etc.** Saving the release target ** Finally, set the release target to be placed in a place where you can easily check it.
Select a specific job such as "Jenkins JOB"> `Settings` `>` `Post-build processing`
Select `Save artifacts`
and specify the path
Running the build will create a `` `sampleproject.war``` on the dashboard or host
$ sudo su -
$ cd /var/lib/docker/volumes/jenkins-data/_data/workspace/JenkinsJOB/target
$ ls
checkstyle-cachefile checkstyle-result.xml findbugsXml.xml generated-test-sources maven-archiver sampleproject-1.0.0 surefire-reports
checkstyle-checker.xml classes generated-sources jacoco.exec maven-status sampleproject.war test-classes
Recommended Posts