📖 Scenario: You are setting up a Jenkins server for your team to automate software builds and deployments. To make Jenkins more powerful and useful, you need to install some essential plugins.
🎯 Goal: Create a list of essential Jenkins plugins as a Python list, add a configuration variable for the minimum required version, filter plugins that meet the version requirement, and finally print the filtered list.
📋 What You'll Learn
Create a Python list named plugins with exact plugin names and versions.
Add a variable min_version with the value 2.0.
Filter the plugins list to include only plugins with version >= min_version.
Print the filtered list of plugin names.
💡 Why This Matters
🌍 Real World
Jenkins administrators often need to manage plugins to keep their automation pipelines stable and secure. Filtering plugins by version helps ensure compatibility.
💼 Career
Knowing how to handle plugin lists and configurations is useful for DevOps engineers managing Jenkins servers in real workplaces.
Progress0 / 4 steps
1
Create the plugins list
Create a Python list called plugins with these exact dictionaries: {'name': 'Git', 'version': 3.7}, {'name': 'Pipeline', 'version': 2.6}, {'name': 'Docker', 'version': 1.9}, {'name': 'Blue Ocean', 'version': 1.24}.
Jenkins
Hint
Use a list of dictionaries with keys 'name' and 'version'.
2
Add minimum version configuration
Add a variable called min_version and set it to 2.0.
Jenkins
Hint
Use a simple variable assignment for min_version.
3
Filter plugins by minimum version
Create a new list called filtered_plugins that includes only plugins from plugins where the version is greater than or equal to min_version. Use a list comprehension.
Jenkins
Hint
Use a list comprehension with a condition on plugin['version'].
4
Print filtered plugin names
Print a list of the name values from filtered_plugins. Use a list comprehension inside the print() function.
Jenkins
Hint
Use print([plugin['name'] for plugin in filtered_plugins]) to show the names.
Practice
(1/5)
1. Which Jenkins plugin is essential for integrating Git repositories?
easy
A. Git plugin
B. Docker plugin
C. Slack Notification plugin
D. Pipeline plugin
Solution
Step 1: Understand plugin purpose
The Git plugin allows Jenkins to connect and pull code from Git repositories.