X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=Jenkinsfile;h=260f644e5e7d0634116d5f74670387e99b86b371;hb=07c09040ffa590bb60ec706bc29d1edf1611a46f;hp=e30c94bad9d64e9f471611acb070bf09a83fe995;hpb=52de972923dc2a6ecb69ba6557e141067edc0f85;p=test.git diff --git a/Jenkinsfile b/Jenkinsfile index e30c94b..260f644 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,64 +1,30 @@ -def Get_MDG(project) { - // split the project. - def values = project.split('/') - if ( values.size() > 1 ) { - return values[1] - } - // no prefix, likely just the project name then - return project -} - -def project_checkout() { - // checkout the project - git url: "https://osm.etsi.org/gerrit/${GERRIT_PROJECT}" - - sh "git fetch origin ${GERRIT_REFSPEC}" - if (GERRIT_PATCHSET_REVISION.size() > 0 ) { - sh "git checkout -f ${GERRIT_PATCHSET_REVISION}" - } -} +properties([ + parameters([ + string(defaultValue: env.BRANCH_NAME, description: '', name: 'GERRIT_BRANCH'), + string(defaultValue: 'test', 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'), + booleanParam(defaultValue: true, description: '', name: 'BUILD_SYSTEM'), + ]) +]) def devops_checkout() { dir('devops') { - git url: 'https://osm.etsi.org/gerrit/osm/devops' + git url: "${PROJECT_URL_PREFIX}/osm/devops" } } node { - stage('Prepare') { - sh 'env' - devops_checkout() - } - - stage('Checkout') { - project_checkout() - } - - container_name = "${GERRIT_PROJECT}-${GERRIT_BRANCH}" - - mdg = Get_MDG("${GERRIT_PROJECT}") - println("MDG is ${mdg}") - - stage('Docker-Build') { - sh "docker build -t ${container_name} ." - } - - withDockerContainer("${container_name}") { - stage('Docker-Setup') { - sh ''' - groupadd -o -g $(id -g) -r jenkins - useradd -o -u $(id -u) --create-home -r -g jenkins jenkins - ''' - } - stage('Test') { - sh 'devops-stages/stage-test.sh' - } - stage('Build') { - sh 'devops-stages/stage-build.sh' - } - stage('Archive') { - sh 'devops-stages/stage-archive.sh' - archiveArtifacts artifacts: "dists/**,pool/${mdg}/*.deb", fingerprint: true - } - } + checkout scm + devops_checkout() + + ci_stage_2 = load "devops/jenkins/ci-pipelines/ci_stage_2.groovy" + ci_stage_2.ci_pipeline( 'test', + params.PROJECT_URL_PREFIX, + params.GERRIT_PROJECT, + params.GERRIT_BRANCH, + params.GERRIT_REFSPEC, + params.GERRIT_PATCHSET_REVISION, + params.BUILD_SYSTEM) }