From f3f204ba73a962283f2eb57c17375968230ad800 Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Mon, 26 Jan 2026 10:24:45 +0100 Subject: [PATCH] Update Jenkinsfile.new to remove test image build and use registry image for devops tests Change-Id: I8d49f41656793d0dc31039ba16dfdfa08cb837a3 Signed-off-by: garciadeblas --- Jenkinsfile.new | 61 ++++------------------------- devops-stages/stage-test.sh | 8 ++-- tools/generatechangelog-pipeline.sh | 13 ++++++ 3 files changed, 25 insertions(+), 57 deletions(-) diff --git a/Jenkinsfile.new b/Jenkinsfile.new index 3f7a36e8..856945a8 100644 --- a/Jenkinsfile.new +++ b/Jenkinsfile.new @@ -17,7 +17,7 @@ def DEFAULT_MODULE_NAME = 'devops' pipeline { agent { label 'pool' } - options { disableConcurrentBuilds() } + // options { disableConcurrentBuilds() } parameters { // Core Gerrit / multibranch inputs string(name: 'GERRIT_BRANCH', defaultValue: env.BRANCH_NAME ?: 'master', description: '') @@ -44,7 +44,7 @@ pipeline { 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' + TEST_IMAGE = 'opensourcemano/devops:19.0' DOCKER_REGISTRY = 'osm.etsi.org:5050/devops/cicd/' } stages { @@ -75,7 +75,7 @@ pipeline { steps { script { // Use shared test image from registry; no local build needed - sh "docker pull ${env.TEST_IMAGE} || true" + sh "docker pull ${env.DOCKER_REGISTRY}${env.TEST_IMAGE} || true" } } } @@ -90,7 +90,7 @@ pipeline { stage('Helm Tests') { sh """ docker run --rm ${common} \ - ${env.TEST_IMAGE} \ + ${env.DOCKER_REGISTRY}${env.TEST_IMAGE} \ /tests/devops-stages/stage-test.sh """ if (fileExists('coverage.xml')) { cobertura coberturaReportFile: 'coverage.xml' } @@ -101,61 +101,14 @@ pipeline { 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' + ${env.DOCKER_REGISTRY}${env.TEST_IMAGE} \ + /bin/sh -lc 'cd /tests; tools/generatechangelog-pipeline.sh > changelog/changelog-${MDG}.html' """ } } } } - stage('Build & Push Image') { - when { expression { return params.DO_DOCKERPUSH } } - steps { - script { - def moduleName = (env.MDG ?: DEFAULT_MODULE_NAME).toLowerCase() - - if (!params.GERRIT_BRANCH) { - error 'GERRIT_BRANCH is required to tag the Docker image' - } - def sanitizedBranchName = params.GERRIT_BRANCH - .toLowerCase() - .replaceAll('[^a-z0-9._-]', '-') - def baseTagPrefix = "osm-${sanitizedBranchName}" - def buildNumber = env.BUILD_NUMBER ?: '0' - def isMergeJob = env.JOB_NAME?.contains('merge') - // Remove promotion logic from this stage - def moduleTags = [] - if (isMergeJob) { - moduleTags << "${baseTagPrefix}-merge" - } else { - moduleTags << "${baseTagPrefix}-patchset-${buildNumber}" - } - - def imageName = params.IMAGENAME ?: "opensourcemano/${moduleName}" - def primaryLocalImage = "${imageName}:${moduleTags[0]}" - - withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'gitlab-registry', - usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) { - sh """ - docker build -f Dockerfile -t ${primaryLocalImage} . - """ - sh "docker login ${env.DOCKER_REGISTRY.split('/')[0]} -u ${USERNAME} -p ${PASSWORD}" - // Push build-scope tag(s) only. Promotion happens after tests. - moduleTags.each { tag -> - def localImage = "${imageName}:${tag}" - def remoteImage = "${env.DOCKER_REGISTRY}${imageName}:${tag}" - sh "docker tag ${localImage} ${remoteImage}" - sh "docker push ${remoteImage}" - } - // Stash the built image id for later promotion without rebuild - env.BUILT_IMAGE = primaryLocalImage - env.BUILT_TAG = moduleTags[0] - } - } - } - } - stage('E2E Test (robot)') { when { expression { return params.DO_ROBOT && !env.JOB_NAME.contains('merge') } } steps { @@ -168,7 +121,7 @@ pipeline { string(name: 'OPENSTACK_BASE_IMAGE', value: params.OPENSTACK_BASE_IMAGE), string(name: 'OPENSTACK_OSM_FLAVOR', value: params.OPENSTACK_OSM_FLAVOR), string(name: 'MODULE_NAME', value: params.MODULE_NAME ?: 'devops'), - string(name: 'CONTAINER_NAME', value: env.BUILT_TAG), + string(name: 'CONTAINER_NAME', value: "not-used-from-devops-pipeline"), booleanParam(name: 'DO_ROBOT', value: params.DO_ROBOT), booleanParam(name: 'DO_INSTALL', value: params.DO_INSTALL), booleanParam(name: 'SAVE_CONTAINER_ON_FAIL', value: params.SAVE_CONTAINER_ON_FAIL), diff --git a/devops-stages/stage-test.sh b/devops-stages/stage-test.sh index c48f693f..72f39ca9 100755 --- a/devops-stages/stage-test.sh +++ b/devops-stages/stage-test.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Copyright 2021 Canonical Ltd. # Copyright ETSI # @@ -16,11 +16,13 @@ set -eu +HERE=$(dirname "$(readlink --canonicalize "$BASH_SOURCE")") + # Download helm chart dependencies -helm dependency update installers/helm/osm +helm dependency update ${HERE}/../installers/helm/osm # Execute linting test for OSM helm chart -helm lint installers/helm/osm +helm lint ${HERE}/../installers/helm/osm # Execute datree test for OSM helm chart # helm datree test installers/helm/osm --verbose diff --git a/tools/generatechangelog-pipeline.sh b/tools/generatechangelog-pipeline.sh index e4aae94f..0c9c8210 100755 --- a/tools/generatechangelog-pipeline.sh +++ b/tools/generatechangelog-pipeline.sh @@ -1,4 +1,17 @@ #!/bin/bash +# +# 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. +# REPO_NAME=$(basename $(git config --get remote.origin.url) | cut -d'.' -f1) git pull --tags origin master &> /dev/null -- 2.25.1