## Lab Instructions
### Part 1: clone the devnet repo
```bash
git clone https://github.com/hwdev123/Devnet.git
Part 2: Commit the Sample App to Git
-
Login to GitHub and create a new repository:
- Visit GitHub (opens in a new tab) and log in.
- Click on "New repository" or the "+" icon, then select "New repository."
- Create a repository with the following details:
- Repository name: sample-app
- Description: Explore CI/CD with GitHub and Jenkins
- Public/Private: Private
- Click "Create repository."
-
Configure Git credentials locally in the VM:
git config --global user.name "Your Name" git config --global user.email your@example.com
-
Initialize a directory as the Git repository:
cd labs/devnet-src/jenkins/sample-app/ git init
-
Point Git repository to GitHub repository:
git remote add origin https://github.com/github-username/sample-app.git
-
Stage, commit, and push the sample-app files to the GitHub repository:
git add * git commit -m "Committing sample-app files." git push origin master
Part 3: Modify the Sample App and Push Changes to Git
-
Open the sample-app files:
- Make sure you are in the
~/labs/devnet-src/jenkins/sample-app
directory. - Open
sample_app.py
andsample-app.sh
for editing.
- Make sure you are in the
-
Edit the sample-app files:
- In
sample_app.py
, change the port from 8080 to 5050. - In
sample-app.sh
, change all instances of port 8080 to 5050.
- In
-
Build and verify the sample-app:
bash ./sample-app.sh
-
Push your changes to GitHub:
git add * git commit -m "Changed port from 8080 to 5050." git push origin master
Part 4: Download and Run the Jenkins Docker Image
-
Download the Jenkins Docker image:
docker pull jenkins/jenkins:lts
-
Start the Jenkins Docker container:
docker run --rm -u root -p 8080:8080 -v jenkins-data:/var/jenkins_home -v $(which docker):/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock -v "$HOME":/home --name jenkins_server jenkins/jenkins:lts
-
Verify the Jenkins server is running:
- Copy the admin password displayed in the output.
-
Investigate the levels of abstraction:
- Observe the levels of abstraction in the Docker-inside-Docker (dind) implementation.
Part 5: Configure Jenkins
-
Open a web browser tab:
- Navigate to http://localhost:8080/ (opens in a new tab) and login with the admin password.
-
Install the recommended Jenkins plugins:
- Click "Install suggested plugins" and wait for the installation to finish.
-
Skip creating a new admin user and instance configuration:
- Skip creating an admin user and use the default configuration.
-
Start using Jenkins:
- Click "Start using Jenkins."
Part 6: Use Jenkins to Run a Build of Your App
-
Create a new job:
- Click "Create a job" or "New Item" in the menu.
- Enter the name "BuildAppJob" and choose "Freestyle project."
-
Configure the Jenkins BuildAppJob:
- Set a description.
- In the "Source Code Management" tab, choose Git and provide the repository URL and credentials.
- enter username and for password enter GitHub personal access token
- change the branch to /main
- In the "Build" tab, add a build step with the command to run the build script.
-
Have Jenkins build the app:
- Click "Build Now" and observe the build process.
-
Access the build details:
- Click the build number in the Build History section and view the console output.
Part 7: Use Jenkins to Test a Build
-
Start a new job for testing the sample-app:
- Create a new job named "TestAppJob" with the type "Freestyle project."
-
Configure the Jenkins TestAppJob:
- Add a description and set the build trigger to run after the "BuildAppJob."
-
Write the test script:
- Add a build step with a script to test the sample-app
.
- Run the test job:
- Click "Build Now" for the "TestAppJob" and observe the results.
Part 8: integration of GitHub and Jenkins in automating the build and test processes (unfinished)
- Consider the CI/CD process: