Skip to content

Instantly share code, notes, and snippets.

@lauer
Created December 7, 2021 07:33
Show Gist options
  • Save lauer/d7345fab533f611730a4087338032c2a to your computer and use it in GitHub Desktop.
Save lauer/d7345fab533f611730a4087338032c2a to your computer and use it in GitHub Desktop.
Small script to jenkinsfile which set the last .0 on alpha releases to the $BUILD_NUMBER from jenkins
#!/usr/bin/env bash
set -e
if [[ -z "${BUILD_NUMBER}" ]]; then
echo "No build number set"
env
exit 0
fi
BUILD_VERSION=`jq -r '.version' package.json | sed "s/0$/${BUILD_NUMBER}/"`
if [[ $BUILD_VERSION =~ .*alpha.* ]]; then
tmp=$(mktemp)
jq '.version="'"$BUILD_VERSION"'"' package.json > "${tmp}" && mv "${tmp}" package.json
else
echo "${BUILD_VERSION} does not contains alpha"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment