Skip to content

Commit

Permalink
Update jenkins lts version to 2.440.1 (#126)
Browse files Browse the repository at this point in the history
Co-authored-by: javierdelapuente <[email protected]>
Co-authored-by: charlie4284 <[email protected]>
  • Loading branch information
3 people authored Mar 25, 2024
1 parent b3c03d1 commit e152d7d
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 54 deletions.
7 changes: 2 additions & 5 deletions .trivyignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ CVE-2024-22257
# Jenkins Plugin Manager CVEs
CVE-2023-5072
GHSA-4jq9-2xhw-jpx7
# Fix hasn't been released upstream
# https://github.com/jenkinsci/jenkins/pull/8971
CVE-2024-23898
CVE-2024-25710
CVE-2024-26308
# https://github.com/jenkinsci/jenkins/pull/8696
# Fixed in 5.3.32
CVE-2024-22243
CVE-2024-22201
CVE-2024-22243
# Fixed in 5.3.33
CVE-2024-22259
# Fixed in 5.7.12
Expand Down
2 changes: 1 addition & 1 deletion jenkins_rock/rockcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ parts:
- default-jre-headless
- git
build-environment:
- JENKINS_VERSION: 2.426.3
- JENKINS_VERSION: 2.440.1
- JENKINS_PLUGIN_MANAGER_VERSION: 2.12.13
override-build: |
mkdir -p ${CRAFT_PART_INSTALL}/{srv/jenkins/,etc/default/jenkins/}
Expand Down
27 changes: 11 additions & 16 deletions src-docs/auth_proxy.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Observer module for Jenkins to auth_proxy integration.

**Global Variables**
---------------
- **AUTH_PROXY_RELATION**
- **JENKINS_SERVICE_NAME**
- **AUTH_PROXY_ALLOWED_ENDPOINTS**
- **AUTH_PROXY_HEADERS**

Expand All @@ -16,12 +18,17 @@ Observer module for Jenkins to auth_proxy integration.
## <kbd>class</kbd> `Observer`
The Jenkins Auth Proxy integration observer.

<a href="../src/auth_proxy.py#L26"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/auth_proxy.py#L27"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>function</kbd> `__init__`

```python
__init__(charm: CharmBase, ingress: IngressPerAppRequirer)
__init__(
charm: CharmBase,
ingress: IngressPerAppRequirer,
jenkins_instance: Jenkins,
state: State
)
```

Initialize the observer and register event handlers.
Expand All @@ -32,6 +39,8 @@ Initialize the observer and register event handlers.

- <b>`charm`</b>: the parent charm to attach the observer to.
- <b>`ingress`</b>: the ingress object from which to extract the necessary settings.
- <b>`jenkins_instance`</b>: the Jenkins instance.
- <b>`state`</b>: the charm state.


---
Expand All @@ -42,18 +51,4 @@ Shortcut for more simple access the model.



---

<a href="../src/auth_proxy.py#L81"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>function</kbd> `has_relation`

```python
has_relation() → bool
```

Check if there's a relation with data for auth proxy.

Returns: True if there's a relation.


22 changes: 20 additions & 2 deletions src-docs/charm.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Charm Jenkins.
## <kbd>class</kbd> `JenkinsK8sOperatorCharm`
Charmed Jenkins.

<a href="../src/charm.py#L41"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/charm.py#L39"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>function</kbd> `__init__`

Expand Down Expand Up @@ -80,7 +80,7 @@ Unit that this execution is responsible for.

---

<a href="../src/charm.py#L114"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/charm.py#L78"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>function</kbd> `calculate_env`

Expand All @@ -95,4 +95,22 @@ Return a dictionary for Jenkins Pebble layer.
**Returns:**
The dictionary mapping of environment variables for the Jenkins service.

---

<a href="../src/charm.py#L175"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>function</kbd> `jenkins_set_storage_config`

```python
jenkins_set_storage_config(event: EventBase) → None
```

Correctly set permissions when storage is attached.



**Args:**

- <b>`event`</b>: The event fired when the permission change is needed.


42 changes: 42 additions & 0 deletions src-docs/pebble.py.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!-- markdownlint-disable -->

<a href="../src/pebble.py#L0"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

# <kbd>module</kbd> `pebble.py`
Pebble functionality.

**Global Variables**
---------------
- **JENKINS_SERVICE_NAME**

---

<a href="../src/pebble.py#L20"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `replan_jenkins`

```python
replan_jenkins(
container: Container,
jenkins_instance: Jenkins,
state: State
) → None
```

Replan the jenkins services.



**Args:**

- <b>`container`</b>: the container for with to replan the services.
- <b>`jenkins_instance`</b>: the Jenkins instance.
- <b>`state`</b>: the charm state.



**Raises:**

- <b>`JenkinsBootstrapError`</b>: if an error occurs while bootstrapping Jenkins.


18 changes: 10 additions & 8 deletions src-docs/state.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Jenkins States.
---------------
- **AGENT_RELATION**
- **DEPRECATED_AGENT_RELATION**
- **AUTH_PROXY_RELATION**
- **JENKINS_SERVICE_NAME**
- **JENKINS_HOME_STORAGE_NAME**

Expand All @@ -31,7 +32,7 @@ Metadata for registering Jenkins Agent.

---

<a href="../src/state.py#L121"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/state.py#L122"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>classmethod</kbd> `from_agent_relation`

Expand All @@ -56,7 +57,7 @@ Instantiate AgentMeta from charm relation databag.

---

<a href="../src/state.py#L102"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/state.py#L103"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>classmethod</kbd> `from_deprecated_agent_relation`

Expand All @@ -81,7 +82,7 @@ Instantiate AgentMeta from charm relation databag.

---

<a href="../src/state.py#L89"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/state.py#L90"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>classmethod</kbd> `numeric_executors`

Expand Down Expand Up @@ -114,7 +115,7 @@ Exception raised when a charm configuration is found to be invalid.

- <b>`msg`</b>: Explanation of the error.

<a href="../src/state.py#L35"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/state.py#L36"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>function</kbd> `__init__`

Expand Down Expand Up @@ -145,7 +146,7 @@ Represents an error with invalid number of units deployed.

- <b>`msg`</b>: Explanation of the error.

<a href="../src/state.py#L67"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/state.py#L68"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>function</kbd> `__init__`

Expand Down Expand Up @@ -176,7 +177,7 @@ Represents an error with invalid data in relation data.

- <b>`msg`</b>: Explanation of the error.

<a href="../src/state.py#L51"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/state.py#L52"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>function</kbd> `__init__`

Expand Down Expand Up @@ -223,7 +224,7 @@ Configuration for accessing Jenkins through proxy.

---

<a href="../src/state.py#L201"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/state.py#L215"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>classmethod</kbd> `from_env`

Expand Down Expand Up @@ -253,13 +254,14 @@ The Jenkins k8s operator charm state.
- <b>`deprecated_agent_relation_meta`</b>: Metadata of all agents from units related through deprecated agent relation.
- <b>`proxy_config`</b>: Proxy configuration to access Jenkins upstream through.
- <b>`plugins`</b>: The list of allowed plugins to install.
- <b>`auth_proxy_integrated`</b>: if an auth proxy integrated has been set.




---

<a href="../src/state.py#L241"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/state.py#L257"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>classmethod</kbd> `from_charm`

Expand Down
18 changes: 7 additions & 11 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,24 +178,20 @@ def app_suffix_fixture():
return "".join(random.choices(string.ascii_lowercase, k=4)) # nosec


@pytest_asyncio.fixture(scope="function", name="jenkins_k8s_agents")
async def jenkins_k8s_agents_fixture(
model: Model, app_suffix: str
) -> AsyncGenerator[Application, None]:
@pytest_asyncio.fixture(scope="module", name="jenkins_k8s_agents")
async def jenkins_k8s_agents_fixture(model: Model):
"""The Jenkins k8s agent."""
agent_app: Application = await model.deploy(
agent: Application = await model.deploy(
"jenkins-agent-k8s",
base="[email protected]",
config={"jenkins_agent_labels": "k8s"},
channel="latest/edge",
application_name=f"jenkins-agent-k8s-{app_suffix}",
)
await model.wait_for_idle(apps=[agent_app.name], status="blocked")
yield agent_app
await model.remove_application(agent_app.name, block_until_done=True)
await model.wait_for_idle(apps=[agent.name], status="blocked")
return agent


@pytest_asyncio.fixture(scope="function", name="k8s_agent_related_app")
@pytest_asyncio.fixture(scope="module", name="k8s_agent_related_app")
async def k8s_agent_related_app_fixture(
jenkins_k8s_agents: Application,
application: Application,
Expand All @@ -207,7 +203,7 @@ async def k8s_agent_related_app_fixture(
await application.model.wait_for_idle(
apps=[application.name, jenkins_k8s_agents.name], wait_for_active=True, check_freq=5
)
yield application
return application


@pytest_asyncio.fixture(scope="function", name="extra_jenkins_k8s_agents")
Expand Down
26 changes: 20 additions & 6 deletions tests/integration/test_auth_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

"""Integration tests for jenkins-k8s-operator with auth_proxy."""

import logging
import re
import time
from typing import Match

import pytest
import requests
Expand All @@ -13,6 +14,10 @@
from playwright.async_api import expect
from playwright.async_api._generated import Page

from .helpers import wait_for

logger = logging.getLogger(__name__)


@pytest.mark.abort_on_fail
@pytest.mark.asyncio
Expand Down Expand Up @@ -56,16 +61,25 @@ async def test_auth_proxy_integration_authorized(
status = await application.model.get_status()
address = status["applications"]["traefik-public"]["public-address"]
jenkins_url = f"https://{address}/{application.model.name}-{application.name}/"

await page.goto(jenkins_url)

expected_url = (
f"https://{address}/{application.model.name}"
"-identity-platform-login-ui-operator/ui/login"
)
expected_url_regex = re.compile(rf"{expected_url}*")

async def is_redirected_to_dex() -> Match[str] | None:
"""Wait until dex properly redirects to correct URL.
Returns:
A match if found, None otherwise.
"""
await page.goto(jenkins_url)
logger.info("Page URL: %s", page.url)
return expected_url_regex.match(page.url)

# Dex might take a bit to be ready
time.sleep(5)
await expect(page).to_have_url(re.compile(rf"{expected_url}*"))
await wait_for(is_redirected_to_dex)
await expect(page).to_have_url(expected_url_regex)

# Choose provider
async with page.expect_navigation():
Expand Down
5 changes: 1 addition & 4 deletions tests/integration/test_jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from juju.unit import Unit

from .helpers import gen_test_job_xml, install_plugins
from .substrings import assert_substrings_not_in_string
from .types_ import UnitWebClient

JENKINS_UID = "2000"
Expand All @@ -31,9 +30,7 @@ async def test_jenkins_update_ui_disabled(
res = jenkins_client.requester.get_url(f"{web_address}/manage")

page_content = str(res.content, encoding="utf-8")
assert_substrings_not_in_string(
("New version of Jenkins", "is available", "download"), page_content
)
assert "New version of Jenkins" not in page_content


@pytest.mark.usefixtures("app_with_restart_time_range", "libfaketime_unit")
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async def test_jenkins_ui_proxy_config(
assert: proxy server host and port exists in configuration value.
"""
res = jenkins_with_proxy_client.requester.get_url(
f"{proxy_jenkins_web_address}/manage/pluginManager/advanced"
f"{proxy_jenkins_web_address}/manage/configure"
)

page_content = str(res.content, encoding="utf-8")
Expand Down

0 comments on commit e152d7d

Please sign in to comment.