Your question is too abstract and contains multiple questions. I typically don't like answering such questions, but here is a starting point for you. The following script will get you all the Jobs and Builds that Ran during the past 24 Hours.
Jenkins.instance.getAllItems(Job.class).each { jobitem ->
def jobName = jobitem.getFullName()
def jobInfo = Jenkins.instance.getItemByFullName(jobName)
// Current time in Miliseconds
def now = new Date().getTime()
def before24Hours = now - (24 * 60 * 60 * 1000)
println("Now: " + now + " Before24H: " + before24Hours)
jobInfo.getBuilds().byTimestamp(before24Hours, now).each { build ->
if(build.getResult().toString().equals('SUCCESS')) {
println("Job : " + jobName + " || BuildNumber: " + build.getNumber() + " || Timestamp: " + build.getTime())
}
}
}
Remember each Build can have multiple commits, hence multiple users. You can get the commit details with this method.
Start building your pipeline with the above and create SO questions for problems you face while doing it. Don't combine multiple questions into the same question.
Update:
Full Pipeline to include commit details.
pipeline {
agent any
stages {
stage('Report') {
steps {
script {
def jobsToInclude = ['Job1', 'Job2']
generateReport(jobsToInclude)
}
}
}
}
}
def generateReport(def jobs) {
Jenkins.instance.getAllItems(Job.class).each { jobitem ->
def jobName = jobitem.getFullName()
if(jobs.contains(jobName)) {
def jobInfo = Jenkins.instance.getItemByFullName(jobName)
// Current time in Miliseconds
def now = new Date().getTime()
def before24Hours = now - (24 * 60 * 60 * 1000)
jobInfo.getBuilds().byTimestamp(before24Hours, now).each { build ->
if(build.getResult().toString().equals('SUCCESS')) {
println("Job : " + jobName + " || BuildNumber: " + build.getNumber() + " || Timestamp: " + build.getTime())
// Get the commits
build.getChangeSets().each{change ->
change.getItems().each { item ->
println("---" + "COMMITID: " + item.getCommitId() + " || Message: " + item.getMsg() + " || Author: " + item.getAuthorName())
}
}
}
}
}
}
}