223 lines
7.4 KiB
Groovy
223 lines
7.4 KiB
Groovy
def sourceinfostore = null
|
|
|
|
/* Example expected JSON
|
|
{
|
|
"Sources": [
|
|
{
|
|
"name": "core",
|
|
"gituri": "git@hydra:core-presto/core-presto-embedded-software-subtree.git",
|
|
"revision": "origin/release"
|
|
},
|
|
{
|
|
"name": "dhb-km-1024i",
|
|
"gituri": "git@hydra:dhb-km-1024i-source/dhb-km-1024i-embedded-software-subtree.git",
|
|
"revision": "origin/master"
|
|
},
|
|
{
|
|
"name": "dhb-tt-cf3",
|
|
"gituri": "git@hydra:dhb-tt-cf3-source/dhb-tt-cf3-embedded-software-subtree.git",
|
|
"revision": "origin/master"
|
|
},
|
|
{
|
|
"name": "emb",
|
|
"gituri": "git@hydra:emb-source/emb-source-embedded-software-subtree.git",
|
|
"revision": "origin/master"
|
|
},
|
|
{
|
|
"name": "hmb-fd-hv-sg1024",
|
|
"gituri": "git@hydra:hmb-fd-hv-source/hmb-fd-hv-embedded-software-subtree.git",
|
|
"revision": "origin/master_sg1024"
|
|
},
|
|
{
|
|
"name": "hmb-fd-hv-sg600",
|
|
"gituri": "git@hydra:hmb-fd-hv-source/hmb-fd-hv-embedded-software-subtree.git",
|
|
"revision": "origin/master_sg600"
|
|
},
|
|
{
|
|
"name": "hmb-si-1536",
|
|
"gituri": "git@hydra:hmb-si-1536-source/hmb-si-1536-embedded-software-subtree.git",
|
|
"revision": "origin/master"
|
|
},
|
|
{
|
|
"name": "sm-200",
|
|
"gituri": "git@hydra:sm-200-source/sm-200-source-embedded-software-subtree.git",
|
|
"revision": "origin/master"
|
|
},
|
|
{
|
|
"name": "hmb-xr-5601",
|
|
"gituri": "git@hydra:hmb-xr-5601-source/hmb-xr-5601-embedded-software-subtree.git",
|
|
"revision": "origin/master"
|
|
}
|
|
],
|
|
"Exclude_paths": [
|
|
"core/utility/thirdparty"
|
|
]
|
|
}
|
|
*/
|
|
|
|
def String asJsonText() {
|
|
return writeJSON(returnText: true, json: sourceinfostore, pretty: 1)
|
|
}
|
|
|
|
def boolean exists() {
|
|
return (sourceinfostore != null)
|
|
}
|
|
|
|
def set(String jsontext) {
|
|
sourceinfostore = readJSON(text: jsontext)
|
|
echo "Source info:\n${asJsonText()}"
|
|
}
|
|
|
|
def get() {
|
|
return sourceinfostore
|
|
}
|
|
|
|
def sources() {
|
|
return sourceinfostore['Sources']
|
|
}
|
|
|
|
def excludepaths() {
|
|
return sourceinfostore['Exclude_paths']
|
|
}
|
|
|
|
pipeline {
|
|
agent { label AGENT_LABEL }
|
|
stages {
|
|
stage('Initial setup') {
|
|
steps {
|
|
script {
|
|
meta = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy").startnonbuild(this)
|
|
|
|
set(SOURCE_INFO)
|
|
}
|
|
}
|
|
}
|
|
stage('Checkout dependencies') {
|
|
steps {
|
|
script {
|
|
configurationhelper = autobuilder.configurationhelper()
|
|
|
|
JAVAURL = 'git@hydra:tools/openjdk.git'
|
|
if (isUnix()) {
|
|
JAVABRANCH = 'origin/openjdk-11.0.2_linux-x64_bin'
|
|
} else {
|
|
JAVABRANCH = 'origin/openjdk-11.0.2_windows-x64_bin'
|
|
}
|
|
JAVADIR = "${WORKSPACE}/java"
|
|
configurationhelper.gitCheckoutAndRegister(meta, 'java', JAVAURL, JAVABRANCH, JAVADIR)
|
|
JAVA = "${JAVADIR}/ver/bin"
|
|
if (isUnix()) {
|
|
env.PATH = JAVA + ':' + PATH
|
|
} else {
|
|
env.PATH = JAVA + ';' + PATH
|
|
}
|
|
|
|
PPDURL = 'git@hydra:tools/pmd.git'
|
|
PPDBRANCH = 'origin/master'
|
|
PPDDIR = "${WORKSPACE}/ppd"
|
|
configurationhelper.gitCheckoutAndRegister(meta, 'ppd', PPDURL, PPDBRANCH, PPDDIR)
|
|
PPD = "${PPDDIR}/bin"
|
|
}
|
|
}
|
|
}
|
|
stage("Clean exports") {
|
|
steps {
|
|
script {
|
|
SRC = "${WORKSPACE}/cd"
|
|
STATICANALYSIS = 'staticanalysis'
|
|
cleanfolders = [
|
|
SRC,
|
|
STATICANALYSIS,
|
|
]
|
|
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
|
|
cleaner.clean(cleanfolders)
|
|
}
|
|
}
|
|
}
|
|
stage('Checkout product source') {
|
|
steps {
|
|
script {
|
|
if (SOURCE_OFFSET_PATH) {
|
|
SRC += "/${SOURCE_OFFSET_PATH}"
|
|
}
|
|
for(item in sources()) {
|
|
configurationhelper.gitCheckoutAndRegister(meta,
|
|
item['name'].trim(),
|
|
item['gituri'].trim(),
|
|
item['revision'].trim(),
|
|
"${SRC}/${item['name'].trim()}",
|
|
'',
|
|
0,
|
|
false)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
stage('Static analysis') {
|
|
steps {
|
|
script {
|
|
def PPDFOLDER = "${STATICANALYSIS}/ppd"
|
|
def EXCLUDE_PARAM = ''
|
|
if (excludepaths()) {
|
|
EXCLUDE_PARAM = '--exclude "'
|
|
for (exclude_path in excludepaths()) {
|
|
EXCLUDE_PARAM += "${SRC}/${exclude_path.trim()},"
|
|
}
|
|
EXCLUDE_PARAM += '"'
|
|
}
|
|
if (isUnix()) {
|
|
sh """#!/bin/bash
|
|
set -ev
|
|
|
|
mkdir -p "${PPDFOLDER}"
|
|
export PMD_JAVA_OPTS=-Xmx65536m
|
|
"${PPD}/run.sh" cpd --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > "${PPDFOLDER}/cpd.xml"
|
|
"""
|
|
} else {
|
|
bat """
|
|
mkdir -p "${PPDFOLDER}"
|
|
set PMD_JAVA_OPTS=-Xmx65536m
|
|
"${PPD}/cpd.bat" --minimum-tokens 100 --files "${SRC}" --language cpp --format xml ${EXCLUDE_PARAM} --failOnViolation false > "${PPDFOLDER}/cpd.xml"
|
|
"""
|
|
}
|
|
recordIssues(tools: [
|
|
cpd(pattern: "**/cpd.xml", reportEncoding: 'UTF-8'),
|
|
])
|
|
}
|
|
}
|
|
}
|
|
stage('Classifying publishable artifacts') {
|
|
steps {
|
|
script {
|
|
def publishable = [
|
|
]
|
|
publishutils = load("${autobuilder.commonscripts()}/publishing/utils.groovy")
|
|
publishutils.generatelist(meta, publishable)
|
|
}
|
|
}
|
|
}
|
|
stage('Archiving artifacts') {
|
|
steps {
|
|
script {
|
|
ArrayList<String> itemsForRelease = ["${STATICANALYSIS}/**"]
|
|
def artifactlist = meta.generateartifacts(itemsForRelease)
|
|
archiveArtifacts "${artifactlist}"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
post {
|
|
always {
|
|
echo 'Post-build'
|
|
}
|
|
failure {
|
|
echo 'Failed build'
|
|
}
|
|
unstable {
|
|
echo 'Unstable build'
|
|
}
|
|
success {
|
|
echo 'Succeeded build'
|
|
}
|
|
}
|
|
}
|