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

How can I download a folder from s3 to local in bitbucket pipeline

NIJO January 20, 2021

How can I download a folder from s3 to local in the bitbucket pipeline?

How I can execute a shell script in the pipeline?

1 answer

0 votes
Dave Gilmore January 20, 2021
Hi @NIJO 

We use Python to Achieve this

`python /tmp/s3_artifact_downloader.py`

Downloader, looks something like:

```

import sysimport boto3
def download_from_s3(aws_public_key, aws_private_key, s3bucket, from_key, to_file): boto3.client( 's3', aws_access_key_id = aws_public_key, aws_secret_access_key = aws_private_key ).download_file(s3bucket, from_key, to_file)
if __name__ == "__main__": hg_bucket = 'build-artifacts' hg_key = 'master/latest' # get key from commnd line if necessary if len(sys.argv) > 1: hg_key = sys.argv[1].replace('/', '-') + '/latest' aws_public_key = sys.argv[2] aws_private_key = sys.argv[3]
print('Downloadingfrom s3://{}/{}'.format(hg_bucket, hg_key))
download_from_s3( aws_public_key = aws_public_key, aws_private_key = aws_private_key, s3bucket = hg_bucket, from_key = hg_key, to_file = 'HG.zip')
Dave Gilmore January 20, 2021

The formatting sucks!

Here is a PasteBin:

https://pastebin.com/k51DQup7

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events