sts-sponsors team mailing list archive
-
sts-sponsors team
-
Mailing list archive
-
Message #05739
[Merge] ~maas-committers/maas-ci/+git/maas-ci-config:fix-commit-sha-collection into ~maas-committers/maas-ci/+git/maas-ci-config:master
Jack Lloyd-Walters has proposed merging ~maas-committers/maas-ci/+git/maas-ci-config:fix-commit-sha-collection into ~maas-committers/maas-ci/+git/maas-ci-config:master.
Commit message:
[Systemstest] update where/how jenkins fetches commit sha
Requested reviews:
MAAS Committers (maas-committers)
For more details, see:
https://code.launchpad.net/~maas-committers/maas-ci/+git/maas-ci-config/+merge/438519
--
Your team MAAS Committers is requested to review the proposed merge of ~maas-committers/maas-ci/+git/maas-ci-config:fix-commit-sha-collection into ~maas-committers/maas-ci/+git/maas-ci-config:master.
diff --git a/jenkins/jobs/ansible_playbook.groovy b/jenkins/jobs/ansible_playbook.groovy
index 2c953c0..ce7d330 100644
--- a/jenkins/jobs/ansible_playbook.groovy
+++ b/jenkins/jobs/ansible_playbook.groovy
@@ -1,11 +1,11 @@
-def updateCommitStatus(commit_sha, message, state) {
+def updateCommitStatus(repo, commit_sha, message, state) {
step([
- $class: 'GitHubCommitStatusSetter',
- reposSource: [$class: "ManuallyEnteredRepositorySource", url: ${params.ANSIBLE_REPO}],
+ $class: "GitHubCommitStatusSetter",
+ reposSource: [$class: "ManuallyEnteredRepositorySource", url: repo],
commitShaSource: [$class: "ManuallyEnteredShaSource", sha: commit_sha],
statusResultSource: [
- $class: 'ConditionalStatusResultSource',
- results: [$class: "AnyBuildResult", message: message, state: state]
+ $class: "ConditionalStatusResultSource",
+ results: [[$class: "AnyBuildResult", state: state, message: message]]
]
])
}
@@ -13,14 +13,6 @@ pipeline {
agent {
label 'ci-lab'
}
- parameters {
- string(name: 'GIT_REPO', defaultValue: 'https://git.launchpad.net/~maas-committers/maas-ci/+git/system-tests', description: 'Git repo to pull system tests from')
- string(name: 'GIT_BRANCH', defaultValue: 'master', description: 'Branch in the repo to use')
- string(name: 'ANSIBLE_REPO', defaultValue: 'https://github.com/maas/maas-ansible-playbook.git', description: 'Git repo to pull Ansible playbook from')
- string(name: 'ANSIBLE_BRANCH', defaultValue: 'main', description: 'Branch in the Ansible playbook repo to use')
- string(name: 'PYTEST_ARGS', defaultValue: '--log-cli-level info', description: 'Additional args to pytest')
- string(name: 'CONTAINERS_IMAGE', defaultValue: 'ubuntu:22.04', description: 'LXD image for containers used in tests')
- }
stages {
stage('Checkout') {
steps {
@@ -38,6 +30,15 @@ pipeline {
"""
}
}
+ stage('Fetch commit sha') {
+ steps {
+ script {
+ env.COMMIT_SHA = sh(script: "git ls-remote ${params.ANSIBLE_REPO} ${params.ANSIBLE_BRANCH} | cut -c1-40", returnStdout: true).trim()
+ println "commit: ${env.COMMIT_SHA}"
+ }
+ updateCommitStatus("${params.ANSIBLE_REPO}", "${env.COMMIT_SHA}", "${env.BUILD_URL}", "PENDING")
+ }
+ }
stage('System Tests') {
steps {
writeFile file: 'system-tests/config.yaml', text: """
@@ -69,16 +70,14 @@ pipeline {
lxc delete ansible-host-1 --force || true
lxc delete ansible-host-2 --force || true
"""
- def data = readFile(file: "artifact/system-tests/systemtests.ansible_tests.log")
- env.COMMIT_SHA = data =~ (?<=commit )[0-9a-f]{6,}
}
success {
- mattermostSend (color: 'green', message: "[${env.JOB_NAME} #${env.BUILD_NUMBER}](${env.BUILD_URL}) :success: was successful")
- updateCommitStatus("${env.COMMIT_SHA}", "${env.BUILD_URL}", "SUCCESS");
+ mattermostSend (color: 'green', message: "[${env.JOB_NAME} #${env.BUILD_NUMBER}](${env.BUILD_URL}) [${env.ANSIBLE_BRANCH}](${params.ANSIBLE_REPO}/commit/${env.COMMIT_SHA}) :success: was successful")
+ updateCommitStatus("${params.ANSIBLE_REPO}", "${env.COMMIT_SHA}", "${env.BUILD_URL}", "SUCCESS")
}
failure {
- mattermostSend (color: 'red', message: "[${env.JOB_NAME} #${env.BUILD_NUMBER}](${env.BUILD_URL}) :fire: failed")
- updateCommitStatus("${env.COMMIT_SHA}", "${env.BUILD_URL}", "FAILURE");
+ mattermostSend (color: 'red', message: "[${env.JOB_NAME} #${env.BUILD_NUMBER}](${env.BUILD_URL}) [${env.ANSIBLE_BRANCH}](${params.ANSIBLE_REPO}/commit/${env.COMMIT_SHA}) :fire: failed")
+ updateCommitStatus("${params.ANSIBLE_REPO}", "${env.COMMIT_SHA}", "${env.BUILD_URL}", "FAILURE")
}
}
}
diff --git a/jenkins/jobs/ansible_playbook.yaml b/jenkins/jobs/ansible_playbook.yaml
index 17157ea..1e5dd83 100644
--- a/jenkins/jobs/ansible_playbook.yaml
+++ b/jenkins/jobs/ansible_playbook.yaml
@@ -8,6 +8,31 @@
description: |
Run the Ansible Playbook system tests
project-type: pipeline
+ parameters:
+ - string:
+ name: GIT_REPO
+ description: Git repo to pull system tests from
+ default: https://git.launchpad.net/~maas-committers/maas-ci/+git/system-tests
+ - string:
+ name: GIT_BRANCH
+ description: Branch in the repo to use
+ default: master
+ - string:
+ name: ANSIBLE_REPO
+ description: Git repo to pull Ansible playbook from
+ default: https://github.com/maas/maas-ansible-playbook.git
+ - string:
+ name: ANSIBLE_BRANCH
+ description: Branch in the Ansible playbook repo to use
+ default: main
+ - string:
+ name: PYTEST_ARGS
+ description: Additional args to pytest
+ default: --log-cli-level info
+ - string:
+ name: CONTAINERS_IMAGE
+ description: LXD image for containers used in tests
+ default: ubuntu:22.04
triggers:
- timed: '@daily'
dsl: !include-jinja2: ansible_playbook.groovy
Follow ups