You've already forked devops-exercises
Change Jenkins section to CI/CD
CI/CD will include Jenkins and other CI/CD systems. In addition, added a couple of questions on various topics.
This commit is contained in:
26
exercises/cicd/ci_for_open_source_project.md
Normal file
26
exercises/cicd/ci_for_open_source_project.md
Normal file
@@ -0,0 +1,26 @@
|
||||
## CI for Open Source Project
|
||||
|
||||
1. Choose an open source project from Github and fork it
|
||||
2. Create a CI pipeline/workflow for the project you forked
|
||||
3. The CI pipeline/workflow will include anything that is relevant to the project you forked. For example:
|
||||
* If it's a Python project, you will run PEP8
|
||||
* If the project has unit tests directory, you will run these unit tests as part of the CI
|
||||
4. In a separate file, describe what is running as part of the CI and why you chose to include it. You can also describe any thoughts, dilemmas, challenge you had
|
||||
|
||||
### Bonus
|
||||
|
||||
Containerize the app of the project you forked using any container engine you would like (e.g. Docker, Podman).<br>
|
||||
Once you successfully ran the application in a container, submit the Dockerfile to the original project (but be prepared that the maintainer might not need/want that).
|
||||
|
||||
### Suggestions for Projects
|
||||
|
||||
The following is a list of projects without CI (at least at the moment):
|
||||
|
||||
Note: I wrote a script to find these (except the first project on the list, of course) based on some parameters in case you wonder why these projects specifically are listed.
|
||||
|
||||
* [This one](https://github.com/bregman-arie/devops-exercises) - We don't have CI! help! :)
|
||||
* [image retrieval platform](https://github.com/skx6/image_retrieval_platform)
|
||||
* [FollowSpot](https://github.com/jenbrissman/FollowSpot)
|
||||
* [Pyrin](https://github.com/mononobi/pyrin)
|
||||
* [food-detection-yolov5](https://github.com/lannguyen0910/food-detection-yolov5)
|
||||
* [Lifely](https://github.com/sagnik1511/Lifely)
|
||||
14
exercises/cicd/remove_builds.md
Normal file
14
exercises/cicd/remove_builds.md
Normal file
@@ -0,0 +1,14 @@
|
||||
### Jenkins - Remove Jobs
|
||||
|
||||
#### Objective
|
||||
|
||||
Learn how to write a Jenkins script that interacts with builds by removing builds older than X days.
|
||||
|
||||
#### Instructions
|
||||
|
||||
1. Pick up (or create) a job which has builds older than X days
|
||||
2. Write a script to remove only the builds that are older than X days
|
||||
|
||||
#### Hints
|
||||
|
||||
X can be anything. For example, remove builds that are older than 3 days. Just make sure that you don't simply remove all the builds (since that's different from the objective).
|
||||
10
exercises/cicd/remove_jobs.md
Normal file
10
exercises/cicd/remove_jobs.md
Normal file
@@ -0,0 +1,10 @@
|
||||
### Jenkins - Remove Jobs
|
||||
|
||||
#### Objective
|
||||
|
||||
Learn how to write a Jenkins script to remove Jenkins jobs
|
||||
|
||||
#### Instructions
|
||||
|
||||
1. Create three jobs called: test-job, test2-job and prod-job
|
||||
2. Write a script to remove all the jobs that include the string "test"
|
||||
16
exercises/cicd/solutions/remove_builds_solution.groovy
Normal file
16
exercises/cicd/solutions/remove_builds_solution.groovy
Normal file
@@ -0,0 +1,16 @@
|
||||
def removeOldBuilds(buildDirectory, days = 14) {
|
||||
|
||||
def wp = new File("${buildDirectory}")
|
||||
def currentTime = new Date()
|
||||
def backTime = currentTime - days
|
||||
|
||||
wp.list().each { fileName ->
|
||||
folder = new File("${buildDirectory}/${fileName}")
|
||||
if (folder.isDirectory()) {
|
||||
def timeStamp = new Date(folder.lastModified())
|
||||
if (timeStamp.before(backTime)) {
|
||||
folder.delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
6
exercises/cicd/solutions/remove_jobs_solution.groovy
Normal file
6
exercises/cicd/solutions/remove_jobs_solution.groovy
Normal file
@@ -0,0 +1,6 @@
|
||||
def jobs = Jenkins.instance.items.findAll { job -> job.name =~ /"test"/ }
|
||||
|
||||
jobs.each { job ->
|
||||
println job.name
|
||||
//job.delete()
|
||||
}
|
||||
Reference in New Issue
Block a user