You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
I need to run my shell script to modify some files without using pipelines.
Is that possible?
Hello @Mustafa ahmed ,
Welcome to Atlassian Community!
In case you want to run the script within Atlassian infrastructure, you will indeed need to use Bitbucket Pipelines, or clone the repository and run the script on your local machine and then push back to bitbucket whatever changes executed by the script in your local repo.
Thank you, @Mustafa ahmed !
Patrik S
Hello @Patrik S ,
thanks a lot for your answer.
I have tried a script on my Pipeline to edit a file and commit that change
here is my yml config:
pipelines:custom:new_publish:- step:name: new publishscript:- echo "This step runs once you click the 'Run' button"- /bin/sh Build_script.sh- echo "git commands"- git add .- git commit -m "change 122"
and here is my Build_script.sh:
#!/usr/bin/env bash
#
# echo "You need define the APP_ENV variable "
APP_ENV="production"ENTITLEMENTS_PLIST_USER=Apps/UserApp/Cura.UserApp.iOS/Entitlements.plist
if [ -e "$ENTITLEMENTS_PLIST_USER" ]
then
echo "Updating Env to $APP_ENV in Entitlements.plist"
plutil -replace aps-environment -string $APP_ENV $ENTITLEMENTS_PLIST_USER
echo "File content:"
cat $ENTITLEMENTS_PLIST_USER
fi#git add .
#git commit -m "change 1"
but it does not work
I get this error:
"Build_script.sh: 15: Build_script.sh: plutil: not found"
please not that I am using that script on Appcenter.
My question is that possible to edit files using pipelines? or it's just for building testing & deploying.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Mustafa ahmed ,
The error you reported is happening because the plutil tool that you use in the script is not installed in the docker image you are using in your step. \
The steps in bitbucket pipelines run in a Linux-based docker container. The plutil is a MacOS tool and is not available for Linux.
However, it seems there's a different command in Linux called plistutil that provides similar functionality. In order to use plistutil in your build step you will have to first install it before running the script, as in the below example :
pipelines:
custom:
new_publish:
- step:
name: new publish
script:
- echo "This step runs once you click the 'Run' button"
- apt-get update && apt-get install -y libplist-utils # installing the package that contains plistutil
- /bin/sh Build_script.sh
- echo "git commands"
- git add .
- git commit -m "change 122"
We have added the command to install the package libplist-utils, which contains the command plistutil.
Then, you will need to edit the content of Build_script.sh and replace the plutil command with plistutil.
Since plistutil is a different command, it might have different options available, so I would recommend taking a look at its official manual :
Thank you, @Mustafa ahmed !
Patrik S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Patrik S
You really helped me to understand the missing parts, I appreciate your support.
My last beginner question:
I have changed my Build_script.sh to:
API_URL="www.production.com"
APP_CONSTANT_FILE=AppConstant.cs
if [ -e "$APP_CONSTANT_FILE" ]
then
echo "Updating AppConstant"
sed -i 's#ApiUrl = "[-A-Za-z0-9:_./]*"#ApiUrl = "'$API_URL'"#' $APP_CONSTANT_FILE
fi
and the pipeline run and was completed successfully.
but I didn't find that change in my source code or that commit in my repository commits
what I am missing here?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.