Retrieve Previous successful build SHA in pipelines

federico March 24, 2021

Hello,

I am using NX in my angular projected, and I would like to deploy/test only affected items during my PRs.

I created the following pipeline :


ds

# This is an example Starter pipeline configuration
# Use a skeleton to build, test and deploy using manual and parallel steps
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: node:12

definitions:
caches:
bundler: vendor/bundle

pipelines:
pull-requests:
- step:
name: 'Installation'
caches:
- node
script:
  - npm install
artifacts:
  - node_modules/**

- parallel:
- step:
name: 'Test'
script:
- npm run affected:test -- --base=origin/develop
- step:
name: 'Lint'
script:
- npm run affected:lint -- --base=origin/develop
- step:
name: 'Stylelint'
script:
- npm run affected:stylelint -- --base=origin/develop

branches:
develop:
-step:
name: 'Deploy Staging'
deployment: staging
script:
- npm run affected:build -- --base=origin/develop

Now, the last line don't work because, when the pipeline execute, the branch is already merged in develop so

 npm run affected:build -- --base=origin/develop

 Will do nothing as it is comparing to itself.

I would like to replace the --base=origin/develop with --base=$previousBuildSHA. But I am quite confused on how to retrieve it.

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events