← Back to team overview

sts-sponsors team mailing list archive

[Merge] ~maas-committers/maas-ci/+git/maas-ci-config:add-force-retest into ~maas-committers/maas-ci/+git/maas-ci-config:master

 

Jack Lloyd-Walters has proposed merging ~maas-committers/maas-ci/+git/maas-ci-config:add-force-retest into ~maas-committers/maas-ci/+git/maas-ci-config:master.

Commit message:
Add "jenkins: !test" ability to ansible-job-creator, to mimic the capabilities of the launchpad ci

Requested reviews:
  MAAS Committers (maas-committers)

For more details, see:
https://code.launchpad.net/~maas-committers/maas-ci/+git/maas-ci-config/+merge/439088
-- 
Your team MAAS Committers is requested to review the proposed merge of ~maas-committers/maas-ci/+git/maas-ci-config:add-force-retest into ~maas-committers/maas-ci/+git/maas-ci-config:master.
diff --git a/jenkins/jobs/ansible_job_creator.groovy b/jenkins/jobs/ansible_job_creator.groovy
index c80c7d3..25ea0b2 100644
--- a/jenkins/jobs/ansible_job_creator.groovy
+++ b/jenkins/jobs/ansible_job_creator.groovy
@@ -44,6 +44,31 @@ def parseJobs(jsonString) {
                 tested = true
             }
 
+            // Reset the tested status if we have left a comment after a test has been run
+            comment_url = parsed_job["comments_url"]
+            comment_out = sh(script: "curl -s ${comment_url}", returnStdout: true).trim()
+            comments = new JsonSlurper().parseText(comment_out)
+            if (tested && comments.size() > 0) {
+                def latest_status_time = Date.parse("yyyy-MM-dd hh:mm:ss", "2000-01-01 00:00:00")
+                def latest_status = ""
+                for (status in commit_status) {
+                    def status_time = Date.parse("yyyy-MM-dd'T'HH:mm:ss'Z'", status["created_at"])
+                    if (status_time > latest_status_time) {
+                        latest_status_time = status_time
+                        latest_status = status["state"]
+                    }
+                }
+                // if the latest test has been completed, and the comment was left after that
+                if (latest_status != "pending") {
+                    for (comment in comments) {
+                        if (comment["created_at"] > latest_status_time && comment["body"] == "Jenkins: !test") {
+                            force_test = true
+                        }
+                    }
+                }
+            }
+
+
             // add this commit to be tested
             if (correct_repo && !wip && !tested) {
                 job["updated"] = pr_updated

Follow ups