Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlekseyKorzun/c70dc6385b89586fdc6de9c58c80d948 to your computer and use it in GitHub Desktop.
Save AlekseyKorzun/c70dc6385b89586fdc6de9c58c80d948 to your computer and use it in GitHub Desktop.
Jenkins building configuration example with tag management and Gulp
echo "Creating package structure..."
rm -rf package
# Purge old tags
echo "Tag: jenkins-${JOB_NAME}"
git fetch --tags
tag_limit=4
tag_current=`git tag -n |grep -i "jenkins-${JOB_NAME}" | wc -l`
if [ $tag_limit -lt $tag_current ]; then
tag_difference=`expr $tag_current - $tag_limit`
git tag |grep -i "jenkins-${JOB_NAME}" | head -$tag_difference | xargs git push --delete || true
git tag |grep -i "jenkins-${JOB_NAME}" | head -$tag_difference | xargs git tag -d || true
fi
# Create new tag
git push --tags
# Gulp automation
cp site/configs/gulp/gulpfile.js ~/
ln -sf `pwd`/site /www/
gulp -cwd ~/ deploy
gulp -cwd ~/ scss
gulp -cwd ~/ styles
gulp -cwd ~/ libs
gulp -cwd ~/ scripts
echo "Copying deployment package..."
cp -r site package/site
echo "Copying configuration files to deployment package"
cp -r configs package/configs
echo "Creating revision file for deployment..."
echo "${JOB_NAME}-${BUILD_NUMBER}" > ../revision.txt
cp ../revision.txt package/site/source/www/revision.txt
echo "Creating archive of source..."
tar -zcf package.tar.gz --exclude .git package
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment