CI Jobs for separated trellis, and tost-onos repos
Use existing ONOS GPG key for maven builds
Change-Id: I29bcf27ae8631b41a4f89ac926258a973626c19a
diff --git a/jjb/defaults.yaml b/jjb/defaults.yaml
index 3e9562a..cc1ed78 100644
--- a/jjb/defaults.yaml
+++ b/jjb/defaults.yaml
@@ -68,3 +68,14 @@
# This portion of the path should be included: `$GOPATH/src/<dest-gopath>/<project>"
# If blank, golang related variables won't be set
dest-gopath: ''
+
+ # JDK distribution to use
+ # Give the version of the JDK to use when building
+ # Parameter is used with `update-java-alternatives --set <jdk-distribution>`
+ jdk-distribution: 'java-11-amazon-corretto'
+
+ # Optionally allow JUnit results to be empty when test framework is set up,
+ # but no tests exist. Default behavior is to fail when test results are
+ # empty. Also will not vote if no test output exists - good for repos where
+ # tests or test output generation may not yet exist.
+ junit-allow-empty-results: false
diff --git a/jjb/repos/tost-onos.yaml b/jjb/repos/tost-onos.yaml
new file mode 100644
index 0000000..9ee0a4c
--- /dev/null
+++ b/jjb/repos/tost-onos.yaml
@@ -0,0 +1,20 @@
+---
+# jobs for 'tost-onos' repo
+
+- project:
+ name: tost-onos
+ project: '{name}'
+
+ jobs:
+ - 'verify-tost-onos-jobs':
+ branch-regexp: '{supported-branches-regexp}'
+
+- job-group:
+ name: 'verify-tost-onos-jobs'
+ jobs:
+ - 'verify-licensed'
+ - 'tag-check':
+ dependency-jobs: 'license-check_tost-onos'
+ - 'make-test':
+ make-test-targets: 'docker-build'
+ junit-allow-empty-results: true
diff --git a/jjb/repos/trellis-control.yaml b/jjb/repos/trellis-control.yaml
new file mode 100644
index 0000000..3ad64c4
--- /dev/null
+++ b/jjb/repos/trellis-control.yaml
@@ -0,0 +1,19 @@
+---
+# jobs for 'trellis-control' repo
+
+- project:
+ name: trellis-control
+ project: '{name}'
+
+ jobs:
+ - 'trellis-control-jobs':
+ branch-regexp: '^(.*)$'
+ junit-allow-empty-results: true
+
+- job-group:
+ name: 'trellis-control-jobs'
+ jobs:
+ - 'verify-licensed'
+ - 'tag-check'
+ - 'maven-test'
+ - 'maven-publish'
diff --git a/jjb/repos/trellis-t3.yaml b/jjb/repos/trellis-t3.yaml
new file mode 100644
index 0000000..03a0b98
--- /dev/null
+++ b/jjb/repos/trellis-t3.yaml
@@ -0,0 +1,19 @@
+---
+# jobs for 'trellis-t3' repo
+
+- project:
+ name: trellis-t3
+ project: '{name}'
+
+ jobs:
+ - 'trellis-t3-jobs':
+ branch-regexp: '^(.*)$'
+ junit-allow-empty-results: true
+
+- job-group:
+ name: 'trellis-t3-jobs'
+ jobs:
+ - 'verify-licensed'
+ - 'tag-check'
+ - 'maven-test'
+ - 'maven-publish'
diff --git a/jjb/shell/tag-check.sh b/jjb/shell/tag-check.sh
index ea66045..fbb1e0c 100755
--- a/jjb/shell/tag-check.sh
+++ b/jjb/shell/tag-check.sh
@@ -22,6 +22,7 @@
VERSIONFILE="" # file path to file containing version number
NEW_VERSION="" # version number found in $VERSIONFILE
+TAG_VERSION="" # version file that might have a leading v to work around go mod funkyness
SEMVER_STRICT=${SEMVER_STRICT:-0} # require semver versions
@@ -38,28 +39,32 @@
then
NEW_VERSION=$(head -n1 "VERSION")
VERSIONFILE="VERSION"
+
+ # If this is a golang project, use funky v-prefixed versions
+ if [ -f "Gopkg.toml" ] || [ -f "go.mod" ]
+ then
+ echo "go-based project found, using v-prefixed version for git tags: v${NEW_VERSION}"
+ TAG_VERSION=v${NEW_VERSION}
+ else
+ TAG_VERSION=${NEW_VERSION}
+ fi
+
elif [ -f "package.json" ]
then
NEW_VERSION=$(python -c 'import json,sys;obj=json.load(sys.stdin); print obj["version"]' < package.json)
+ TAG_VERSION=$NEW_VERSION
VERSIONFILE="package.json"
+ elif [ -f "pom.xml" ]
+ then
+ NEW_VERSION=$(xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' pom.xml)
+ TAG_VERSION=$NEW_VERSION
+ VERSIONFILE="pom.xml"
else
echo "ERROR: No versioning file found!"
exit 1
fi
}
-# check if the version is already a tag in git
-function is_git_tag_duplicated {
- for existing_tag in $(git tag)
- do
- if [ "$NEW_VERSION" = "$existing_tag" ]
- then
- echo "ERROR: Duplicate tag: $existing_tag"
- exit 2
- fi
- done
-}
-
# check if the version is a released version
function check_if_releaseversion {
if [[ "$NEW_VERSION" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]
@@ -77,6 +82,18 @@
fi
}
+# check if the version is already a tag in git
+function is_git_tag_duplicated {
+ for existing_tag in $(git tag)
+ do
+ if [ "$TAG_VERSION" = "$existing_tag" ]
+ then
+ echo "ERROR: Duplicate tag: $existing_tag"
+ exit 2
+ fi
+ done
+}
+
# check if Dockerfiles have a released version as their parent
function dockerfile_parentcheck {
while IFS= read -r -d '' dockerfile
diff --git a/jjb/shell/version-tag.sh b/jjb/shell/version-tag.sh
index 6c7774c..393b3bc 100755
--- a/jjb/shell/version-tag.sh
+++ b/jjb/shell/version-tag.sh
@@ -22,6 +22,7 @@
VERSIONFILE="" # file path to file containing version number
NEW_VERSION="" # version number found in $VERSIONFILE
+TAG_VERSION="" # version file that might have a leading v to work around go mod funkyness
SEMVER_STRICT=${SEMVER_STRICT:-0} # require semver versions
@@ -38,10 +39,26 @@
then
NEW_VERSION=$(head -n1 "VERSION")
VERSIONFILE="VERSION"
+
+ # If this is a golang project, use funky v-prefixed versions
+ if [ -f "Gopkg.toml" ] || [ -f "go.mod" ]
+ then
+ echo "go-based project found, using v-prefixed version for git tags: v${NEW_VERSION}"
+ TAG_VERSION=v${NEW_VERSION}
+ else
+ TAG_VERSION=${NEW_VERSION}
+ fi
+
elif [ -f "package.json" ]
then
NEW_VERSION=$(python -c 'import json,sys;obj=json.load(sys.stdin); print obj["version"]' < package.json)
+ TAG_VERSION=$NEW_VERSION
VERSIONFILE="package.json"
+ elif [ -f "pom.xml" ]
+ then
+ NEW_VERSION=$(xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' pom.xml)
+ TAG_VERSION=$NEW_VERSION
+ VERSIONFILE="pom.xml"
else
echo "ERROR: No versioning file found!"
exit 1
@@ -69,7 +86,7 @@
function is_git_tag_duplicated {
for existing_tag in $(git tag)
do
- if [ "$NEW_VERSION" = "$existing_tag" ]
+ if [ "$TAG_VERSION" = "$existing_tag" ]
then
echo "ERROR: Duplicate tag: $existing_tag"
exit 2
diff --git a/jjb/templates/maven.yaml b/jjb/templates/maven.yaml
new file mode 100644
index 0000000..7d8788a
--- /dev/null
+++ b/jjb/templates/maven.yaml
@@ -0,0 +1,141 @@
+---
+# maven jobs for Java projects
+
+- job-template:
+ id: maven-test
+ name: 'verify_{project}_maven-test{name-extension}'
+ description: |
+ <!-- Managed by Jenkins Job Builder -->
+ Created by {id} job-template from ci-management/jjb/maven.yaml
+
+ node: 'ubuntu16.04-basebuild-1c-2g'
+ project-type: freestyle
+
+ parameters:
+ - string:
+ name: jdkDistro
+ default: '{jdk-distribution}'
+ description: 'Distribution of the JDK to use with update-java-alternatives'
+
+ triggers:
+ - onf-infra-gerrit-trigger-patchset:
+ gerrit-server-name: '{gerrit-server-name}'
+ project-regexp: '{project}'
+ branch-regexp: '{branch-regexp}'
+ file-include-regexp: '{all-files-regexp}'
+ dependency-jobs: '{dependency-jobs}'
+
+ properties:
+ - onf-infra-properties:
+ build-days-to-keep: '{build-days-to-keep}'
+ artifact-num-to-keep: '{artifact-num-to-keep}'
+
+ scm:
+ - lf-infra-gerrit-scm:
+ git-url: '$GIT_URL/$GERRIT_PROJECT'
+ refspec: '$GERRIT_REFSPEC'
+ branch: '$GERRIT_BRANCH'
+ submodule-disable: '{submodule-disable}'
+ submodule-recursive: 'false'
+ submodule-timeout: '{submodule-timeout}'
+ choosing-strategy: gerrit
+ jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+ builders:
+ # Set JDK version
+ - shell: |
+ #!/usr/bin/env bash
+ set -eu -o pipefail
+ echo "Setting JDK Distro to: $jdkDistro"
+ sudo update-java-alternatives -s $jdkDistro
+ echo "Java Version:"
+ java -version
+
+ # run tests and install
+ - maven-target:
+ pom: pom.xml
+ settings: 'release-build-maven-settings'
+ settings-type: cfp
+ goals: '-Pci-verify clean test install'
+
+ publishers:
+ - junit:
+ results: "**/TEST-*.xml"
+ allow-empty-results: '{junit-allow-empty-results}'
+ - cobertura:
+ report-file: "**/*coverage.xml"
+ targets:
+ - files:
+ healthy: 80
+ unhealthy: 0
+ failing: 0
+ - method:
+ healthy: 50
+ unhealthy: 0
+ failing: 0
+
+- job-template:
+ id: maven-publish
+ name: 'maven-publish{name-extension}_{project}'
+ description: |
+ <!-- Managed by Jenkins Job Builder -->
+ Created by {id} job-template from ci-management/jjb/maven.yaml
+
+ node: 'ubuntu16.04-basebuild-1c-2g'
+ project-type: freestyle
+
+ parameters:
+ - string:
+ name: jdkDistro
+ default: '{jdk-distribution}'
+ description: 'Distribution of the JDK to use with update-java-alternatives'
+
+ 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}'
+
+ properties:
+ - onf-infra-properties:
+ build-days-to-keep: '{build-days-to-keep}'
+ artifact-num-to-keep: '{artifact-num-to-keep}'
+
+ scm:
+ - lf-infra-gerrit-scm:
+ git-url: '$GIT_URL/$GERRIT_PROJECT'
+ refspec: '$GERRIT_REFSPEC'
+ branch: '$GERRIT_BRANCH'
+ submodule-disable: '{submodule-disable}'
+ submodule-recursive: 'false'
+ submodule-timeout: '{submodule-timeout}'
+ choosing-strategy: gerrit
+ jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+ builders:
+ # Provide GPG key file
+ - config-file-provider:
+ files:
+ - file-id: 'gpg-key'
+ target: 'jenkins.key'
+ variable: 'GPG_KEY_FILE'
+
+ # Set JDK version
+ - shell: |
+ #!/usr/bin/env bash
+ set -eu -o pipefail
+ echo "Setting JDK Distro to: $jdkDistro"
+ sudo update-java-alternatives -s $jdkDistro
+ echo "Java Version:"
+ java -version
+ echo "Import GPG key"
+ gpg --import jenkins.key
+
+ # make build release and deploy
+ - maven-target:
+ pom: pom.xml
+ settings: 'release-build-maven-settings'
+ settings-type: cfp
+ goals: '-Prelease clean deploy'