Merge commit '9c69d262a6df9ab41e9ab02d2c9a552d5fa31369'
This commit is contained in:
commit
0afffb4ea2
4 changed files with 141 additions and 11 deletions
|
|
@ -1,16 +1,21 @@
|
|||
// Assume that WORKSPACE environment variable is set
|
||||
|
||||
autobuildroot = "${WORKSPACE}/autobuild"
|
||||
autobuildroot = 'autobuild'
|
||||
commonscriptsroot = "${autobuildroot}/Common_scripts"
|
||||
metafolderscript = null
|
||||
|
||||
def conditionalclean(doclean = "${CLEAN_WORKSPACE}" == "true") {
|
||||
if (doclean) {
|
||||
if (doclean) {
|
||||
echo "Cleaning workspace"
|
||||
// Save any script files that were loaded into the workspace at first and are required after cleaning the workspace
|
||||
stash allowEmpty: true, includes: 'autobuild/**', name: 'Clean workspace stash', useDefaultExcludes: false
|
||||
def stashname = 'Clean workspace stash'
|
||||
stash(allowEmpty: true,
|
||||
includes: "${autobuildroot}/**,${autobuildroot}/.git/**",
|
||||
name: stashname,
|
||||
useDefaultExcludes: false
|
||||
)
|
||||
cleanWs()
|
||||
unstash name: 'Clean workspace stash'
|
||||
unstash name: stashname
|
||||
}
|
||||
else {
|
||||
echo "Not cleaning workspace"
|
||||
|
|
|
|||
77
copy/all.groovy
Normal file
77
copy/all.groovy
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
pipeline {
|
||||
agent { label "${AGENT_LABEL}" }
|
||||
stages {
|
||||
stage('Initial setup') {
|
||||
steps {
|
||||
script {
|
||||
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Clean exports') {
|
||||
steps {
|
||||
script {
|
||||
IMPORTS = 'imports'
|
||||
cleanfolders = [
|
||||
IMPORTS,
|
||||
]
|
||||
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
|
||||
cleaner.clean(cleanfolders)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Import source artifacts') {
|
||||
steps {
|
||||
script {
|
||||
importer = load("${autobuilder.commonscripts()}/import/importer.groovy")
|
||||
importer.artifactimport(meta, SOURCE_ARTIFACT_LOCATION, SOURCE_ARTIFACT_BUILD_JOB, SOURCE_ARTIFACT_BUILD_SELECTOR, SOURCE_ARTIFACT_RELEASE_REPO, SOURCE_ARTIFACT_RELEASE_REVISION, IMPORTS)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Copy source artifacts') {
|
||||
steps {
|
||||
script {
|
||||
dir(IMPORTS) {
|
||||
fileOperations([
|
||||
fileCopyOperation(excludes: '',
|
||||
flattenFiles: false,
|
||||
includes: '**/*',
|
||||
targetLocation: WORKSPACE)
|
||||
])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Archiving artifacts') {
|
||||
steps {
|
||||
script {
|
||||
def includes = '**/*'
|
||||
def excludes = "${IMPORTS}/*"
|
||||
echo "Archiving artifacts: Includes: ${includes} Excludes: ${excludes}"
|
||||
// This does not work: archiveArtifacts artifacts: includes, excludes: excludes
|
||||
// so
|
||||
cleanfolders = [
|
||||
IMPORTS,
|
||||
'autobuild',
|
||||
]
|
||||
cleaner.clean(cleanfolders)
|
||||
archiveArtifacts artifacts: includes
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo 'Post-build'
|
||||
}
|
||||
failure {
|
||||
echo 'Failed build'
|
||||
}
|
||||
unstable {
|
||||
echo 'Unstable build'
|
||||
}
|
||||
success {
|
||||
echo 'Succeeded build'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,6 +9,9 @@ class ImportOptions {
|
|||
String m_excludes // Exclude files/paths/folders that match the exclude filter
|
||||
boolean m_fingerprint // Do Jenkins fingerprinting on imported artifacts
|
||||
boolean m_nested // Import all child artifacts too (identified in the related meta info
|
||||
boolean m_flatten // Flatten files and folders imported
|
||||
boolean m_includemetainfilter // Make sure meta is also included in filter
|
||||
boolean m_clean // Clean import folder before obtaining artifacts
|
||||
boolean m_appendtoparentmeta // Append to parent meta
|
||||
String m_sourceselect // Where are the artifacts coming from
|
||||
|
||||
|
|
@ -25,6 +28,9 @@ class ImportOptions {
|
|||
String excludes = '',
|
||||
boolean fingerprint = false,
|
||||
boolean nested = false,
|
||||
boolean flatten = false,
|
||||
boolean includemetainfilter = true,
|
||||
boolean clean = true,
|
||||
appendtoparentmeta = true) {
|
||||
m_script = script
|
||||
m_sourceselect = sourceselect.trim()
|
||||
|
|
@ -33,6 +39,9 @@ class ImportOptions {
|
|||
m_excludes = excludes.trim()
|
||||
m_fingerprint = fingerprint
|
||||
m_nested = nested
|
||||
m_flatten = flatten
|
||||
m_includemetainfilter = includemetainfilter
|
||||
m_clean = clean
|
||||
m_appendtoparentmeta = appendtoparentmeta
|
||||
}
|
||||
|
||||
|
|
@ -51,7 +60,7 @@ class ImportOptions {
|
|||
}
|
||||
}
|
||||
|
||||
void setincrementversionnumber(boolean incrementversionnumber) {
|
||||
void setincrementversionnumber(boolean incrementversionnumber = true) {
|
||||
m_incrementversionnumber = incrementversionnumber
|
||||
}
|
||||
|
||||
|
|
@ -63,14 +72,26 @@ class ImportOptions {
|
|||
m_excludes = excludes.trim()
|
||||
}
|
||||
|
||||
void setfingerprint(boolean fingerprint) {
|
||||
void setfingerprint(boolean fingerprint = true) {
|
||||
m_fingerprint = fingerprint
|
||||
}
|
||||
|
||||
void setnested(boolean nested) {
|
||||
void setnested(boolean nested = true) {
|
||||
m_nested = nested
|
||||
}
|
||||
|
||||
void flattenimports(boolean flatten = true) {
|
||||
m_flatten = flatten
|
||||
}
|
||||
|
||||
void includemetainfilter(boolean includemetainfilter = true) {
|
||||
m_includemetainfilter = includemetainfilter
|
||||
}
|
||||
|
||||
void clean(boolean clean = true) {
|
||||
m_clean = clean
|
||||
}
|
||||
|
||||
void setappendtoparentmeta(boolean appendtoparentmeta) {
|
||||
m_appendtoparentmeta = appendtoparentmeta
|
||||
}
|
||||
|
|
@ -98,14 +119,36 @@ ImportOptions getNewImportOptions() {
|
|||
return new ImportOptions(this)
|
||||
}
|
||||
|
||||
def formFilter(ImportOptions importoptions) {
|
||||
def String filter = importoptions.m_filter
|
||||
if (filter != '') {
|
||||
if (importoptions.m_includemetainfilter) {
|
||||
filter = 'meta/**,' + filter
|
||||
}
|
||||
}
|
||||
echo "Import options filter is: ${filter}"
|
||||
return filter
|
||||
}
|
||||
|
||||
def conditionalClean(ImportOptions importoptions, String destpath) {
|
||||
if (importoptions.m_clean) {
|
||||
echo "Cleaning ${destpath}"
|
||||
dir(destpath) {
|
||||
deleteDir()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def artifactimportfrombuildjob(meta, importoptions, String destpath) {
|
||||
if (importoptions.m_sourceselect != 'Jenkins job artifact') {
|
||||
error("Import options settings have not been set for: Jenkins job artifact")
|
||||
return
|
||||
}
|
||||
|
||||
conditionalClean(importoptions, destpath)
|
||||
|
||||
copyArtifacts(
|
||||
filter: importoptions.m_filter,
|
||||
filter: formFilter(importoptions),
|
||||
excludes: importoptions.m_excludes,
|
||||
fingerprintArtifacts: importoptions.m_fingerprint,
|
||||
projectName: importoptions.m_jobname,
|
||||
|
|
@ -113,6 +156,7 @@ def artifactimportfrombuildjob(meta, importoptions, String destpath) {
|
|||
$class: 'ParameterizedBuildSelector',
|
||||
parameterName: importoptions.m_buildnumberorselector
|
||||
],
|
||||
flatten: importoptions.m_flatten,
|
||||
target: destpath
|
||||
)
|
||||
def importedmeta = meta.importrelated(importoptions.m_appendtoparentmeta, destpath)
|
||||
|
|
@ -138,7 +182,9 @@ def hierarchyartifactimportfromrepo(meta, importoptions, String destpath) {
|
|||
def rootrevision = importoptions.m_revision
|
||||
echo "Cloning root release repo: ${rooturl}, revision: ${rootrevision} at folder: ${destpath}"
|
||||
|
||||
def ArrayList<String> sparseitemlist = gh.convertSparseItemsString(importoptions.m_filter)
|
||||
conditionalClean(importoptions, destpath)
|
||||
|
||||
def ArrayList<String> sparseitemlist = gh.convertSparseItemsString(formFilter(importoptions))
|
||||
gh.gitCheckoutAlt(rooturl, rootrevision, destpath, "", 1, true, sparseitemlist)
|
||||
|
||||
def importedmeta = meta.importrelated(importoptions.m_appendtoparentmeta, destpath, rooturl, rootrevision, gh.getGitInfo(destpath))
|
||||
|
|
@ -178,11 +224,13 @@ def artifactimportfromrepo(meta, importoptions, String destpath) {
|
|||
return
|
||||
}
|
||||
|
||||
conditionalClean(importoptions, destpath)
|
||||
|
||||
def rooturl = importoptions.m_repo
|
||||
def rootrevision = importoptions.m_revision
|
||||
echo "Cloning release repo: ${rooturl}, revision: ${rootrevision} at folder: ${destpath}"
|
||||
|
||||
def ArrayList<String> sparseitemlist = gh.convertSparseItemsString(importoptions.m_filter)
|
||||
def ArrayList<String> sparseitemlist = gh.convertSparseItemsString(formFilter(importoptions))
|
||||
gh.gitCheckoutAlt(rooturl, rootrevision, destpath, "", 1, true, sparseitemlist)
|
||||
|
||||
def importedmeta = meta.importrelated(importoptions.m_appendtoparentmeta, destpath, rooturl, rootrevision, gh.getGitInfo(destpath))
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
def substitute(String filepath, String pattern, String subst) {
|
||||
def substitute(String filepath, pattern, String subst) {
|
||||
fileText = readFile(file: filepath, encoding: 'UTF-8')
|
||||
def converted = fileText.replaceAll(pattern, subst)
|
||||
writeFile(file: filepath, text: converted, encoding: 'UTF-8')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue