Adds CI CD with deb for external deps
This commit is contained in:
82 files changed
+3547
-3
No files matched your search
+132
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Jenkins Pipeline for building external dependency DEB packages
|
||||
* for air-gapped environment.
|
||||
*
|
||||
* Packages are uploaded to SCM repository:
|
||||
* http://remote-repo.sl.defence-elec.de:8081/repository/external-rpms/general
|
||||
*/
|
||||
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
parameters {
|
||||
choice(
|
||||
name: 'PACKAGE',
|
||||
choices: ['avs', 'arcgis', 'tmsif', 'rti-connext-dds', 'buildingmodels', 'geographiclib', 'schusstafel', 'dtentity'],
|
||||
description: 'Select package to build'
|
||||
)
|
||||
string(
|
||||
name: 'VERSION',
|
||||
defaultValue: '1.0.0',
|
||||
description: 'Package version'
|
||||
)
|
||||
booleanParam(
|
||||
name: 'UPLOAD_TO_SCM',
|
||||
defaultValue: true,
|
||||
description: 'Upload built package to SCM repository'
|
||||
)
|
||||
}
|
||||
|
||||
environment {
|
||||
SCM_REPO = 'http://remote-repo.sl.defence-elec.de:8081/repository/external-rpms/general'
|
||||
DEB_PACKAGE_DIR = "${env.WORKSPACE}/external-dependencies/deb-packages/${params.PACKAGE}"
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
checkout scm
|
||||
}
|
||||
}
|
||||
|
||||
stage('Validate Package Structure') {
|
||||
steps {
|
||||
script {
|
||||
def requiredFiles = [
|
||||
'debian/control',
|
||||
'debian/rules',
|
||||
'debian/changelog',
|
||||
'debian/compat',
|
||||
'debian/source/format'
|
||||
]
|
||||
requiredFiles.each { file ->
|
||||
if (!fileExists("${DEB_PACKAGE_DIR}/${file}")) {
|
||||
error "Missing required file: ${file}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build DEB Package') {
|
||||
steps {
|
||||
dir("${DEB_PACKAGE_DIR}") {
|
||||
sh '''
|
||||
# Install build dependencies
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y debhelper devscripts build-essential
|
||||
|
||||
# Build the package
|
||||
debuild -us -uc -b
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Upload to SCM') {
|
||||
when {
|
||||
expression { return params.UPLOAD_TO_SCM }
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
// Upload to Nexus SCM repository
|
||||
withCredentials([usernamePassword(
|
||||
credentialsId: 'scm-repo-credentials',
|
||||
usernameVariable: 'SCM_USER',
|
||||
passwordVariable: 'SCM_PASS'
|
||||
)]) {
|
||||
sh '''
|
||||
# Find the built .deb file
|
||||
DEB_FILE=$(find ${DEB_PACKAGE_DIR}/.. -name "*.deb" -type f | head -1)
|
||||
|
||||
if [ -z "$DEB_FILE" ]; then
|
||||
echo "No .deb file found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Uploading $DEB_FILE to SCM repository..."
|
||||
|
||||
# Upload to Nexus repository using curl with PUT
|
||||
curl -u "${SCM_USER}:${SCM_PASS}" \
|
||||
--request PUT \
|
||||
--upload-file "$DEB_FILE" \
|
||||
"${SCM_REPO}/$(basename $DEB_FILE)" \
|
||||
--fail \
|
||||
--show-error
|
||||
|
||||
echo "Package uploaded successfully to: ${SCM_REPO}/$(basename $DEB_FILE)"
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Archive Artifacts') {
|
||||
steps {
|
||||
archiveArtifacts artifacts: "${DEB_PACKAGE_DIR}/../*.deb", allowEmptyArchive: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
cleanWs()
|
||||
}
|
||||
success {
|
||||
echo "Package ${params.PACKAGE} version ${params.VERSION} built and uploaded successfully!"
|
||||
}
|
||||
failure {
|
||||
echo "Build failed for package ${params.PACKAGE}"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user