Hello people, my question now is: I created a * sh to create a tag in another repository (weird thing I need more for my business rule to work in gcp) I'm doing this via the bitbucket api, only to create the precise hash tag for a commit from this repository, so far ok! But what I did is working, but of course it's not done well, but that's what I got for now.
#!/usr/bin/env bash
# Exit immediately if a any command exits with a non-zero status
set -e
# Set variables
REPOSITORY=$1
echo "Get Last Commit"
curl https://api.bitbucket.org/2.0/repositories/$BITBUCKET_REPO_OWNER/$REPOSITORY/commits/?pagelen=1 \
-u $BITBUCKET_USERNAME:$BITBUCKET_APP_PASSWORD_MASTER \
sed 's/{"pagelen.*, "hash//' arq1.hash > arq2.hash
grep -i "" arq2.hash | awk '{print $2}' > arq3.hash
sed 's/"//g' arq3.hash > arq4.hash
sed 's/,//g' arq4.hash > arq5.hash
LAST_COMMIT_HASH=$(cat arq5.hash)
rm -f arq*.hash
echo "Last Commit: " $LAST_COMMIT_HASH
# Create new tag
echo "Creating Tag"
curl (-)X POST https://api.bitbucket.org/2.0/repositories/$BITBUCKET_REPO_OWNER/$REPOSITORY/refs/tags \
(-u $BITBUCKET_USERNAME:$BITBUCKET_APP_PASSWORD_MASTER \
--fail --show-error --silent \
-H 'Content-Type: application/json' \
-d '{
"name":
"release_'$BITBUCKET_BUILD_NUMBER'",
"target": {
"hash": "'$LAST_COMMIT_HASH'"
}
}'
What I would like to know is if it is possible through the API to rescue the hash of the last commit from the master of a repository OR if I can create an empty commit (git commit --allow-empty) through the api and in return get this hash? !