ergerg
ergerg

Reputation: 1

Howto run a script within a pipe?

I am using the pipe atlassian/aws-s3-deploy:0.4.0 in my Bitbucket pipeline to deploy to aws s3. This works well, but I need to set Cache-Control only for the index.html

How do I run code within the pipe, so that the aws cli tool is still available? It should not be another step, as the deployment process should be a single one.

My Current Script looks like this:

image: node:10.15.3

pipelines:
default:
    - step:
        name: Build
        caches:
        - node
        script:
        - npm install
        - npm run build
        artifacts:
        - dist/**
    - step:
        name: Deploy
        trigger: manual
        script:
        - pipe: atlassian/aws-s3-deploy:0.4.0
            variables:
            AWS_DEFAULT_REGION: 'eu-central-1'
            S3_BUCKET: '***'
            LOCAL_PATH: 'dist'
        - aws s3 cp dist/index.html s3://***/index.html --cache-control no-cache,no-store

Credentials are provided via project secret variables.

Thank you!!

Upvotes: 0

Views: 776

Answers (1)

Alexander Zhukov
Alexander Zhukov

Reputation: 4557

You could just install the aws cli in the same step:

- step:
    name: Deploy
    trigger: manual
    # use python docker image so pip is available
    image: python:3.7
    script:
      - pipe: atlassian/aws-s3-deploy:0.4.0
          variables:
            AWS_DEFAULT_REGION: 'eu-central-1'
            S3_BUCKET: '***'
            LOCAL_PATH: 'dist'
    # install the aws cli
      - pip3 install awscli --upgrade --user
      - aws s3 cp dist/index.html s3://***/index.html --cache-control no-cache,no-store

Upvotes: 0

Related Questions