-
Notifications
You must be signed in to change notification settings - Fork 5
/
bitbucket-pipelines.yml
194 lines (193 loc) · 7.85 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# Pipeline for building and publishing msteams-jira project
image: atlassian/default-image:4
options:
docker: true
size: 2x
definitions:
services:
docker:
memory: 5000
steps:
- step: &dockerImage
name: Prepare custom Docker image
services:
- docker
caches:
- docker
script:
- pipe: atlassian/artifactory-sidekick:v1
- source .artifactory/activate.sh
- export IMG_TAG=docker.atl-paas.net/atlassian/netrunners/dotnet-node
- docker build --tag="$IMG_TAG" --file docker/Dockerfile .
- docker push "$IMG_TAG"
- step: &build
name: Build and Test
image:
name: docker-proxy.services.atlassian.com/atlassian/netrunners/dotnet-node
username: netrunners
password: $PIPELINES_JWT_TOKEN
caches:
- dotnetcore
- node
script:
# change project version
- PACKAGE_VERSION=$(date +%Y.%m.%d).$BITBUCKET_BUILD_NUMBER
- xmlstarlet edit -L -u /Project/PropertyGroup/Version -v ""$PACKAGE_VERSION"" $BITBUCKET_CLONE_DIR/src/MicrosoftTeamsIntegration.Jira/MicrosoftTeamsIntegration.Jira.csproj
- echo "`xmlstarlet sel -t -v /Project/PropertyGroup/Version $BITBUCKET_CLONE_DIR/src/MicrosoftTeamsIntegration.Jira/MicrosoftTeamsIntegration.Jira.csproj`"
# build source code
- REPORTS_PATH=./test-reports/build_$BITBUCKET_BUILD_NUMBER
- dotnet build -c Release
- dotnet test --no-build -c Release --logger:"junit;LogFilePath=$REPORTS_PATH/test-result.xml"
- step: &publish
name: Publish application
image:
name: docker-proxy.services.atlassian.com/atlassian/netrunners/dotnet-node
username: netrunners
password: $PIPELINES_JWT_TOKEN
script:
- dotnet publish -c Release -o 'publish'
- pushd ./publish; zip -r ../jira-$BITBUCKET_BUILD_NUMBER.zip .; popd
artifacts:
- jira-*.zip
- step: &deploy
name: Deploy application
deployment: Integration
script:
- pipe: atlassian/azure-web-apps-deploy:1.1.0
variables:
AZURE_APP_ID: $AZURE_APP_ID
AZURE_PASSWORD: $AZURE_PASSWORD
AZURE_TENANT_ID: $AZURE_TENANT_ID
AZURE_RESOURCE_GROUP: $AZURE_RESOURCE_GROUP
AZURE_APP_NAME: $AZURE_APP_NAME
ZIP_FILE: 'jira-$BITBUCKET_BUILD_NUMBER.zip'
SLOT: $AZURE_SLOT
- step: &manifests
name: Build manifests
image:
name: docker-proxy.services.atlassian.com/atlassian/netrunners/dotnet-node
username: netrunners
password: $PIPELINES_JWT_TOKEN
script:
- MANIFEST_VERSION=$(date +%Y.%m.%d)
- MANIFEST_ZIP_VERSION=$MANIFEST_VERSION.$BITBUCKET_BUILD_NUMBER
# Change version and zip integration sideload
- echo "`jq '.version="'"$MANIFEST_VERSION"'"' manifests/server/integration/manifest.json`" > manifests/server/integration/manifest.json
- pushd ./manifests/server/integration/; zip -r ./../../../Jira.Server.Sideload.$MANIFEST_ZIP_VERSION-Integration.zip .; popd
# Change version and zip staging sideload
- echo "`jq '.version="'"$MANIFEST_VERSION"'"' manifests/server/staging/manifest.json`" > manifests/server/staging/manifest.json
- pushd ./manifests/server/staging/; zip -r ./../../../Jira.Server.Sideload.$MANIFEST_ZIP_VERSION-Staging.zip .; popd
# Change version and zip production sideload
- echo "`jq '.version="'"$MANIFEST_VERSION"'"' manifests/server/production/manifest.json`" > manifests/server/production/manifest.json
- pushd ./manifests/server/production/; zip -r ./../../../Jira.Server.Sideload.$MANIFEST_ZIP_VERSION-Production.zip .; popd
artifacts:
- Jira.Server.Sideload*.zip
- step: &createTag
name: Create tag
script:
- TAG_NAME=$(echo "$BITBUCKET_BRANCH" | sed 's/release\///')
- echo "Creating new tag ${TAG_NAME}"
- git tag -am "Tag ${TAG_NAME}" $TAG_NAME
- git push origin $TAG_NAME
- step: &snyk-scan
name: Run Snyk scan
image:
name: docker-proxy.services.atlassian.com/atlassian/netrunners/dotnet-node
username: netrunners
password: $PIPELINES_JWT_TOKEN
script:
- pipe: atlassian/artifactory-sidekick:v1
- source .artifactory/activate.sh
# restore all dependencies before scan
- dotnet publish -c Release -o 'publish'
# install Snyk
- npm install -g snyk
# run Snyk monitor
- snyk monitor --all-projects
- step: &pushToGithub
name: Push changes to Github repo
script:
- git remote add github [email protected]:atlassian-labs/msteams-jira-server.git
- git push -u github ${BITBUCKET_BRANCH}
- git push github --follow-tags
- step: &staticAnalysis
name: Static analysis
image:
name: docker-proxy.services.atlassian.com/atlassian/netrunners/dotnet-node
username: netrunners
password: $PIPELINES_JWT_TOKEN
script:
- rm -rf /var/lib/apt/lists/*
- export CHROME_BIN=/usr/bin/google-chrome
- dotnet tool install --global dotnet-sonarscanner
- dotnet tool install --global JetBrains.dotCover.GlobalTool
- export PATH="$PATH:/root/.dotnet/tools"
- dotnet sonarscanner begin /k:"$SONAR_REPOSITORY" /d:sonar.host.url="$SONAR_URL" /d:sonar.login="$SONAR_TOKEN" /d:sonar.cs.dotcover.reportsPaths=dotCover.Output.html /d:sonar.javascript.lcov.reportPaths=./ClientApp/coverage/lcov-report/lcov.info
- dotnet build --no-incremental
- dotnet dotcover test --dcReportType=HTML
- npm install --prefix ./src/MicrosoftTeamsIntegration.Jira/ClientApp
- npm run test:pipeline --no-sandbox --prefix ./src/MicrosoftTeamsIntegration.Jira/ClientApp
- dotnet sonarscanner end /d:sonar.login="$SONAR_TOKEN"
- |
ENCODED_BRANCH=$(echo "$BITBUCKET_BRANCH" | jq -sRr @uri)
STATUS=$(curl -s -u $SONAR_TOKEN: "https://sonar-enterprise.internal.atlassian.com/api/qualitygates/project_status?projectKey=msteams-jira-onprem&branch=$ENCODED_BRANCH" | jq -r .projectStatus.status)
if [ "$STATUS" != "OK" ]; then
echo "Quality gate failed: https://sonar-enterprise.internal.atlassian.com/dashboard?id=msteams-jira-onprem&branch=$ENCODED_BRANCH&"
exit 1
fi
pipelines:
default:
- step:
<<: *dockerImage
condition:
changesets:
includePaths:
- 'docker/**'
- step: *build
- step: *staticAnalysis
custom:
buildDockerImage:
- step: *dockerImage
buildManifests:
- step: *manifests
createNewTag:
- step: *createTag
runSnyk:
- step: *snyk-scan
runSonar:
- step: *staticAnalysis
branches:
master:
- step: *build
- step: *staticAnalysis
- step: *publish
- step:
<<: *deploy
name: Deploy to integration
deployment: Integration
- step:
<<: *deploy
name: Deploy to staging
deployment: Staging
trigger: manual
release/*:
- step: *build
- step: *publish
- step:
<<: *deploy
name: Deploy to integration
deployment: Integration
- step:
<<: *deploy
name: Deploy to staging
deployment: Staging
- step:
<<: *deploy
name: Deploy to production
deployment: Production
trigger: manual
- step:
<<: *createTag
trigger: manual
- step:
<<: *pushToGithub