From: Anil Belur Date: Wed, 15 Feb 2017 03:19:52 +0000 (+1000) Subject: Add packer verify and merge jobs X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=c8a35f918e87a609dea15b749a71a960e50a8497;p=ci-management.git Add packer verify and merge jobs - These jobs have been ported from ODL releng - Jobs are designed to build new images first of every month - Verify runs a packer validation on the templates and verifies the syntax of provision scripts - Merge job is designed to trigger a build only relevent to the change rather than building all images Change-Id: I882fdf9d60a49221e1d9f50809c5fda1d8ebf4fb Signed-off-by: Anil Belur --- diff --git a/jjb/ci-management/ci-management-jobs.yaml b/jjb/ci-management/ci-management-jobs.yaml index 24fa255af..d46f894fd 100644 --- a/jjb/ci-management/ci-management-jobs.yaml +++ b/jjb/ci-management/ci-management-jobs.yaml @@ -3,6 +3,16 @@ jobs: - 'ci-management-verify-jjb' - 'ci-management-merge-jjb' + - 'ci-management-verify-packer' + - 'ci-management-merge-packer-{platforms}-{templates}' + + platforms: + - centos + - ubuntu-14.04 + - ubuntu-16.04 + + templates: + - basebuild project: ci-management branch: master @@ -201,3 +211,150 @@ !include-raw-escape: include-raw-test-nodepool.sh - shell: !include-raw-escape: include-raw-merge-nodepool.sh + + + +- job-template: + name: 'ci-management-verify-packer' + project-type: freestyle + node: ubuntu1404-basebuild-4c-4g + concurrent: true + + properties: + - fdio-infra-properties: + build-days-to-keep: '{build-days-to-keep}' + build-num-to-keep: '{build-num-to-keep}' + + parameters: + - project-parameter: + project: '{project}' + - gerrit-parameter: + branch: '{branch}' + - gerrit-refspec-parameter: + refspec: 'refs/heads/{branch}' + + scm: + - gerrit-trigger-scm: + credentials-id: 'jenkins-gerrit-credentials' + refspec: '$GERRIT_REFSPEC' + branches: + - '$GERRIT_BRANCH' + choosing-strategy: 'gerrit' + + wrappers: + - fdio-infra-wrappers: + build-timeout: '{build-timeout}' + - ssh-agent-credentials: + users: + - 'jenkins-gerrit-credentials' + + triggers: + - timed: 'H H 1 * *' + - gerrit: + server-name: 'Primary' + trigger-on: + - patchset-created-event: + exclude-drafts: 'false' + exclude-trivial-rebase: 'false' + exclude-no-code-change: 'false' + - draft-published-event + - comment-added-contains-event: + comment-contains-value: 'recheck' + - comment-added-contains-event: + comment-contains-value: 'reverify' + projects: + - project-compare-type: 'ANT' + project-pattern: 'ci-management' + branches: + - branch-compare-type: 'ANT' + branch-pattern: '**/master' + file-paths: + - compare-type: ANT + pattern: packer/** + + builders: + - packer-validate: + + publishers: + - archive: + artifacts: 'packer/*.log' + allow-empty: 'true' + only-if-success: 'true' + - fdio-infra-shiplogs: + maven-version: 'mvn33-new' + +- job-template: + name: 'ci-management-merge-packer-{platforms}-{templates}' + project-type: freestyle + node: ubuntu1404-basebuild-4c-4g + concurrent: true + + properties: + - fdio-infra-properties: + build-days-to-keep: '{build-days-to-keep}' + build-num-to-keep: '{build-num-to-keep}' + + parameters: + - project-parameter: + project: '{project}' + - gerrit-parameter: + branch: '{branch}' + - gerrit-refspec-parameter: + refspec: 'refs/heads/{branch}' + + scm: + - gerrit-trigger-scm: + credentials-id: 'jenkins-gerrit-credentials' + refspec: '$GERRIT_REFSPEC' + branches: + - '$GERRIT_BRANCH' + choosing-strategy: 'default' + + wrappers: + - fdio-infra-wrappers: + build-timeout: '{build-timeout}' + - ssh-agent-credentials: + users: + - 'jenkins-gerrit-credentials' + + triggers: + - timed: 'H H 1 * *' + - gerrit: + server-name: 'Primary' + trigger-on: + - change-merged-event + - comment-added-contains-event: + comment-contains-value: 'remerge' + projects: + - project-compare-type: 'ANT' + project-pattern: 'ci-management' + branches: + - branch-compare-type: 'ANT' + branch-pattern: '**/master' + file-paths: + - compare-type: ANT + pattern: 'packer/vars/{platforms}.json' + - compare-type: ANT + pattern: 'packer/templates/{templates}.json' + - compare-type: ANT + pattern: 'packer/provision/{templates}.sh' + - compare-type: ANT + pattern: 'packer/provision/system_reseal.sh' + - compare-type: ANT + pattern: 'packer/provision/rh-user_data.sh' + - compare-type: ANT + pattern: 'packer/provision/baseline.sh' + + builders: + - packer-validate: + - packer-build: + platform: '{platforms}' + template: '{templates}' + + publishers: + - archive: + artifacts: 'packer/*.log' + allow-empty: 'true' + only-if-success: 'true' + - fdio-infra-shiplogs: + maven-version: 'mvn33-new' diff --git a/jjb/global-defaults.yaml b/jjb/global-defaults.yaml index b5aa1009f..81daba436 100644 --- a/jjb/global-defaults.yaml +++ b/jjb/global-defaults.yaml @@ -9,3 +9,6 @@ build-artifact-num-to-keep: 5 # Timeout in minutes build-timeout: 360 + + # fd.io branch defaults + branch: master diff --git a/jjb/global-macros.yaml b/jjb/global-macros.yaml index 2493c2b52..cdecdce39 100644 --- a/jjb/global-macros.yaml +++ b/jjb/global-macros.yaml @@ -337,3 +337,60 @@ variable: 'GLOBAL_SETTINGS_FILE' - file-id: '{settings-file}' variable: 'SETTINGS_FILE' + +- property: + name: fdio-infra-properties + properties: + - build-discarder: + days-to-keep: '{build-days-to-keep}' + num-to-keep: '{build-num-to-keep}' + + +- builder: + name: packer-validate + builders: + - config-file-provider: + files: + - file-id: 'packer-cloud-env' + variable: 'CLOUDENV' + - shell: | + #!/bin/bash + cd packer + varfiles="../packer/vars/*" + templates="../packer/templates/*" + provision="../packer/provision/*.sh" + for v in $varfiles; do + [[ "${v##*/}" =~ ^(cloud-env.*)$ ]] && continue + for t in $templates; do + export PACKER_LOG="yes" && \ + export PACKER_LOG_PATH="packer-validate-${v##*/}-${t##*/}.log" && \ + packer.io validate -var-file=$CLOUDENV \ + -var-file=$v $t + if [ $? -ne 0 ]; then + break + fi + done + done + for p in $provision; do + /bin/bash -n $p > provision-validate-${p##*/}.log 2>&1 + if [ $? -ne 0 ]; then + break + fi + done + + +- builder: + name: packer-build + builders: + - config-file-provider: + files: + - file-id: 'packer-cloud-env' + variable: 'CLOUDENV' + - shell: | + #!/bin/bash + cd packer + export PACKER_LOG="yes" && \ + export PACKER_LOG_PATH="packer-build.log" && \ + packer.io build -var-file=$CLOUDENV \ + -var-file=../packer/vars/{platform}.json \ + ../packer/templates/{template}.json