-
Notifications
You must be signed in to change notification settings - Fork 7
/
bitbucket-pipelines.yml
145 lines (142 loc) · 8.31 KB
/
bitbucket-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
image:
name: gscloudsolutions/devops-mate:stable # Referencing the public image from Docker Hub
#username: $DOCKER_HUB_USERNAME #Username-password not required
#password: $DOCKER_HUB_PASSWORD
pipelines:
pull-requests:
feature/*: #any branch with a feature prefix
- step:
name: Creating Deployment Package for CI(Continuous Integration)
script:
- echo 'Getting Target Org Status From QA/Partial Dev Org'
- sfDeploymentInfo get -u "$QA_ORG_USERNAME" -t $QA_ORG_TYPE -i $BITBUCKET_BUILD_NUMBER -n All -s "$QA_ORG_PASSWORD"
- echo 'Creating a Git Diff based artifact/package'
- sfPackages source-combined -p $BITBUCKET_CLONE_DIR -n $LATEST_COMMIT_HASH_TAG -i $BITBUCKET_BUILD_NUMBER || if test $? -eq 21; then exit 0; else exit 1; fi
artifacts:
- Artifacts/**
- step:
name: Scratch Org Deployment Validation
script:
- echo 'Create Scratch Org'
- sfOrgs createOrg -x 'CIOrg-$BITBUCKET_BUILD_NUMBER' -p ./config/project-scratch-def.json -t $DEVHUB_ORG_TYPE -u "$DEVHUB_USERNAME" -s "$DEVHUB_PASSWORD"
- echo 'Create a full deployment artifact/package'
- sfPackages source-combined -f true -v $MAJOR_VERSION.$MINOR_VERSION.$PATCH.$BITBUCKET_BUILD_NUMBER -p $BITBUCKET_CLONE_DIR -n $LATEST_COMMIT_HASH_TAG || if test $? -eq 21; then exit 0; else exit 1; fi
- echo 'Deploy the package to Scratch Org'
- sfDeploy mdapipackage -l $TEST_LEVEL -p $BITBUCKET_CLONE_DIR -a 'CIOrg-$BITBUCKET_BUILD_NUMBER' -v $MAJOR_VERSION.$MINOR_VERSION.$PATCH.$BITBUCKET_BUILD_NUMBER
- step:
name: Deployment Validation On QA/CI Environment
script:
- echo 'Getting Target Org Status From QA/CI Org'
- sfDeploymentInfo get -u "$QA_ORG_USERNAME" -t $QA_ORG_TYPE -i $BITBUCKET_BUILD_NUMBER -n All -s "$QA_ORG_PASSWORD"
#- echo 'Creating a Git Diff based artifact/package'
#- sfPackages source-combined -p $BITBUCKET_CLONE_DIR/$QA_PACKAGE_DIR -n $LATEST_COMMIT_HASH_TAG -i $BITBUCKET_BUILD_NUMBER || if test $? -eq 21; then exit 0; else exit 1; fi
- echo 'Deployment Validation On QA/Partial-Dev Org.'
- sfDeploy mdapipackage -p $BITBUCKET_CLONE_DIR -c true -u "$QA_ORG_USERNAME" -s "$QA_ORG_PASSWORD" -t $QA_ORG_TYPE --successSHA $LATEST_COMMIT_HASH_TAG -i $BITBUCKET_BUILD_NUMBER
artifacts:
- Artifacts/**
branches:
# Pipeline for master branch
'master':
#Automated step as BB Pipeline can not start with a manual step
- step:
name: Feature Ready for QA
script:
- echo 'Ready for QA'
#QA Org Deployment
- step:
name: QA Org Deployment
deployment: QAOrg
trigger: manual
script:
- echo 'Getting Target Org Status From QA Org'
- sfDeploymentInfo get -u "$QA_ORG_USERNAME" -t $QA_ORG_TYPE -i $BITBUCKET_BUILD_NUMBER -n All -s "$QA_ORG_PASSWORD"
- echo 'Creating a Git Diff based artifact/package'
- sfPackages source-combined -p $BITBUCKET_CLONE_DIR -n $LATEST_COMMIT_HASH_TAG -i $BITBUCKET_BUILD_NUMBER || if test $? -eq 21; then exit 0; else exit 1; fi
- echo 'Deployment On QA Org.'
- sfDeploy mdapipackage -p $BITBUCKET_CLONE_DIR -u "$QA_ORG_USERNAME" -s "$QA_ORG_PASSWORD" -t $QA_ORG_TYPE --successSHA $LATEST_COMMIT_HASH_TAG -i $BITBUCKET_BUILD_NUMBER -l RunLocalTests
#UAT Org Deployment
- step:
name: UAT Org Deployment
deployment: UATOrg
trigger: manual
script:
- echo 'Getting Target Org Status from UAT Org'
- sfDeploymentInfo get -u "$UAT_ORG_USERNAME" -t $UAT_ORG_TYPE -i $BITBUCKET_BUILD_NUMBER -n All -s "$UAT_ORG_PASSWORD"
- echo 'Creating a Git Diff based artifact/package'
- sfPackages source-combined -p $BITBUCKET_CLONE_DIR -n $LATEST_COMMIT_HASH_TAG -i $BITBUCKET_BUILD_NUMBER || if test $? -eq 21; then exit 0; else exit 1; fi
- echo 'UAT Org Deployment Validation'
- sfDeploy mdapipackage -p $BITBUCKET_CLONE_DIR -u $UAT_ORG_USERNAME -s $UAT_ORG_PASSWORD -t $UAT_ORG_TYPE --successSHA $LATEST_COMMIT_HASH_TAG -i $BITBUCKET_BUILD_NUMBER -l RunLocalTests
artifacts:
- Artifacts/**
#Production Org Deployment Validation
- step:
name: Creating Deployment Package for QA/Partial-Dev Org Validation
script:
- echo 'Getting Target Org Status from Prodcution Org'
- sfDeploymentInfo get -u "$PROD_ORG_USERNAME" -t "$PROD_ORG_TYPE" -i $BITBUCKET_BUILD_NUMBER -n All -s "$PROD_ORG_PASSWORD"
- echo 'Creating a Git Diff based artifact/package'
- sfPackages source-combined -p $BITBUCKET_CLONE_DIR -n $LATEST_COMMIT_HASH_TAG -i $BITBUCKET_BUILD_NUMBER || if test $? -eq 21; then exit 0; else exit 1; fi
artifacts:
- Artifacts/**
- step:
name: Prod Org Deployment Validation
trigger: manual
script:
- echo 'Getting Target Org Status from Prodcution Org'
- sfDeploymentInfo get -u "$PROD_ORG_USERNAME" -t $PROD_ORG_TYPE -i $BITBUCKET_BUILD_NUMBER -n All -s "$PROD_ORG_PASSWORD"
- echo 'Creating a Git Diff based artifact/package'
- sfPackages source-combined -p $BITBUCKET_CLONE_DIR -n $LATEST_COMMIT_HASH_TAG -i $BITBUCKET_BUILD_NUMBER || if test $? -eq 21; then exit 0; else exit 1; fi
- echo 'Production Org Deployment Validation'
- sfDeploy mdapipackage -p $BITBUCKET_CLONE_DIR -c true -u "$PROD_ORG_USERNAME" -s "$PROD_ORG_PASSWORD" -t $PROD_ORG_TYPE --successSHA $LATEST_COMMIT_HASH_TAG -i $BITBUCKET_BUILD_NUMBER -l RunLocalTests
#Production Org Deployment
- step:
name: Prod Org Deployment
deployment: ProdOrg
trigger: manual
script:
- echo 'Getting Target Org Status from Prodcution Org'
- sfDeploymentInfo get -u "$PROD_ORG_USERNAME" -t $PROD_ORG_TYPE -i $BITBUCKET_BUILD_NUMBER -n All -s "$PROD_ORG_PASSWORD"
- echo 'Creating a Git Diff based artifact/package'
- sfPackages source-combined -p $BITBUCKET_CLONE_DIR -n $LATEST_COMMIT_HASH_TAG -i $BITBUCKET_BUILD_NUMBER || if test $? -eq 21; then exit 0; else exit 1; fi
- echo 'Production Org Deployment'
- sfDeploy mdapipackage -p $BITBUCKET_CLONE_DIR -u "$PROD_ORG_USERNAME" -s "$PROD_ORG_PASSWORD" -t $PROD_ORG_TYPE --successSHA $LATEST_COMMIT_HASH_TAG -i $BITBUCKET_BUILD_NUMBER -l RunLocalTests
artifacts:
- Artifacts/**
custom: # Pipelines that can only be triggered manually or can be scheduled
PullAndCommitChangeSet:
- variables: #list variable names under here
- name: CHANGESET_NAME
- name: COMMIT_MESSAGE
- name: BRANCH_NAME
- step:
name: Checkout a git branch
script:
- echo 'Checking out git branch'
- pwd
- echo $BITBUCKET_CLONE_DIR
- echo $CHANGESET_NAME
- echo $COMMIT_MESSAGE
- echo $BRANCH_NAME
- ls -a
- git checkout -b "feature/$BRANCH_NAME"
- echo 'Pulling changeset and commiting it to checked out branch'
- sfRetrieve src-format -u "$DEV_ORG_USERNAME" -s "$DEV_ORG_PASSWORD" -t "$DEV_ORG_TYPE" -n "$CHANGESET_NAME" -p $BITBUCKET_CLONE_DIR
- ls -a
- git add --all
- git commit -m "$COMMIT_MESSAGE"
- git push
DeployParticularCommit:
- variables: #list variable names under here
- name: COMMIT_HASH_OR_TAG
- step:
name: Create Artifact
script:
- echo 'Creating a Git Diff based artifact/package'
- sfPackages source-combined -p $BITBUCKET_CLONE_DIR -n "$COMMIT_HASH_OR_TAG" -o "$COMMIT_HASH_OR_TAG~1" -v 1.0.0.$BITBUCKET_BUILD_NUMBER || if test $? -eq 21; then exit 0; else exit 1; fi
artifacts:
- Artifacts/**
- step:
name: Deploy Artifact
script:
- echo 'Deploying Artifact'
- sfDeploy mdapipackage -p $BITBUCKET_CLONE_DIR -u "QA_ORG_USERNAME"-s "QA_ORG_PASSWORD"-t $QA_ORG_TYPE -v 1.0.0.$BITBUCKET_BUILD_NUMBER -l RunLocalTests