Reputation: 171
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")
Upvotes: 0
Views: 678
Reputation: 3589
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.
Upvotes: 2