Skip to content

Instantly share code, notes, and snippets.

@apua
Last active January 14, 2025 09:20
Show Gist options
  • Save apua/8d3dcf76b11d7cd8bd865c8df4388337 to your computer and use it in GitHub Desktop.
Save apua/8d3dcf76b11d7cd8bd865c8df4388337 to your computer and use it in GitHub Desktop.
List queued Jenkins jobs
// vim: set filetype=groovy:
pipeline {
agent any
stages { stage('Hello') { steps { script {
// `Jenkins` comes from `jenkins.model.Jenkins`.
Jenkins.get().queue.items.findAll { it.task instanceof org.jenkinsci.plugins.workflow.support.steps.ExecutorStepExecution.PlaceholderTask } .each { println("${it.task.runId} ${it.task.label}") }
}}}}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment