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:
abregman
2021-10-31 08:32:18 +02:00
parent 353ae7f60b
commit 046b154ccd
13 changed files with 353 additions and 125 deletions

View 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)

View 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).

View 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"

View 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()
}
}
}
}

View File

@@ -0,0 +1,6 @@
def jobs = Jenkins.instance.items.findAll { job -> job.name =~ /"test"/ }
jobs.each { job ->
println job.name
//job.delete()
}