← Back to team overview

sts-sponsors team mailing list archive

Re: [Merge] ~maas-committers/maas-ci/+git/maas-ci-config:jenkins-commit-status into ~maas-committers/maas-ci/+git/maas-ci-config:master

 

Review: Approve

nitpick inline, but let's see how this goes

Diff comments:

> diff --git a/jenkins/jobs/ansible_playbook.groovy b/jenkins/jobs/ansible_playbook.groovy
> new file mode 100644
> index 0000000..2c953c0
> --- /dev/null
> +++ b/jenkins/jobs/ansible_playbook.groovy
> @@ -0,0 +1,84 @@
> +def updateCommitStatus(commit_sha, message, state) {
> +    step([
> +        $class: 'GitHubCommitStatusSetter',
> +        reposSource: [$class: "ManuallyEnteredRepositorySource", url: ${params.ANSIBLE_REPO}],
> +        commitShaSource: [$class: "ManuallyEnteredShaSource", sha: commit_sha],
> +        statusResultSource: [
> +        $class: 'ConditionalStatusResultSource',
> +        results: [$class: "AnyBuildResult", message: message, state: state]
> +        ]
> +    ])
> +}
> +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 {
> +                sh """
> +                rm -rf system-tests
> +                git clone ${params.GIT_REPO} --branch ${params.GIT_BRANCH} --depth 1 system-tests
> +                env -C system-tests git show --no-patch
> +                """
> +            }
> +        }
> +        stage('Setup') {
> +            steps {
> +                sh """
> +                sudo apt-get install -y tox
> +                """
> +            }
> +        }
> +        stage('System Tests') {
> +            steps {
> +                writeFile file: 'system-tests/config.yaml', text: """
> +                proxy:
> +                    http: http://squid.internal:3128
> +                containers-image: ${params.CONTAINERS_IMAGE}
> +                ansible-playbooks:
> +                    git-repo: ${params.ANSIBLE_REPO}
> +                    git-branch: ${params.ANSIBLE_BRANCH}
> +                """
> +                dir("system-tests") {
> +                    sh """
> +                    cat config.yaml
> +                    export http_proxy=http://squid.internal:3128/
> +                    export https_proxy=http://squid.internal:3128/
> +                    tox r -e cog
> +                    tox r -e ansible_tests -- ${params.PYTEST_ARGS}
> +                    """
> +                }
> +            }
> +        }
> +    }
> +    post {
> +        always {
> +            archiveArtifacts artifacts:'system-tests/*.log,system-tests/config.yaml,system-tests/junit*.xml', fingerprint: true
> +            junit allowEmptyResults: true, testResults: 'system-tests/junit*.xml'
> +            sh """
> +                lxc delete ansible-main --force || true
> +                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,}

this is cute, but how about we just have a file explicitly with the COMMIT SHA in it (e.g. system-tests/ansible-commit-sha1.out) or a new command like `tox r -e ansible-tests ansible-commit-sha` ?

> +        }
> +        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");
> +        }
> +        failure {
> +            mattermostSend (color: 'red', message: "[${env.JOB_NAME} #${env.BUILD_NUMBER}](${env.BUILD_URL}) :fire: failed")
> +            updateCommitStatus("${env.COMMIT_SHA}", "${env.BUILD_URL}", "FAILURE");
> +        }
> +    }
> +}


-- 
https://code.launchpad.net/~maas-committers/maas-ci/+git/maas-ci-config/+merge/437623
Your team MAAS Committers is subscribed to branch ~maas-committers/maas-ci/+git/maas-ci-config:master.



References