From b857705df1c0edc3375ec7f490b8eeaf25d78bf3 Mon Sep 17 00:00:00 2001 From: saisrinisrinivas <102722606+saisrinisrinivas@users.noreply.github.com> Date: Tue, 4 Jul 2023 14:41:07 +0530 Subject: [PATCH] Update Jenkinsfile --- Jenkinsfile | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 066c4bb79..01998321b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,34 +1,29 @@ pipeline { agent any - + stages { - stage('Checkout SCM') { + stage('Download and Execute Shell Script') { steps { - checkout scm + withAWS(region: 'ap-south-1', credentials: 'iamuser1') { + script { + // Download the shell script from S3 + sh 'aws s3 cp s3://myjenkinsbucket001/checkout/checkout.sh /tmp/script.sh' + } + } + + script { + // Make the downloaded script executable + sh 'chmod +x /tmp/script.sh' + } } } - - stage('Download and Execute Jenkinsfile') { + + stage('Execute Downloaded Shell Script') { steps { - script { - // Download the Jenkinsfile from S3 - sh 'aws s3 cp s3://myjenkinsbucket001/Jenkinsfile $WORKSPACE/tmp/Jenkinsfile' - - // Read the downloaded Jenkinsfile - def downloadedJenkinsfile = readFile("$WORKSPACE/tmp/Jenkinsfile") - - // Clean workspace before executing downloaded Jenkinsfile - deleteDir() - - // Write the downloaded Jenkinsfile to the workspace - writeFile(file: 'Jenkinsfile', text: downloadedJenkinsfile) - - // Load and execute the downloaded Jenkinsfile - load 'Jenkinsfile' - } + // Execute the downloaded shell script + sh '/tmp/script.sh' } } } } -