简体   繁体   中英

Jenkins job url getting build incorrect for JenkinsJobTriggerOperator with Airflow

I am trying to monitor a Jenkins job using Airflow. I followed the instructions mentioned below for:

a. JenkinsJobTriggerOperator

b.Configuring connection in Airflow UI

I am successfully able to make connection from Airflow to Jenkins but not able to submit job and getting error: “requests.exceptionsHTTPError: 404 Client Error:Not Found for url: https://example.com:443/job/Project/job/job/job/TestPipeline/job/job/job/dev/build

After observing closely, I noticed the build url which is getting created by host + port + Jenkins job is incorrect in a particular pattern. "job" keyword is present 3 times, instead of 1 time.

The above incorrect build url looks like: https://example.com:443/job/Project/job/job/job/TestPipeline/job/job/job/dev/build

The expected one should be: https://example.com:443/job/Project/job/TestPipeline/job/dev/build

Airflow code snipped:

with dag:

    trigger_jenkins_job = JenkinsJobTriggerOperator(
        dag=dag,
        task_id='trigger_jenkins_job',
        job_name='Project/job/TestPipeline/dev',
        jenkins_connection_id="Jenkins_test")

Looks like the Jenkins API builds the folder path of the URL by adding /job/ to the job_name supplied by first splitting the job_name by "/" into list and then adding /job/ to each element in that list. See here .

I was able to get the desired URL by using a job_name of "Project/TestPipeline/dev". You do not need to insert /job/ throughout your job_name value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM