Skip to content

Cannot set schema in Airflow UI for Jenkins connection, resulting in connection failure #55351

@sjyangkevin

Description

@sjyangkevin

Apache Airflow Provider(s)

jenkins

Versions of Apache Airflow Providers

apache-airflow-providers-jenkins==4.1.2

Apache Airflow version

3.0.6

Operating System

Ubuntu 22.04.3 LTS

Deployment

Docker-Compose

Deployment details

Follow the Airflow documentation to run Airflow with Docker: https://airflow.apache.org/docs/apache-airflow/stable/howto/docker-compose/index.html

What happened

Cannot find where to set schema in Airflow UI when defining Jenkins connection. Maybe the field is hidden?

Image Image Image

If the schema is not specified, the connection to Jenkins server will fail due to the unset schema being added to the URL as None, as shown in the screenshot below.
Image

@classmethod
def get_ui_field_behaviour(cls) -> dict[str, Any]:
"""Return custom UI field behaviour for Jenkins connection."""
return {
"hidden_fields": ["schema", "extra"],
"relabeling": {},
"placeholders": {
"login": "Login for the Jenkins service you would like to connect to",
"password": "Password for the Jenkins service you would like to connect too",
"host": "Host for your Jenkins server. Should NOT contain scheme (http:// or https://)",
"port": "Specify a port number",
},
}
def __init__(self, conn_id: str = default_conn_name) -> None:
super().__init__()
connection = self.get_connection(conn_id)
self.connection = connection
connection_prefix = "http"
# connection.extra contains info about using https (true) or http (false)
if connection.extra_dejson.get("use_https"):
connection_prefix = "https"
url = f"{connection_prefix}://{connection.host}:{connection.port}/{connection.schema}"
self.log.info("Trying to connect to %s", url)
self.jenkins_server = jenkins.Jenkins(url, connection.login, connection.password)

What you think should happen instead

We should be able to specify schema in the UI, so it will not be rendered as None in the connection string. If the schema is optional. Then, we also should not put it into the connection string if its value is None.

How to reproduce

Run Airflow through the Docker compose deployment, or in breeze development environment. Install Jenkins provider, and attempt to set the connection. The following DAG may be helpful to re-produce the error.

https://github.com/apache/airflow/blob/main/providers/jenkins/tests/system/jenkins/example_jenkins_job_trigger.py

Anything else

also mentioned in #54207

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions