-
-
Save hatan4ik/be8aaabd8a5d4d49c47f6b6240f1b31d to your computer and use it in GitHub Desktop.
Jenkins_Bacup via jenkins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Delete all files in the workspace | |
| rm -rf * | |
| # Create a directory for the job definitions | |
| mkdir -p $BUILD_ID/jobs | |
| # Copy global configuration files into the workspace | |
| cp $JENKINS_HOME/*.xml $BUILD_ID/ | |
| # Copy keys and secrets into the workspace | |
| cp $JENKINS_HOME/identity.key.enc $BUILD_ID/ | |
| cp $JENKINS_HOME/secret.key $BUILD_ID/ | |
| cp $JENKINS_HOME/secret.key.not-so-secret $BUILD_ID/ | |
| cp -r $JENKINS_HOME/secrets $BUILD_ID/ | |
| # Copy user configuration files into the workspace | |
| cp -r $JENKINS_HOME/users $BUILD_ID/ | |
| # Copy job definitions into the workspace | |
| rsync -am --include='config.xml' --include='*/' --prune-empty-dirs --exclude='*' $JENKINS_HOME/jobs/ $BUILD_ID/jobs/ | |
| # Create an archive from all copied files (since the S3 plugin cannot copy folders recursively) | |
| tar czf $BUILD_ID.tar.gz $BUILD_ID/ | |
| # Remove the directory so only the archive gets copied to S3 | |
| rm -rf $BUILD_ID | |
| # uploading the build to s3 bucket, post build action is a bitch !! | |
| #/usr/bin/s3cmd put /var/lib/jenkins/workspace/jenkins_backup/$BUILD_ID.tar.gz s3://<bucket_name>/jenkins/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment