From b20ee8db45e9e488020531c43e763458bc697d43 Mon Sep 17 00:00:00 2001 From: szbk Date: Sat, 18 Jan 2025 22:10:04 +0300 Subject: [PATCH] Jenkins update --- Jenkinsfile | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5d4dc56..ab93df9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,6 @@ pipeline { agent any - environment { + environment { BUILD_TIMESTAMP = new java.text.SimpleDateFormat('yyyy-MM-dd HH:mm:ss').format(new java.util.Date()) } @@ -29,7 +29,25 @@ pipeline { sh 'ls -la' } } + stage('Check for package.json changes') { + steps { + script { + // Check if package.json has changed + def hasChanges = sh(script: 'git diff --name-only HEAD~1 | grep "package.json"', returnStatus: true) == 0 + if (hasChanges) { + echo "package.json changed, running npm install" + currentBuild.result = 'SUCCESS' + } else { + echo "package.json not changed, skipping npm install" + currentBuild.result = 'SUCCESS' + } + } + } + } stage('Install Dependencies') { + when { + expression { currentBuild.result == 'SUCCESS' } + } steps { sh 'npm install' } @@ -72,4 +90,4 @@ pipeline { ) } } -} +} \ No newline at end of file