Merge branch 'develop' into ansible-instance

This commit is contained in:
Marc Mattmüller 2023-09-04 10:42:59 +02:00
commit 225319fe69
4 changed files with 138 additions and 20 deletions

View File

@ -84,6 +84,7 @@ jobs:
credentials('gitCredentials')
}
extensions {
disableRemotePoll()
wipeWorkspace()
}
}

View File

@ -27,7 +27,7 @@ env.HASHSERVER = "${env.HASH_SSTATE_SRV_IP}:8686"
env.YOCTO_REPO_DIR = "nwl"
env.YOCTO_RELEASE = 'kirkstone'
env.CI_IMAGE = "nwl-fitimage"
env.CI_IMAGE = "nwl-ramdisk-minimal"
// Artifactory
@ -118,8 +118,31 @@ def removePreExistingYoctoConfigs(confPath) {
//-----------------------------------------------------------------------------
def gitCheckout(gitUrl, branchTag, repoDir, hasSubmodules) {
println "checking out ${gitUrl} to ${repoDir}..."
def printLatestGitHistory() {
gitHistory = sh(returnStdout: true, script: "git log --pretty=oneline -3")
println "Last 3 git commits:\n-----------------------------\n${gitHistory}"
}
//-----------------------------------------------------------------------------
def printSubmoduleStatus(hasSubmodules = true) {
if(hasSubmodules) {
submoduleStatus = sh(script: "git submodule status", returnStdout: true)
println "${submoduleStatus}"
}
}
//-----------------------------------------------------------------------------
def gitUpdateSubmodulesCheckoutBranch(branchTag, hasSubmodules, doUpdatePackageSrcRevisions) {
def gitCredentials = getGitCredentialID()
def updateSubmodulesCmd = hasSubmodules ? " && git submodule update --init --recursive" : ""
sshagent (credentials: [gitCredentials]) {
sh(script: "git checkout ${branchTag} && git pull --rebase ${updateSubmodulesCmd}")
if(doUpdatePackageSrcRevisions) {
sh(label: "Temporary task - updating source revisions (sub-repositories)",
script: "./scripts/update-source-revisions.sh")
}
}
}
//-----------------------------------------------------------------------------
def cloneGitRepoUnlessExisting(gitUrl, repoDir, hasSubmodules) {
def gitCredentials = getGitCredentialID()
if(!fileExists("./${repoDir}")) {
sshagent (credentials: [gitCredentials]) {
@ -127,21 +150,23 @@ def gitCheckout(gitUrl, branchTag, repoDir, hasSubmodules) {
sh(script: "git clone ${inclSubmodulesOpt} ${gitUrl} ${repoDir}")
}
}
dir("${repoDir}") {
def updateSubmodulesCmd = hasSubmodules ? " && git submodule update --init --recursive" : ""
sshagent (credentials: [gitCredentials]) {
sh(script: "git fetch -ap && git fetch -t")
sh(script: "git checkout ${branchTag} && git pull --rebase ${updateSubmodulesCmd}")
}
//-----------------------------------------------------------------------------
def gitCheckout(gitUrl, branchTag, repoDir, hasSubmodules, doUpdatePackageSrcRevisions = true) {
println "checking out git repository ${gitUrl} to ${repoDir}..."
cloneGitRepoUnlessExisting(gitUrl, repoDir, hasSubmodules)
sh(label: "Temporary task - updating source revisions (sub-repositories)",
script: "./scripts/update-source-revisions.sh")
}
if(hasSubmodules) {
submoduleStatus = sh(script: "git submodule status", returnStdout: true)
println "${submoduleStatus}"
}
gitHistory = sh(returnStdout: true, script: "git log --pretty=oneline -3")
println "Last 3 git commits:\n-----------------------------\n${gitHistory}"
dir("${repoDir}") {
gitUpdateSubmodulesCheckoutBranch(branchTag, hasSubmodules, doUpdatePackageSrcRevisions)
printSubmoduleStatus(hasSubmodules)
printLatestGitHistory()
}
}
//-----------------------------------------------------------------------------
def cleanupRepository(repoDir) {
println "cleanup repository (e.g. temporary source revision updates)..."
dir("${repoDir}") {
sh("git restore .")
}
}
//-----------------------------------------------------------------------------

View File

@ -1,4 +1,6 @@
pipelineJob('nwl') {
def branchToUse = binding.variables.get("SEEDING_BRANCH")
displayName('1. NWL CI Pipeline')
description('CI pipeline for the NetModule Wireless Linux')
authorization {
@ -11,11 +13,20 @@ pipelineJob('nwl') {
daysToKeep(7)
numToKeep(7)
}
properties {
pipelineTriggers {
triggers {
cron {
spec('H H(5-6) * * 1-5')
}
}
}
}
definition {
cpsScm {
scm {
git {
branches('main')
branches(branchToUse)
extensions {
cloneOptions {
depth(1)
@ -33,6 +44,8 @@ pipelineJob('nwl') {
}
pipelineJob('nwl-target') {
def branchToUse = binding.variables.get("SEEDING_BRANCH")
displayName('2. NWL Yocto Build')
description('CI pipeline building a NetModule Wireless Linux Yocto Target')
authorization {
@ -49,7 +62,7 @@ pipelineJob('nwl-target') {
cpsScm {
scm {
git {
branches('main')
branches(branchToUse)
extensions {
cloneOptions {
depth(1)
@ -66,7 +79,45 @@ pipelineJob('nwl-target') {
}
}
pipelineJob('nwl-update-src-rev') {
def branchToUse = binding.variables.get("SEEDING_BRANCH")
displayName('0. Update Source Revisions')
description('CI pipeline updating the source revisions for the NetModule Wireless Linux')
authorization {
permissionAll('anonymous')
}
authenticationToken('buildNwlToken')
logRotator {
artifactDaysToKeep(7)
artifactNumToKeep(7)
daysToKeep(7)
numToKeep(7)
}
definition {
cpsScm {
scm {
git {
branches(branchToUse)
extensions {
cloneOptions {
depth(1)
}
}
remote {
credentials('gitCredentials')
url('ssh://git@bitbucket.gad.local:7999/nm-nsp/nwl-ci.git')
}
}
scriptPath('jobs/Jenkinsfile_UpdateSrcRevisions')
}
}
}
}
pipelineJob('doc') {
def branchToUse = binding.variables.get("SEEDING_BRANCH")
displayName('Documentation')
description('Builds the Documentation of the work concerning NWL CI')
authorization {
@ -86,7 +137,7 @@ pipelineJob('doc') {
cpsScm {
scm {
git {
branches('main')
branches(branchToUse)
extensions {
cloneOptions {
depth(1)

View File

@ -0,0 +1,41 @@
// Loading code requires a NODE context
// But we want the code accessible outside the node Context
// So declare common (object created by the LOAD operation) outside the Node block.
def common
// declarative pipeline
pipeline {
agent any
parameters {
string(name: 'BUILD_BRANCH', defaultValue: 'main', description: 'Enter the branch of the NWL to build (default = main), will skip deployment if not main')
booleanParam(name: 'CLEAN_BUILD', defaultValue: false, description: 'do a clean build, i.e. remove the yocto directory and start from scratch')
}
options {
timeout(time: 1, unit: 'HOURS')
buildDiscarder(
logRotator(numToKeepStr: '10')
)
}
stages {
stage('Prepare') {
steps {
script {
println "ToDo: prepare stage"
}
}
}
stage('Update') {
steps {
script {
println "ToDo: Update stage"
}
}
}
} // stages
}