ium_z487177/Jenkinsfile-dataset-stats

64 lines
1.8 KiB
Plaintext
Raw Normal View History

2023-04-19 21:04:37 +02:00
pipeline {
agent any
parameters {
2023-04-19 21:06:34 +02:00
choice(
name: 'BUILD_SELECTOR',
choices: ['lastSuccessful', 'specificBuild'],
description: 'Select build'
)
2023-04-19 21:04:37 +02:00
string(
2023-04-19 21:06:34 +02:00
name: 'SPECIFIC_BUILD',
defaultValue: '',
description: 'Specific build to copy artifacts from',
2023-04-19 21:04:37 +02:00
trim: true
)
}
stages {
2023-04-19 21:06:34 +02:00
stage('Copy Artifacts') {
2023-04-19 21:04:37 +02:00
steps {
2023-04-19 21:06:34 +02:00
script {
def buildSelector
if (params.BUILD_SELECTOR == 'lastSuccessful') {
buildSelector = lastSuccessful()
} else if (params.BUILD_SELECTOR == 'specificBuild') {
buildSelector = build(params.SPECIFIC_BUILD)
} else {
error('Invalid build selector')
}
def copyArtifactParams = [
2023-04-19 21:07:40 +02:00
projectName: 'z-s487177-create-dataset',
2023-04-19 21:06:34 +02:00
selector: buildSelector,
filter: 'output.txt.gz',
flatten: true
]
copyArtifacts(copyArtifactParams)
}
2023-04-19 21:04:37 +02:00
}
}
2023-04-19 21:06:34 +02:00
stage('Calculate Dataset Statistics') {
2023-04-19 21:04:37 +02:00
steps {
sh '''
2023-04-19 21:06:34 +02:00
#!/bin/bash
set -e
# Count the number of lines in the input file
zcat output.txt.gz | wc -l > stats
# Archive the stats file
tar czvf stats.tar.gz stats
2023-04-19 21:04:37 +02:00
'''
2023-04-19 21:06:34 +02:00
}
post {
always {
archiveArtifacts artifacts: 'stats.tar.gz', fingerprint: true
}
2023-04-19 21:04:37 +02:00
}
}
}
}