Sign in
agent:

List my Jenkins pipelines

There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.

Python script to list Jenkins pipelines using Jenkins API

import requests # Get environment variables jenkins_username = getEnvVar('JENKINS_USERNAME') jenkins_api_token = getEnvVar('JENKINS_API_TOKEN') jenkins_url = getEnvVar('JENKINS_URL') # Jenkins API endpoint to list pipelines url = f'{jenkins_url}/api/json?tree=jobs[name]' # Make the request response = requests.get(url, auth=(jenkins_username, jenkins_api_token)) # Check if the request was successful if response.status_code == 200: data = response.json() pipelines = [job['name'] for job in data.get('jobs', [])] print('Pipelines:', pipelines) else: print('Failed to fetch pipelines:', response.status_code) pipelines = [] # Output the pipelines pipelines
copied