Loading sa5-data-models-validation.jenkinsfile 0 → 100644 +79 −0 Original line number Diff line number Diff line pipeline { options { disableConcurrentBuilds() gitLabConnection('Gitlab at Forge') gitlabBuilds(builds: ["Resolve", "Validate"]) } agent any environment { def resolveSucceded = "false" } stages { stage('Resolve') { steps{ sh 'echo Resolve stage' updateGitlabCommitStatus name: 'Resolve', state: 'pending' dir('data-models') { checkout changelog: true, poll: false, scm: [ $class: 'GitSCM', branches: [[name: "origin/${env.gitlabSourceBranch}"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PreBuildMerge', options: [ fastForwardMode: 'FF', mergeRemote: 'origin', mergeStrategy: 'DEFAULT', mergeTarget: "${env.gitlabTargetBranch}"]] ], submoduleCfg: [], userRemoteConfigs: [[ credentialsId: 'f9a9fd70-ea8b-4872-a9d5-d1fb1cf8123e', url: "${env.gitlabSourceRepoSshUrl}" ]] ] } dir('scripts'){ checkout changelog: false, poll: false, scm: [ $class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[ credentialsId: 'f9a9fd70-ea8b-4872-a9d5-d1fb1cf8123e', url: 'git@forge.etsi.org:cti/forge-tools/3gpp-scripts.git']] ] } updateGitlabCommitStatus name: 'Resolve', state: 'success' script { env.resolveSucceded = "true" } } } stage('Validate') { steps{ updateGitlabCommitStatus name: 'Validate', state: 'pending' sh 'echo Validate stage' sh 'bash ./scripts/validate-data-models.sh ./data-models' updateGitlabCommitStatus name: 'Validate', state: 'success' } } stage('Deploy to FTP') { steps{ sh 'echo DEPLOY stage' } } } post { failure { script { if (env.resolveSucceded == "false") { updateGitlabCommitStatus name: 'Resolve', state: 'failed' } } updateGitlabCommitStatus name: 'Validate', state: 'failed' mail to: 'cti_support@etsi.org', subject: "Failed Pipeline: ${currentBuild.fullDisplayName}", body: "Something is wrong with ${env.BUILD_URL}" } } } validate-data-models.sh 0 → 100644 +19 −0 Original line number Diff line number Diff line #!/bin/bash # Copyright ETSI 2020 echo "------ Switching to $1 folder --------" cd $1 echo "------ Content of the folder ------" ls echo "------ Validating all YANG, JSON and XML files ------" # If there are no YANG, JSON or XML files, then simply exit ls | grep -q 'yang\|json\|xml\|xsd' found_data_models=$? if [ ! $found_data_models ] ; then echo "-- No YANG, JSON, XML or XSD files." exit 0 fi exit 1 No newline at end of file Loading
sa5-data-models-validation.jenkinsfile 0 → 100644 +79 −0 Original line number Diff line number Diff line pipeline { options { disableConcurrentBuilds() gitLabConnection('Gitlab at Forge') gitlabBuilds(builds: ["Resolve", "Validate"]) } agent any environment { def resolveSucceded = "false" } stages { stage('Resolve') { steps{ sh 'echo Resolve stage' updateGitlabCommitStatus name: 'Resolve', state: 'pending' dir('data-models') { checkout changelog: true, poll: false, scm: [ $class: 'GitSCM', branches: [[name: "origin/${env.gitlabSourceBranch}"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PreBuildMerge', options: [ fastForwardMode: 'FF', mergeRemote: 'origin', mergeStrategy: 'DEFAULT', mergeTarget: "${env.gitlabTargetBranch}"]] ], submoduleCfg: [], userRemoteConfigs: [[ credentialsId: 'f9a9fd70-ea8b-4872-a9d5-d1fb1cf8123e', url: "${env.gitlabSourceRepoSshUrl}" ]] ] } dir('scripts'){ checkout changelog: false, poll: false, scm: [ $class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[ credentialsId: 'f9a9fd70-ea8b-4872-a9d5-d1fb1cf8123e', url: 'git@forge.etsi.org:cti/forge-tools/3gpp-scripts.git']] ] } updateGitlabCommitStatus name: 'Resolve', state: 'success' script { env.resolveSucceded = "true" } } } stage('Validate') { steps{ updateGitlabCommitStatus name: 'Validate', state: 'pending' sh 'echo Validate stage' sh 'bash ./scripts/validate-data-models.sh ./data-models' updateGitlabCommitStatus name: 'Validate', state: 'success' } } stage('Deploy to FTP') { steps{ sh 'echo DEPLOY stage' } } } post { failure { script { if (env.resolveSucceded == "false") { updateGitlabCommitStatus name: 'Resolve', state: 'failed' } } updateGitlabCommitStatus name: 'Validate', state: 'failed' mail to: 'cti_support@etsi.org', subject: "Failed Pipeline: ${currentBuild.fullDisplayName}", body: "Something is wrong with ${env.BUILD_URL}" } } }
validate-data-models.sh 0 → 100644 +19 −0 Original line number Diff line number Diff line #!/bin/bash # Copyright ETSI 2020 echo "------ Switching to $1 folder --------" cd $1 echo "------ Content of the folder ------" ls echo "------ Validating all YANG, JSON and XML files ------" # If there are no YANG, JSON or XML files, then simply exit ls | grep -q 'yang\|json\|xml\|xsd' found_data_models=$? if [ ! $found_data_models ] ; then echo "-- No YANG, JSON, XML or XSD files." exit 0 fi exit 1 No newline at end of file