This is an automated email from the ASF dual-hosted git repository.

rlenferink pushed a commit to branch update-hugo-version
in repository https://gitbox.apache.org/repos/asf/celix-site.git

commit 5991f195bc6e9f110dc44d76645a84072bcc62c2
Author: Roy Lenferink <[email protected]>
AuthorDate: Thu Mar 30 19:50:08 2023 +0200

    Add checksum verification for Hugo dependency
---
 Jenkinsfile | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 828e803..666abad 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -24,6 +24,7 @@ pipeline {
    
     environment {
         HUGO_VERSION = '0.111.3'
+        HUGO_HASH = 
'b382aacb522a470455ab771d0e8296e42488d3ea4e61fe49c11c32ec7fb6ee8b'
         DEPLOY_BRANCH = 'asf-site'
     }
 
@@ -34,24 +35,24 @@ pipeline {
                     // Capture last commit hash for final commit message
                     env.LAST_SHA = sh(script:'git log -n 1 
--pretty=format:\'%H\'', returnStdout: true).trim()
 
-                    // Setup Hugo
+                    // Download Hugo
                     env.HUGO_DIR = sh(script:'mktemp -d', returnStdout: 
true).trim()
-                    sh """
-                        mkdir -p ${env.HUGO_DIR}/bin
-                        cd ${env.HUGO_DIR}
-                        wget --no-verbose -O hugo.tar.gz 
https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz
-                        tar xfzv hugo.tar.gz
-                        mv hugo ${env.HUGO_DIR}/bin/
-                    """
+                    sh "mkdir -p ${env.HUGO_DIR}/bin"
+                    sh "wget --no-verbose -O ${env.HUGO_DIR}/hugo.tar.gz 
https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz";
+                    // Verify the checksum
+                    def hugo_hash = sha256 file: "${env.HUGO_DIR}/hugo.tar.gz"
+                    assert hugo_hash == "${HUGO_HASH}"
+                    // Unpack Hugo
+                    sh "tar -C ${env.HUGO_DIR}/bin -xkf 
${env.HUGO_DIR}/hugo.tar.gz"
 
                     // Setup directory structure for generated content
                     env.TMP_DIR = sh(script:'mktemp -d', returnStdout: 
true).trim()
                     env.OUT_DIR = "${env.TMP_DIR}/content"
                     sh "mkdir -p ${env.OUT_DIR}"
-                    
                 }
             }
         }
+
         stage('Build') {
             steps {
                 script {
@@ -61,6 +62,7 @@ pipeline {
                 }
             }
         }
+
         stage('Deploy') {
             when {
                 anyOf {

Reply via email to