CI jobs for [AETHER-778], [AETHER-779] and [AETHER-782]
- Leverages the name-extension to create new jobs
- Introduces a new pipeline job for tost builds
- Same job is used for post-merge and nightly builds
- Passes the DOCKER_TAG as env variable
- Disables versioning jobs for TOST
The new jobs are currently disabled to avoid any service
disruption during the transition. Will follow another patch
that will disable the old jobs and enable the new ones.
Change-Id: I82e023609693b37d310f735f818c3659c84ccf79
diff --git a/jjb/defaults.yaml b/jjb/defaults.yaml
index b867c9b..fa39327 100644
--- a/jjb/defaults.yaml
+++ b/jjb/defaults.yaml
@@ -57,6 +57,9 @@
# used to rename jobs if required
name-extension: ''
+ # used to disable a job
+ disable-job: false
+
# regexes for branch matching
all-branches-regexp: '.*'
supported-branches-regexp: '.*'
diff --git a/jjb/pipeline/tost-onos-publish.groovy b/jjb/pipeline/tost-onos-publish.groovy
new file mode 100644
index 0000000..a07e782
--- /dev/null
+++ b/jjb/pipeline/tost-onos-publish.groovy
@@ -0,0 +1,105 @@
+// Copyright 2020-present Open Networking Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/* tost-onos-publish pipeline.*/
+pipeline {
+
+ /* executor is determined by JJB */
+ agent {
+ label "${params.buildNode}"
+ }
+
+ /* lighweight version of the docker-publish pipeline. */
+ stages {
+
+ stage('checkout') {
+ steps {
+ checkout([
+ $class: 'GitSCM',
+ userRemoteConfigs: [[ url: "${params.gitUrl}", credentialsId: 'onos-jenkins-ssh', refspec: "$GERRIT_REFSPEC"]],
+ branches: [[ name: "$GERRIT_PATCHSET_REVISION", ]],
+ extensions: [
+ [$class: 'WipeWorkspace'],
+ [$class: 'RelativeTargetDirectory', relativeTargetDir: "$GERRIT_PROJECT"],
+ [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
+ [$class: 'SubmoduleOption', recursiveSubmodules: true],
+ ],
+ ])
+ script {
+ git_tags = sh(script:"cd $projectName; git tag -l --points-at HEAD", returnStdout: true).trim()
+ }
+ }
+ }
+
+ stage('build'){
+ steps {
+ script {
+ sshagent(credentials: ['github-onf-bot-ssh-key']) {
+ withDockerRegistry([credentialsId: 'docker-artifact-push-credentials']) {
+ sh( script: """
+ #!/usr/bin/env bash
+ set -eu -o pipefail
+
+ # checked out in a subdir so the log can be in WORKSPACE
+ cd "$GERRIT_PROJECT"
+
+ # set registry/repository variables
+ export DOCKER_REGISTRY="$dockerRegistry/"
+ export DOCKER_REPOSITORY="$dockerRepo/"
+
+ # Build w/extraEnvironmentVars
+ echo "Building image with following vars $extraEnvironmentVars"
+ $extraEnvironmentVars make docker-build 2>&1 | tee "$WORKSPACE/docker-build.log"
+ """)
+ }
+ }
+ }
+ }
+ }
+
+ stage('push'){
+ steps {
+ script {
+ withDockerRegistry(credentialsId: 'aether-internal-registry', url: "https://${params.dockerRegistry}") {
+ sh( script:"""
+ #!/usr/bin/env bash
+ set -eu -o pipefail
+
+ # checked out in a subdir so the log can be in WORKSPACE
+ cd "$GERRIT_PROJECT"
+
+ # set registry/repository variables
+ export DOCKER_REGISTRY="$dockerRegistry/"
+ export DOCKER_REPOSITORY="$dockerRepo/"
+
+ # Push w/extraEnvironmentVars
+ echo "Pushing image with following vars $extraEnvironmentVars"
+ $extraEnvironmentVars make docker-push 2>&1 | tee "$WORKSPACE/docker-push.log"
+ """)
+ }
+ }
+ }
+ }
+ }
+
+ post {
+ always {
+ archiveArtifacts artifacts: 'docker-*.log', fingerprint: true
+ deleteDir()
+ }
+ failure {
+ step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${params.maintainers}", sendToIndividuals: false])
+ }
+ }
+}
diff --git a/jjb/repos/tost-onos.yaml b/jjb/repos/tost-onos.yaml
index 0cf2184..92a7d58 100644
--- a/jjb/repos/tost-onos.yaml
+++ b/jjb/repos/tost-onos.yaml
@@ -22,23 +22,78 @@
- 'verify-licensed'
- 'tag-check':
dependency-jobs: 'license-check_tost-onos'
+ disable-job: true
- 'private-make-test':
make-test-targets: 'docker-build'
junit-allow-empty-results: true
build-node: '{bigger-build-node}'
+ - 'private-make-test':
+ disable-job: true
+ target: 'master'
+ name-extension: '-{target}'
+ make-test-vars: 'DOCKER_TAG={target}'
+ make-test-targets: 'docker-build'
+ junit-allow-empty-results: true
+ build-node: '{bigger-build-node}'
+ - 'private-make-test':
+ disable-job: true
+ target: 'stable'
+ name-extension: '-{target}'
+ make-test-vars: 'DOCKER_TAG={target}'
+ make-test-targets: 'docker-build'
+ junit-allow-empty-results: true
+ build-node: '{bigger-build-node}'
+ - 'private-make-test':
+ disable-job: true
+ target: 'devel'
+ name-extension: '-{target}'
+ make-test-vars: 'DOCKER_TAG={target}'
+ make-test-targets: 'docker-build'
+ junit-allow-empty-results: true
+ build-node: '{bigger-build-node}'
- job-group:
name: 'publish-tost-onos-jobs'
+
jobs:
- - 'version-tag'
+ - 'version-tag':
+ disable-job: true
- 'private-docker-publish':
docker-repo: 'tost'
docker-registry: 'registry.aetherproject.org'
maintainers: 'charles@opennetworking.org, pier@opennetworking.org'
build-timeout: 30
dependency-jobs: 'version-tag_tost-onos'
+ - 'tost-onos-docker-publish':
+ disable-job: true
+ target: 'master'
+ name-extension: '-{target}'
+ extraEnvironmentVars: 'DOCKER_TAG={target}'
+ docker-repo: 'tost'
+ docker-registry: 'registry.aetherproject.org'
+ maintainers: 'charles@opennetworking.org, pier@opennetworking.org'
+ build-timeout: 30
+ - 'tost-onos-docker-publish':
+ disable-job: true
+ target: 'stable'
+ name-extension: '-{target}'
+ extraEnvironmentVars: 'DOCKER_TAG={target}'
+ docker-repo: 'tost'
+ docker-registry: 'registry.aetherproject.org'
+ maintainers: 'charles@opennetworking.org, pier@opennetworking.org'
+ build-timeout: 30
+ - 'tost-onos-docker-publish':
+ disable-job: true
+ target: 'devel'
+ name-extension: '-{target}'
+ extraEnvironmentVars: 'DOCKER_TAG={target}'
+ docker-repo: 'tost'
+ docker-registry: 'registry.aetherproject.org'
+ maintainers: 'charles@opennetworking.org, pier@opennetworking.org'
+ build-timeout: 30
- job-group:
name: 'release-tost-onos-jobs'
+ # To be used only with trellis-t3 and trellis-control
jobs:
- - 'artifact-release'
\ No newline at end of file
+ - 'artifact-release'
diff --git a/jjb/templates/private-docker-publish.yaml b/jjb/templates/private-docker-publish.yaml
index 2e09d16..454844b 100644
--- a/jjb/templates/private-docker-publish.yaml
+++ b/jjb/templates/private-docker-publish.yaml
@@ -4,6 +4,7 @@
- job-template:
id: private-docker-publish
name: 'private-docker-publish_{project}'
+ disabled: '{disable-job}'
description: |
Created by {id} job-template from ci-management/jjb/private-docker-publish.yaml, script pipeline/docker-publish.groovy
diff --git a/jjb/templates/private-make-test.yaml b/jjb/templates/private-make-test.yaml
index 6860260..a0a26c9 100644
--- a/jjb/templates/private-make-test.yaml
+++ b/jjb/templates/private-make-test.yaml
@@ -4,7 +4,7 @@
- job-template:
id: 'private-make-test'
name: 'private-make-test{name-extension}_{project}'
-
+ disabled: '{disable-job}'
description: |
Created by {id} job-template from ci-management/jjb/templates/private-make-test.yaml<br/>
Runs make with the following test targets - '{make-test-targets}' and with the<br/>
diff --git a/jjb/templates/tost-onos-jobs.yaml b/jjb/templates/tost-onos-jobs.yaml
new file mode 100644
index 0000000..50bbbef
--- /dev/null
+++ b/jjb/templates/tost-onos-jobs.yaml
@@ -0,0 +1,94 @@
+# tost-onos docker image building + aether publishing tasks
+
+- job-template:
+ id: tost-onos-docker-publish
+ name: 'tost-onos-docker-publish{name-extension}'
+ disabled: '{disable-job}'
+ description: |
+ Created by {id} job-template from ci-management/jjb/tost-onos-jobs.yaml, script pipeline/tost-onos-publish.groovy<br/>
+ Runs docker-build with the following env. variables - '{extraEnvironmentVars}' and then publish the image on {docker-registry}/{docker-repo}. <br/>
+ Triggered also nightly. <br/>
+
+ triggers:
+ - onf-infra-gerrit-trigger-merge:
+ gerrit-server-name: '{gerrit-server-name}'
+ project-regexp: '{project}'
+ branch-regexp: '{branch-regexp}'
+ file-include-regexp: '{all-files-regexp}'
+ dependency-jobs: '{dependency-jobs}'
+ - timed: "@midnight"
+
+ properties:
+ - onf-infra-onfstaff-private:
+ - onf-infra-properties:
+ build-days-to-keep: '{build-days-to-keep}'
+ artifact-num-to-keep: '{artifact-num-to-keep}'
+
+ wrappers:
+ - lf-infra-wrappers:
+ build-timeout: '{build-timeout}'
+ jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+ parameters:
+ - string:
+ name: buildNode
+ default: '{bigger-build-node}'
+ description: 'Name of the Jenkins build executor to run the job on'
+
+ - string:
+ name: gitUrl
+ default: '$GIT_URL/$GERRIT_PROJECT'
+ description: 'URL to the git repo'
+
+ - string:
+ name: GERRIT_PATCHSET_REVISION
+ default: 'master'
+ description: 'git ref to build (commit hash or tag)'
+
+ - string:
+ name: GERRIT_REFSPEC
+ default: 'refs/heads/master'
+ description: 'git refSpec to build (refs/changes/)'
+
+ - string:
+ name: GERRIT_PROJECT
+ default: 'tost-onos'
+ description: 'Name of the project in Gerrit'
+
+ - string:
+ name: GERRIT_BRANCH
+ default: 'master'
+ description: 'Branch of the project in Gerrit'
+
+ - string:
+ name: dockerRepo
+ default: '{docker-repo}'
+ description: "Docker repository to push to ('onosproject', etc.)"
+
+ - string:
+ name: dockerRegistry
+ default: '{docker-registry}'
+ description: "Docker registry to push to (blank for DockerHub)"
+
+ # AWS CPU arch names: `x86_64` `arm64` (which don't align to vendor names... *sigh*)
+ - string:
+ name: dockerArchList
+ default: 'x86_64'
+ description: "List of architectures to build containers on, pipe separated (nonfunctional currently)"
+
+ - string:
+ name: maintainers
+ default: '{maintainers}'
+ description: "The person that should be notified if this job fails"
+
+ - string:
+ name: extraEnvironmentVars
+ default: '{extraEnvironmentVars}'
+ description: "Provide extra environment variables to the build"
+
+ project-type: pipeline
+ concurrent: true
+ extraEnvironmentVars: ""
+ sandbox: true
+
+ dsl: !include-raw-escape: ../pipeline/tost-onos-publish.groovy
diff --git a/jjb/templates/versioning.yaml b/jjb/templates/versioning.yaml
index 5c56f33..2affdf2 100644
--- a/jjb/templates/versioning.yaml
+++ b/jjb/templates/versioning.yaml
@@ -25,6 +25,7 @@
Created by {id} job-template from ci-management/jjb/templates/versioning.yaml
Checks for changes to version files, and that they don't duplicate tags
already in the git repo.
+ disabled: '{disable-job}'
triggers:
- onf-infra-gerrit-trigger-patchset:
@@ -73,6 +74,7 @@
Created by {id} job-template from ci-management/jjb/templates/versioning.yaml
When a patch is merged, check if it contains a SemVer released version
file and if so tags the commit in git with that same version.
+ disabled: '{disable-job}'
triggers:
- onf-infra-gerrit-trigger-merge: