diff --git a/package-lock.json b/package-lock.json
index 342dd18..06bed9b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "test-results-reporter",
- "version": "1.1.2",
+ "version": "1.1.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "test-results-reporter",
- "version": "1.1.2",
+ "version": "1.1.3",
"license": "ISC",
"dependencies": {
"async-retry": "^1.3.3",
diff --git a/package.json b/package.json
index e76802c..af38b70 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "test-results-reporter",
- "version": "1.1.2",
+ "version": "1.1.3",
"description": "Publish test results to Microsoft Teams, Google Chat, Slack and InfluxDB",
"main": "src/index.js",
"types": "./src/index.d.ts",
diff --git a/src/extensions/ci-info.js b/src/extensions/ci-info.js
index be67799..0795c0d 100644
--- a/src/extensions/ci-info.js
+++ b/src/extensions/ci-info.js
@@ -43,7 +43,15 @@ function get_repository_elements(inputs) {
elements.push({ label: 'Repository', key: ci.repository_name, value: ci.repository_url, type: 'hyperlink' });
}
if (inputs.show_repository_branch && ci && ci.repository_ref) {
- elements.push({ key: 'Branch', value: ci.repository_ref.replace('refs/heads/', '') });
+ if (ci.repository_ref.includes('refs/pull')) {
+ const pr_url = ci.repository_url + ci.repository_ref.replace('refs/pull/', 'pull/');
+ const pr_name = ci.repository_ref.replace('refs/pull/', '').replace('/merge', '');
+ elements.push({ label: 'Pull Request', key: pr_name, value: pr_url, type: 'hyperlink' });
+ } else {
+ const branch_url = ci.repository_url + ci.repository_ref.replace('refs/heads/', 'tree/');
+ const branch_name = ci.repository_ref.replace('refs/heads/', '');
+ elements.push({ label: 'Branch', key: branch_name, value: branch_url, type: 'hyperlink' });
+ }
}
return elements;
}
@@ -57,7 +65,7 @@ function get_build_elements(inputs) {
const ci = getCIInformation();
if (inputs.show_build && ci && ci.build_url) {
const name = (ci.build_name || 'Build') + (ci.build_number ? ` #${ci.build_number}` : '');
- elements.push({ key: name, value: ci.build_url, type: 'hyperlink' });
+ elements.push({ label: 'Build', key: name, value: ci.build_url, type: 'hyperlink' });
}
if (inputs.data) {
elements = elements.concat(inputs.data);
diff --git a/src/helpers/ci.js b/src/helpers/ci.js
index 9320da0..3c19c7a 100644
--- a/src/helpers/ci.js
+++ b/src/helpers/ci.js
@@ -20,7 +20,7 @@ function getGitHubActionsInformation() {
repository_name: ENV.GITHUB_REPOSITORY,
repository_ref: ENV.GITHUB_REF,
repository_commit_sha: ENV.GITHUB_SHA,
- build_url: ENV.GITHUB_SERVER_URL + '/' + ENV.GITHUB_REPOSITORY + '/commit/' + ENV.GITHUB_SHA + '/checks/' + ENV.GITHUB_RUN_ID,
+ build_url: ENV.GITHUB_SERVER_URL + '/' + ENV.GITHUB_REPOSITORY + '/actions/runs/' + ENV.GITHUB_RUN_ID,
build_number: ENV.GITHUB_RUN_NUMBER,
build_name: ENV.GITHUB_WORKFLOW,
user: ENV.GITHUB_ACTOR,
diff --git a/test/ext-ci-info.spec.js b/test/ext-ci-info.spec.js
index 5db1fea..12eb480 100644
--- a/test/ext-ci-info.spec.js
+++ b/test/ext-ci-info.spec.js
@@ -97,7 +97,7 @@ describe('extensions - ci-info', () => {
process.env.SYSTEM_TEAMPROJECT = 'test';
process.env.BUILD_REPOSITORY_URI = 'https://github.com/test/test';
process.env.BUILD_REPOSITORY_NAME = 'test/test';
- process.env.BUILD_SOURCEBRANCH = '/refs/heads/feature-test';
+ process.env.BUILD_SOURCEBRANCH = '/refs/pull/123/merge';
process.env.BUILD_SOURCEVERSION = 'sha';
process.env.BUILD_BUILDID = 'id-123';
process.env.BUILD_BUILDNUMBER = 'number-123';
@@ -131,6 +131,53 @@ describe('extensions - ci-info', () => {
assert.equal(mock.getInteraction(id).exercised, true);
});
+ it('should send test-summary with azure devops ci information to chat and extra data', async () => {
+ process.env.GITHUB_ACTIONS = 'GITHUB_ACTIONS';
+ process.env.GITHUB_SERVER_URL = 'https://github.com';
+ process.env.GITHUB_REPOSITORY = 'org/repo';
+ process.env.GITHUB_REF = '/refs/heads/feature-test';
+ process.env.GITHUB_SHA = 'sha';
+ process.env.GITHUB_RUN_ID = 'id-123';
+ process.env.GITHUB_RUN_NUMBER = 'number-123';
+ process.env.GITHUB_WORKFLOW = 'Build';
+ const id = mock.addInteraction('post test-summary with ci-info to chat');
+ await publish({
+ config: {
+ targets: [
+ {
+ name: 'chat',
+ inputs: {
+ url: 'http://localhost:9393/message'
+ },
+ extensions: [
+ {
+ name: 'ci-info',
+ inputs: {
+ data: [
+ {
+ "key": "Download Logs",
+ "value": "{LOGS_URL}",
+ "type": "hyperlink"
+ }
+ ]
+ }
+ }
+ ]
+ }
+ ],
+ results: [
+ {
+ type: 'testng',
+ files: [
+ 'test/data/testng/single-suite.xml'
+ ]
+ }
+ ]
+ }
+ });
+ assert.equal(mock.getInteraction(id).exercised, true);
+ });
+
afterEach(() => {
mock.clearInteractions();
});
diff --git a/test/mocks/chat.mock.js b/test/mocks/chat.mock.js
index b8fd259..f039138 100644
--- a/test/mocks/chat.mock.js
+++ b/test/mocks/chat.mock.js
@@ -548,4 +548,36 @@ addInteractionHandler('post test-summary with metadata to chat', () => {
status: 200
}
}
+});
+
+addInteractionHandler('post test-summary with ci-info to chat', () => {
+ return {
+ request: {
+ method: 'POST',
+ path: '/message',
+ body: {
+ "cards": [
+ {
+ "sections": [
+ {
+ "@DATA:TEMPLATE@": "CHAT_RESULT_SINGLE_SUITE"
+ },
+ {
+ "widgets": [
+ {
+ "textParagraph": {
+ "text": "Repository: org/repo | Branch: /feature-test
Build: Build #number-123 | Download Logs"
+ }
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ },
+ response: {
+ status: 200
+ }
+ }
});
\ No newline at end of file
diff --git a/test/mocks/slack.mock.js b/test/mocks/slack.mock.js
index 67a5afe..ce42c68 100644
--- a/test/mocks/slack.mock.js
+++ b/test/mocks/slack.mock.js
@@ -631,7 +631,7 @@ addInteractionHandler('post test-summary with ci-info to slack', () => {
"type": "section",
"text": {
"type": "mrkdwn",
- "text": "*Repository:* | *Branch:* /feature-test\n"
+ "text": "*Repository:* | *Pull Request:* \n*Build:* "
}
}
]
diff --git a/test/mocks/teams.mock.js b/test/mocks/teams.mock.js
index 1673f93..7ff965d 100644
--- a/test/mocks/teams.mock.js
+++ b/test/mocks/teams.mock.js
@@ -1556,7 +1556,7 @@ addInteractionHandler('post test-summary with ci-info to teams', () => {
},
{
"type": "TextBlock",
- "text": "**Repository:** [test/test](https://github.com/test/test) | **Branch:** /feature-test\n\n[Build #number-123](https://github.com/test/test/commit/sha/checks/id-123)",
+ "text": "**Repository:** [test/test](https://github.com/test/test) | **Branch:** [/feature-test](https://github.com/test/test/tree/feature-test)\n\n**Build:** [Build #number-123](https://github.com/test/test/actions/runs/id-123)",
"wrap": true,
"separator": true
}