Skip to content

Commit be4c91d

Browse files
utsavizedsarvaje
authored andcommitted
New: Update new service endpoints
1 parent 9b33a55 commit be4c91d

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

azure-pipelines.yml

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
GIT_USER_EMAIL: $(GIT_USER_EMAIL)
2626
GIT_USER_NAME: $(GIT_USER_NAME)
2727
GIT_PASSWORD: $(GIT_PASSWORD)
28+
GIT_SCANNER_USER: $(GIT_SCANNER_USER)
29+
GIT_SCANNER_PASSWORD: $(GIT_SCANNER_PASSWORD)
30+
BRANCH: variables['Build.SourceBranch']
2831
- script: npm run test-staging && node helpers/integration-tests/index.js
2932
displayName: 'Analyze staging with webhint'
3033
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))

helpers/update-site.sh

+22-3
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,31 @@ update_website() {
3636
# Move to temp folder
3737
cd "$TMP_DIR"
3838

39+
declare -r masterBranch="refs/heads/master"
40+
declare slot=""
41+
declare user=""
42+
declare password=""
43+
declare message=""
44+
45+
if [ "$masterBranch" == "$BRANCH" ]; then
46+
slot="sonarwhal-staging"
47+
user=$GIT_USER_NAME
48+
password=$GIT_PASSWORD
49+
message="Hey server, this content is for you! ***NO_CI***"
50+
else
51+
slot="sonarwhal-scanner-staging"
52+
user=$GIT_SCANNER_USER
53+
password=$GIT_SCANNER_PASSWORD
54+
message="Hey staging server, this content is for you! ***NO_CI***"
55+
fi
56+
57+
3958
git config --global user.email "$GIT_USER_EMAIL" \
40-
&& git config --global user.name "$GIT_USER_NAME" \
59+
&& git config --global user.name "$user" \
4160
&& git init \
4261
&& git add -A \
43-
&& git commit --message "Hey server, this content is for you! ***NO_CI***" \
44-
&& git push --quiet --force --set-upstream "https://$GIT_USER_NAME:$GIT_PASSWORD@sonarwhal-staging.scm.azurewebsites.net:443/sonarwhal.git" master
62+
&& git commit --message "$message" \
63+
&& git push --quiet --force --set-upstream "https://$user:$password@$slot.scm.azurewebsites.net:443/sonarwhal.git" master
4564
}
4665

4766
remove_sensitive_information() {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,4 @@
9595
"update-site": "node helpers/update-site.js",
9696
"postinstall": "node helpers/postinstall.js"
9797
}
98-
}
98+
}

src/server/routes/scanner.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const promisify = require('util').promisify;
44
const _ = require('lodash');
55
const moment = require('moment');
66
const globby = require('globby');
7-
const r = require('request').defaults({ headers: { authorization: `Bearer ${process.env.auth}` } }); // eslint-disable-line no-process-env
7+
const r = require('request').defaults({ headers: { 'x-functions-key': `${process.env.FUNCTIONS_KEY}` } }); // eslint-disable-line no-process-env
88
const { getMessage: getMessageUtils } = require('@hint/utils').i18n;
99

1010
const request = promisify(r);
@@ -42,11 +42,11 @@ const getMessageByLanguage = (language) => {
4242
};
4343

4444
const sendRequest = (url) => {
45-
const formData = { url };
4645
const options = {
47-
formData,
46+
body: JSON.stringify({ url }),
47+
headers: { 'Content-type': 'application/json' },
4848
method: 'POST',
49-
url: `${serviceEndpoint}`
49+
url: `${serviceEndpoint}/createjob`
5050
};
5151

5252
return request(options);
@@ -55,7 +55,7 @@ const sendRequest = (url) => {
5555
const queryResult = async (id, tries) => {
5656
let response;
5757
const counts = tries || 0;
58-
const result = await request(`${serviceEndpoint}${id}`);
58+
const result = await request(`${serviceEndpoint}/jobstatus?id=${id}`);
5959

6060
if (!result.body) {
6161
throw new Error(`No result found for this url. Please scan again.`);

0 commit comments

Comments
 (0)