Continuous Integration - leortyz/softwareEngineeringResources GitHub Wiki
- Automatically run tests after uploading new code to an existing repository using Jenkins.
- Obtain a report with the results of the tests.
- Eclipse IDE for Java Developers >= 2021β03 Download from Eclipse || Get executable
- Gradle tool for eclipse
- Git
- Jenkins >= 2.222.1 Download
- Ngrok Download
Continuous integration is a software development practice where a new code is joined to an existing code that is hosted in a repository. The union of codes comes with automatic execution of tests to ensure its correct operation[1].
The goal of continuous integration is to quickly detect and locate bugs, so reduce the time to fix and improve the software, and that updates are available as soon as possible.
To carry out this workshop, you must use Jenkins as a continuous integration tool. Jenkins is Open Source and runs as a server on the host machine; In addition, it has numerous plugins that increase its capabilities.
Additionally, you must use Ngrok, which is a tool that allows exposing a local url to a public url.
For this workshop, Jenkins will run locally on your computer, by uploading the changes to our remote repository hosted on Github, it will be able to send a response to our server, so it is necessary to have a public url to expose our local server to the internet. Here Ngrok intervenes that will act as a communication bridge between Github and Jenkins.
- Go to the following https://jenkins.io/download/
- Download Jenkins (LTS o Weekly) for your OS.
- Follow the steps shown in the following tutorial: Windows [2] o ubuntu[3]
- Go to the following https://dashboard.ngrok.com/signup
- Create an account. Github is recommended
- Download the file
4. Unzip the file
//Replace <your authtoken> with the token given in the page
./ngrok authtoken <your authtoken>
- Open the program and enter the following command
Note: The authtoken is in the 2nd item of the ngrok page. - To test the operation, write the following command.
./ngrok http 8080
- Take note of the highlighted URL and do not close the console.
Note: ngrok will give you a random URL every time the command is entered. Do not close.
- Create a Github repository
- Set up your Jenkins connection
- Go to Settings > Webhook > Add Webhook
- In Payload URL, place your url as follow:
<your url>/github-webhook/.
For example: http://e760c763.ngrok.io/github-webhook/
- In Content type, select application/json
- Leave the rest of the options as they are and click on Add WebHook
- Check the console again and verify the connection
- Select option βManage Jenkinsβ > Manage Plugins
- Select the Available tab and search βtest-results-analyzerβ
- Mark the check Install y click βInstall without restartβ
- Select the option βNew Itemβ in the left menu
- Enter a name, select βFreestyle Projectβ and click Ok
- In the tab βGeneralβ, mark Github Project and write your repository url.
- In the tab βSource Code Managementβ, select git and enter the url again.
- In the tab βBuild Triggerβ, select the option βGitHub hook trigger for GITScm pollingβ
- In the tab βBuildβ
a. Select βInvoke Gradle scriptβ
b. Enter data as follow
- In the tab βPost-build Actionsβ, enter data as follow.
- Click Save.
- Clone this repository: ContinuousIntegration
- Open the project with Eclipse and verify the program and the test are running correctly.
- Place the content in the repository created at step 1
- Push to the repository
- Review Jenkins and check a new build is running (lower left corner). The first build always takes more time, wait to the end and get the results.
- When complete successfully, it will be marked in blue next to the build number. If it is marked in red, there are errors.
- From the side menu, select "Test Results Analyzerβ to get charts about the tests performed and save those charts.
After reviewing the code with the development team, a bug was found in one of the methods, although it does not show compilation errors and passes written tests, it is necessary to correct it to avoid further problems in the development process.
What you have to do:
- Correct the error in isLess method in the correct relational operator, it should be only <
- Upload changes to repository
- Review the report obtained in Jenkins (save the graphics)
After review again, the error was corrected, but the Jenkins report indicates that not all tests have been passed successfully.
In addition, it was identified that missing test cases that have not been included and are necessary.
You should:
- Correct the necessary tests
- Add additional tests. There should be 6 tests in total, 3 for each method.
- Upload changes to repository
- Review Jenkins report (save charts)
- Practice report with at least: cover, introduction, development, conclusions and recommendations, and references.
- Answer these questions in the report:
a. What is continuous integration?
b. Why is it important and almost necessary?
c. In what type of projects is it recommended to apply it?
d. What would be the result of not doing the continuous integration of a project?
Note: Do not include the questions, these are only a guide. - In the development of the report, include screens of the practice process. 6 graphs should be about the tests process (pie and bars for each build, the line graph is not necessary)
- Include in the report the url of the repository where you did the practice.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ¦ββββββββ
β Description β Value β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ¬ββββββββ£
β Testing code (in the repository) β 50 β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ¬ββββββββ£
β Practice report β 50 β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ¬ββββββββ£
β Penalty per hour or fraction of delay β -30 β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ¬ββββββββ£
β Penalty for not uploading required deliverables as specified β -30 β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ©ββββββββ