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

Run shell script

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

1 answer

1 accepted

0 votes
Answer accepted
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
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
Atlassian Team members are employees working across the company in a wide variety of roles.
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

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.

Screenshot 2023-01-27 at 1.06.31 AM.png

 

but I didn't find that change in my source code or that commit in my repository commits

what I am missing here? 

Hi @Patrik S 

I was missing the push command 

It works now thanks.

Suggest an answer

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

Atlassian Community Events