Skip to content
This repository has been archived by the owner on Mar 28, 2020. It is now read-only.

Commit

Permalink
#2 Jenkins create more meaningful PDF name
Browse files Browse the repository at this point in the history
  • Loading branch information
schnatterer committed Sep 18, 2019
1 parent e55f16b commit 3330adc
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Jenkinsfile
Expand Up @@ -20,7 +20,6 @@ node('docker') {
])

def introSlidePath = 'docs/slides/01-intro.md'
pdfPath ='slides.pdf'
nodeImageVersion = 'node:11.14.0-alpine'

Git git = new Git(this, 'cesmarvin')
Expand All @@ -35,6 +34,7 @@ node('docker') {
}

String versionName = createVersion(mvn)
String pdfPath = createPdfName()

stage('Build') {
docker.image(nodeImageVersion)
Expand All @@ -58,7 +58,7 @@ node('docker') {
}

stage('print pdf') {
printPdf()
printPdf pdfPath
archiveArtifacts pdfPath
}

Expand Down Expand Up @@ -95,7 +95,11 @@ node('docker') {
}

String nodeImageVersion
String pdfPath

String createPdfName() {
String title = sh (returnStdOut: true, script: "grep -r '<title>' index.html | sed 's/.*<title>\\(.*\\)<.*/\\1/'")
return "${new Date().format('yyyy-MM-dd')}-${title}.pdf"
}

String createVersion(Maven mvn) {
// E.g. "201708140933-1674930"
Expand All @@ -118,7 +122,7 @@ void writeVersionNameToIntroSlide(String versionName, String introSlidePath) {
sh "mv $filteredIntro $introSlidePath"
}

void printPdf() {
void printPdf(String pdfPath) {
Docker docker = new Docker(this)

docker.image(nodeImageVersion).withRun(
Expand Down

0 comments on commit 3330adc

Please sign in to comment.