Created
June 26, 2022 06:48
-
-
Save kaosf/42610e6ea58fea778fdb8985efaafce8 to your computer and use it in GitHub Desktop.
Update `releaseVersion = '.*'` in `Jenkinsfile` automatically.
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
#!/bin/bash | |
VERSION_LINE=$(grep "releaseVersion = '.*'" Jenkinsfile) | |
[[ $VERSION_LINE =~ releaseVersion\ =\ \'(.*)\' ]] && VERSION=${BASH_REMATCH[1]} | |
if [[ -z $VERSION ]]; then | |
echo "Could not find version in Jenkinsfile" | |
VERSION=$(date +%Y%m%d).0 | |
else | |
DATE=$(echo $VERSION | cut -d. -f1) | |
TODAY=$(date +%Y%m%d) | |
if [[ $DATE == $TODAY ]]; then | |
VERSION=$(echo $VERSION | cut -d. -f2) | |
VERSION=$((VERSION+1)) | |
VERSION=$DATE.$VERSION | |
else | |
VERSION=$TODAY.0 | |
fi | |
fi | |
read -p "$VERSION, OK? y/N: " -n 1 -r ANSWER | |
if [[ $ANSWER != "y" ]]; then | |
VERSION="" | |
while [[ -z $VERSION ]]; do | |
read -p "Version: " VERSION | |
done | |
fi | |
sed -i Jenkinsfile -e "s/releaseVersion = '.*'/releaseVersion = '$VERSION'/" | |
git add Jenkinsfile | |
git commit -m "Version $VERSION" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Trackback https://twitter.com/ka_/status/1540952261949501440