Update Jenkinsfile

This commit is contained in:
saisrinisrinivas 2023-07-04 14:41:07 +05:30 committed by GitHub
parent 10b182786a
commit b857705df1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

39
Jenkinsfile vendored
View file

@ -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'
}
}
}
}