Skip to content
Snippets Groups Projects
Commit e15b72a5 authored by Martin Christoph Hierholzer's avatar Martin Christoph Hierholzer
Browse files

remove echo() and refactoring to reduce the number of steps - this should make...

remove echo() and refactoring to reduce the number of steps - this should make the logs easier to read
parent 949bb7b0
No related branches found
No related tags found
No related merge requests found
......@@ -61,8 +61,7 @@ def transformIntoStep(String libraryName, ArrayList<String> dependencyList, Stri
find /export > /export.list.before
make install
find /export > /export.list.after
"""
sh """
cd "$WORKSPACE"
diff /export.list.before /export.list.after | grep "^> " | sed -e 's/^> //' > export.list.installed
mv /scratch/artefact.list /scratch/dependencies.${JOB_NAME}.list
echo /scratch/dependencies.${JOB_NAME}.list >> export.list.installed
......
......@@ -61,9 +61,7 @@ def transformIntoStep(String buildName) {
sed -i CONFIG -e 's|^EPICS[[:space:]]*=.*\$|EPICS = '/export/epics'|'
mkdir -p /scratch
echo "DOOCS_epics" > /scratch/dependencies.${JOB_NAME}.list
"""
sh """
sudo -u msk_jenkins tar zcf install-${JOB_NAME}-${label}-${buildType}.tgz /export /scratch
sudo -u msk_jenkins tar zcf "$WORKSPACE/install-${JOB_NAME}-${label}-${buildType}.tgz" /export /scratch
"""
archiveArtifacts artifacts: "install-${JOB_NAME}-${label}-${buildType}.tgz", onlyIfSuccessful: false
}
......
......@@ -43,11 +43,11 @@ def transformIntoStep(String buildName) {
def dockerArgs = "-u 0 --device=/dev/mtcadummys0 --device=/dev/mtcadummys1 --device=/dev/mtcadummys2 --device=/dev/mtcadummys3 --device=/dev/llrfdummys4 --device=/dev/noioctldummys5 --device=/dev/pcieunidummys6 -v /var/run/lock/mtcadummy:/var/run/lock/mtcadummy"
docker.image("builder:${label}").inside(dockerArgs) {
script {
sh '''
sh """
VERSION=3.14.12.6
sudo -E -u msk_jenkins wget https://epics.anl.gov/download/base/baseR${VERSION}.tar.gz
sudo -u msk_jenkins tar xf baseR${VERSION}.tar.gz
cd base-${VERSION}
sudo -E -u msk_jenkins wget https://epics.anl.gov/download/base/baseR\${VERSION}.tar.gz
sudo -u msk_jenkins tar xf baseR\${VERSION}.tar.gz
cd base-\${VERSION}
echo "INSTALL_LOCATION=/export/epics" >> configure/CONFIG_SITE
export LC_ALL=en_US.UTF-8
mkdir -p /export/epics
......@@ -61,9 +61,7 @@ def transformIntoStep(String buildName) {
ln -sfn linux-x86_64/* .
mkdir -p /scratch
touch /scratch/dependencies.${JOB_NAME}.list
'''
sh """
sudo -u msk_jenkins tar zcf install-${JOB_NAME}-${label}-${buildType}.tgz /export /scratch
sudo -u msk_jenkins tar zcf "$WORKSPACE/install-${JOB_NAME}-${label}-${buildType}.tgz" /export /scratch
"""
archiveArtifacts artifacts: "install-${JOB_NAME}-${label}-${buildType}.tgz", onlyIfSuccessful: false
}
......
......@@ -47,14 +47,11 @@ def doAnalysis(ArrayList<String> dependencyList, String label, String buildType)
def doPrepare(boolean checkoutScm, String gitUrl='') {
// Make sure, /var/run/lock/mtcadummy is writeable by msk_jenkins
sh '''
chmod ugo+rwX /var/run/lock/mtcadummy
'''
// Make sure, /var/run/lock/mtcadummy is writeable by msk_jenkins.
// Create scratch directory. Keep the absolute path fixed, so we can copy the build directory as an artefact for the
// analysis job
sh '''
chmod ugo+rwX /var/run/lock/mtcadummy
mkdir /scratch
chown msk_jenkins /scratch
'''
......@@ -79,29 +76,22 @@ def doPrepare(boolean checkoutScm, String gitUrl='') {
/**********************************************************************************************************************/
def doDependencyArtefacts(ArrayList<String> dependencyList, String label, String buildType) {
echo("Obtaining dependency artefacts for ${label}-${buildType}")
// obtain artefacts of dependencies
script {
sh """
touch /scratch/artefact.list
"""
echo("Downloading and unpacking artefacts...")
dependencyList.each {
if( it != "" ) {
sh """
echo "${it}" >> /scratch/artefact.list
"""
copyArtifacts filter: "install-${it}-${label}-${buildType}.tgz", fingerprintArtifacts: true, projectName: "${it}", selector: lastSuccessful(), target: "artefacts"
sh """
tar zxvf \"artefacts/install-${it}-${label}-${buildType}.tgz\" -C /
cp /scratch/dependencies.${it}.list ${WORKSPACE}/artefact.list
touch /scratch/artefact.list
echo "${it}" >> /scratch/artefact.list
"""
myFile = readFile(env.WORKSPACE+"/artefact.list")
doDependencyArtefacts(new ArrayList<String>(Arrays.asList(myFile.split("\n"))), label, buildType)
}
}
echo("Done getting artefacts.")
sh """
chown -R msk_jenkins /scratch
"""
......@@ -112,25 +102,19 @@ def doDependencyArtefacts(ArrayList<String> dependencyList, String label, String
/**********************************************************************************************************************/
def doBuilddirArtefact(String label, String buildType) {
echo("Obtaining build directory artefact for ${label}-${buildType}")
// obtain artefacts of dependencies
script {
def parentJob = env.JOB_NAME[0..-10] // remove "-analysis" from the job name, which is 9 chars long
copyArtifacts filter: "build-${parentJob}-${label}-${buildType}.tgz", fingerprintArtifacts: true, projectName: "${parentJob}", selector: lastSuccessful(), target: "artefacts"
}
// unpack artefact into the Docker system root (should only write files to /scratch, which is writable by msk_jenkins)
sh """
for a in artefacts/build-*-${label}-${buildType}.tgz ; do
sudo -u msk_jenkins tar zxvf \"\${a}\" -C /
done
"""
// obtain artefacts of dependencies (from /scratch/artefact.list)
script {
echo("Getting dependency artefacts...")
// Unpack artefact into the Docker system root (should only write files to /scratch, which is writable by msk_jenkins).
// Then obtain artefacts of dependencies (from /scratch/artefact.list)
sh """
for a in artefacts/build-*-${label}-${buildType}.tgz ; do
sudo -u msk_jenkins tar zxvf \"\${a}\" -C /
done
cp /scratch/artefact.list ${WORKSPACE}/artefact.list
"""
myFile = readFile(env.WORKSPACE+"/artefact.list")
......@@ -139,7 +123,6 @@ def doBuilddirArtefact(String label, String buildType) {
copyArtifacts filter: "install-${it}-${label}-${buildType}.tgz", fingerprintArtifacts: true, projectName: "${it}", selector: lastSuccessful(), target: "artefacts"
}
}
echo("Done dependency getting artefacts.")
}
// unpack artefacts of dependencies into the Docker system root
......@@ -179,23 +162,15 @@ def doBuild(String label, String buildType) {
/**********************************************************************************************************************/
def doTest(String label, String buildType) {
echo("Starting tests for ${label}-${buildType}")
// Run the tests via ctest
sh """
cd /scratch/build-${JOB_NAME}
sudo -u msk_jenkins ctest --no-compress-output $MAKEOPTS -T Test || true
"""
// Prefix test names with label and buildType, so we can distinguish them later
// Copy test results files to the workspace, otherwise they are not available to the xunit plugin
sh """
cd /scratch/build-${JOB_NAME}
sudo -u msk_jenkins ctest --no-compress-output $MAKEOPTS -T Test || true
sudo -u msk_jenkins sed -i Testing/*/Test.xml -e 's_\\(^[[:space:]]*<Name>\\)\\(.*\\)\\(</Name>\\)\$_\\1${label}.${buildType}.\\2\\3_'
"""
// Copy test results files to the workspace, otherwise they are not available to the xunit plugin
sh """
sudo -u msk_jenkins cp -r /scratch/build-${JOB_NAME}/Testing .
sudo -u msk_jenkins cp -r /scratch/build-${JOB_NAME}/Testing "${WORKSPACE}"
"""
// Publish test result directly (works properly even with multiple publications from parallel branches)
......@@ -206,7 +181,6 @@ def doTest(String label, String buildType) {
/**********************************************************************************************************************/
def doCoverage(String label, String buildType) {
echo("Generating coverage report for ${label}-${buildType}")
def parentJob = env.JOB_NAME[0..-10] // remove "-analysis" from the job name, which is 9 chars long
// Generate coverage report as HTML and also convert it into cobertura XML file
......@@ -237,7 +211,6 @@ def doCoverage(String label, String buildType) {
/**********************************************************************************************************************/
def doValgrind(String label, String buildType) {
echo("Running valgrind for ${label}-${buildType}")
def parentJob = env.JOB_NAME[0..-10] // remove "-analysis" from the job name, which is 9 chars long
// Run valgrind twice in memcheck and helgrind mode
......@@ -276,28 +249,23 @@ def doValgrind(String label, String buildType) {
cd /scratch/build-${parentJob}
done
"""
// stash valgrind result files for later publication
sh """
sudo -u msk_jenkins cp /scratch/build-${parentJob}/*.valgrind .
sudo -u msk_jenkins cp /scratch/build-${parentJob}/*.valgrind "${WORKSPACE}"
"""
// stash valgrind result files for later publication
stash includes: '*.valgrind', name: "valgrind-${label}-${buildType}"
}
/**********************************************************************************************************************/
def doInstall(String label, String buildType) {
echo("Generating artefacts for ${label}-${buildType}")
// Install, but redirect files into the install directory (instead of installing into the system)
// Generate tar ball of install directory - this will be the artefact used by our dependents
sh """
cd /scratch/build-${JOB_NAME}
sudo -u msk_jenkins make install DESTDIR=../install
"""
// Generate tar ball of install directory - this will be the artefact used by our dependents
sh """
cd /scratch/install
mkdir -p scratch
cp /scratch/artefact.list scratch/dependencies.${JOB_NAME}.list
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment