Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,455,289
Community Members
 
Community Events
175
Community Groups

Run shell script

I need to run my shell script to modify some files without using pipelines.
Is that possible?  

1 answer

0 votes
Patrik S Atlassian Team Jan 25, 2023

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 publish
script:
- 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.


Patrik S Atlassian Team Jan 26, 2023

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:
namenew 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

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS

Atlassian Community Events