sts-sponsors team mailing list archive
-
sts-sponsors team
-
Mailing list archive
-
Message #06318
Re: [Merge] ~maas-committers/maas-ci/+git/maas-ci-internal:openapi-github-duplicator into ~maas-committers/maas-ci/+git/maas-ci-internal:main
Diff comments:
> diff --git a/jobs/maas-openapi-duplicator.groovy b/jobs/maas-openapi-duplicator.groovy
> new file mode 100644
> index 0000000..d8a48cd
> --- /dev/null
> +++ b/jobs/maas-openapi-duplicator.groovy
> @@ -0,0 +1,76 @@
> +pipeline {
> + agent {
> + docker {
> + image 'ubuntu:{{ series }}'
> + registryUrl '{{ docker_registry }}'
> + registryCredentialsId '{{ docker_registry_cred }}'
> + label 'maas-tester'
> + args '-u 0:0'
> + reuseNode true
> + }
> + }
> +
> + stages {
> + stage('Prepare') {
> + steps {
> + cleanWs()
> + sh '''
> + if [ ! -z \$http_proxy ]; then
> + echo "Acquire::http::proxy \\"\$http_proxy\\"\\;" > /etc/apt/apt.conf.d/launchpad-ci-proxy
> + echo "Acquire::https::proxy \\"\$http_proxy\\"\\;" >> /etc/apt/apt.conf.d/launchpad-ci-proxy
> + fi
> + export DEBIAN_FRONTEND=noninteractive
> + apt update
> + apt install -y devscripts tox python3-pip
> + '''
> + }
> + }
> + stage('Lint Schema') {
> + steps {
> + withCredentials([file(credentialsId: 'lp-lander-sshkey', variable: 'SSHKEY')]) {
> + withEnv(["GIT_SSH_COMMAND=ssh -i $SSHKEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"]) {
> + lock(resource: "maas-${LP_BRANCH}") {
> + sh '''
> + mkdir -p /run/build
> + cd /run/build
> + git clone --depth 1 --single-branch --branch ${LP_BRANCH} git+ssh://maas-lander@xxxxxxxxxxxxxxxxx/${LP_REPO} maas
> + cd maas
i think cloning and linting are two different steps - let's separate them (and also use builtin scm step to do the git clone?)
> + make lint-oapi
> + '''
> + }
> + }
> + }
> + }
> + }
> + stage('Push Schema') {
> + steps {
> + def schema = readFile(file: "openapi.yaml")
the current working directory here will not have an openapi.yaml AFAICT? (won't it be in the maas directory?)
> + script {
> + sh "git clone ${GH_REPO} oapi_folder"
> + dir("oapi_folder") {
> + def schema_updated = !fileExists("${GH_FILE_LOC}") || schema != readFile(file: "${GH_FILE_LOC}")
> + if (schema_updated) {
> + writeFile(file: "${GH_FILE_LOC}", text: schema)
> + sh """
> + git add ${GH_FILE_LOC}
> + git commit -m "updating openapi schema"
> + git push
> + """
> + }
> + }
> + sh "rm -rf oapi_folder"
> + }
> + }
> + }
> + }
> + post {
> + success {
> + if (schema_updated) {
> + mattermostSend (color: 'green', message: "[${env.JOB_NAME} #${env.BUILD_NUMBER}](${env.BUILD_URL}) :success: updated OpenAPI Schema")
> + }
> + }
> + failure {
> + mattermostSend (color: 'red', message: "[${env.JOB_NAME} #${env.BUILD_NUMBER}](${env.BUILD_URL}) :fire: failed to update OpenAPI Schema")
> + }
> + }
> +}
> \ No newline at end of file
new lines!
> diff --git a/jobs/maas-openapi-duplicator.yaml b/jobs/maas-openapi-duplicator.yaml
> new file mode 100644
> index 0000000..0c02b54
> --- /dev/null
> +++ b/jobs/maas-openapi-duplicator.yaml
> @@ -0,0 +1,30 @@
> +- project:
> + name: update-openapi-schema
> + jobs:
> + - update-openapi-schema
> +
> +- job-template:
> + name: update-openapi-schema
> + triggers:
> + - timed: '@daily'
> + parameters:
> + - string:
> + name: LP_REPO
> + description: 'Target git repository'
> + default: '~maas-committers/maas'
> + - string:
> + name: LP_BRANCH
> + description: 'Target git branch'
> + default: 'master'
> + - string:
> + name: GH_REPO
> + description: 'GitHub repository to push schema to'
> + default: 'https://github.com/maas/maas-openapi-yaml'
> + - string:
> + name: GH_FILE_LOC
> + description: 'Location of file in GitHub repo to push schema to'
> + default: 'openapi.yaml'
> + properties:
> + - build-discarder:
> + artifact-num-to-keep: 10
> + dsl: !include-jinja2: maas-openapi-duplicator.groovy
> \ No newline at end of file
new lines!
--
https://code.launchpad.net/~maas-committers/maas-ci/+git/maas-ci-internal/+merge/438449
Your team MAAS Committers is requested to review the proposed merge of ~maas-committers/maas-ci/+git/maas-ci-internal:openapi-github-duplicator into ~maas-committers/maas-ci/+git/maas-ci-internal:main.
References