limitations under the License.
*/
+def DEFAULT_MODULE_NAME = 'common'
+
pipeline {
- agent none
- parameters {
- string(defaultValue: env.GERRIT_BRANCH, description: '', name: 'GERRIT_BRANCH')
- string(defaultValue: 'osm/common', description: '', name: 'GERRIT_PROJECT')
- string(defaultValue: env.GERRIT_REFSPEC, description: '', name: 'GERRIT_REFSPEC')
- string(defaultValue: env.GERRIT_PATCHSET_REVISION, description: '', name: 'GERRIT_PATCHSET_REVISION')
- string(defaultValue: 'https://osm.etsi.org/gerrit', description: '', name: 'PROJECT_URL_PREFIX')
+ agent { label 'pool' }
+ options { disableConcurrentBuilds() }
+ parameters {
+ // Core Gerrit / multibranch inputs
+ string(name: 'GERRIT_BRANCH', defaultValue: env.BRANCH_NAME ?: 'master', description: '')
+ string(name: 'GERRIT_PROJECT', defaultValue: 'osm/common', description: '')
+ string(name: 'GERRIT_REFSPEC', defaultValue: env.GERRIT_REFSPEC ?: '', description: '')
+ string(name: 'GERRIT_PATCHSET_REVISION', defaultValue: env.GERRIT_PATCHSET_REVISION ?: '', description: '')
+ string(name: 'PROJECT_URL_PREFIX', defaultValue: 'https://osm.etsi.org/gerrit', description: '')
+ string(name: 'DOCKER_ARGS', defaultValue: '', description: 'Extra docker args for docker run')
+
+ // E2E test parameters
+ string(name: 'OPENSTACK_BASE_IMAGE', defaultValue: 'ubuntu22.04', description: '')
+ string(name: 'OPENSTACK_OSM_FLAVOR', defaultValue: 'osm.sanity', description: '')
+
+ booleanParam(name: 'DO_INSTALL', defaultValue: true, description: '')
+ booleanParam(name: 'DO_ROBOT', defaultValue: true, description: '')
+ string(name: 'MODULE_NAME', defaultValue: 'common', description: 'Name of the module under test')
+
+ booleanParam(name: 'SAVE_CONTAINER_ON_FAIL', defaultValue: false, description: '')
+ booleanParam(name: 'SAVE_CONTAINER_ON_PASS', defaultValue: false, description: '')
+ }
+ environment {
+ MDG = "${params.GERRIT_PROJECT?.contains('/') ? params.GERRIT_PROJECT.split('/')[1] : params.GERRIT_PROJECT}"
+ CONTAINER_NAME = "${params.GERRIT_PROJECT}-${params.GERRIT_BRANCH}".toLowerCase()
+ TEST_IMAGE = 'overdrive3000/tox-osm:v1.6'
+ DOCKER_REGISTRY = 'osm.etsi.org:5050/devops/cicd/'
+ }
+ stages {
+ stage('Prepare') { steps { sh 'env' } }
+
+ stage('Checkout') {
+ steps {
+ checkout scm
+ script {
+ sh "git fetch --tags"
+ if (params.GERRIT_REFSPEC?.trim()) { sh "git fetch origin ${params.GERRIT_REFSPEC}" }
+ if (params.GERRIT_PATCHSET_REVISION?.trim()) { sh "git checkout -f ${params.GERRIT_PATCHSET_REVISION}" }
+ sh "sudo git clean -dfx || git clean -dfx"
+ }
+ }
+ }
+
+ stage('Clone devops (central)') {
+ steps {
+ dir('devops') {
+ sh "git init ."
+ sh "git remote remove origin || true"
+ sh "git remote add origin ${params.PROJECT_URL_PREFIX}/osm/devops"
+ sh "git fetch --depth=1 origin ${params.GERRIT_BRANCH}"
+ sh "git checkout -f FETCH_HEAD"
+ }
+ }
+ }
+
+ stage('License Scan') {
+ steps {
+ script {
+ def isMergeJob = env.JOB_NAME?.contains('merge')
+ if (!isMergeJob) { sh 'devops/tools/license_scan.sh' } else { echo 'skip the scan for merge' }
+ }
+ }
+ }
+
+ stage('Prepare Test Image') {
+ steps {
+ script {
+ // Use shared test image from registry; no local build needed
+ sh "docker pull ${env.TEST_IMAGE} || true"
+ }
+ }
}
- stages {
- stage('TEST') {
- agent { label 'system' }
- steps {
- echo "HELLO"
- }
+
+ stage('Tests') {
+ steps {
+ script {
+ def UID = sh(returnStdout: true, script: 'id -u').trim()
+ def GID = sh(returnStdout: true, script: 'id -g').trim()
+ def common = "-v ${env.WORKSPACE}:/tests -e UID=${UID} -e GID=${GID} " + (params.DOCKER_ARGS ?: '')
+
+ stage('Linting Tests') {
+ sh """
+ docker run --rm ${common} \
+ ${env.TEST_IMAGE} \
+ /tests/devops-stages/stage-lint.sh
+ """
+ }
+
+ stage('Unit Tests') {
+ sh """
+ docker run --rm ${common} \
+ ${env.TEST_IMAGE} \
+ /tests/devops-stages/stage-test.sh
+ """
+ if (fileExists('coverage.xml')) { cobertura coberturaReportFile: 'coverage.xml' }
+ if (fileExists('nosetests.xml')) { junit 'nosetests.xml' }
+ }
+
+ stage('Changelog') {
+ sh 'mkdir -p changelog'
+ sh """
+ docker run --rm ${common} \
+ ${env.TEST_IMAGE} \
+ /bin/sh -lc 'devops/tools/generatechangelog-pipeline.sh > /tests/changelog/changelog-${MDG}.html'
+ """
+ }
}
+ }
}
-}
+ }
+ post {
+ always {
+ // cleanWs()
+ deleteDir()
+ }
+ }
+}
\ No newline at end of file