Created
May 16, 2016 23:37
-
-
Save AlekseyKorzun/c70dc6385b89586fdc6de9c58c80d948 to your computer and use it in GitHub Desktop.
Jenkins building configuration example with tag management and Gulp
This file contains 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
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