@docupace/pipeline 1.0.116 → 1.0.117

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docupace/pipeline",
3
- "version": "1.0.116",
3
+ "version": "1.0.117",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -83,6 +83,9 @@ function getJiraVersions(changes) {
83
83
  return versions;
84
84
  }
85
85
 
86
+ // Prevents concurrent calls for the same ticket from uploading to Canny more than once
87
+ const cannyUploadCache = new Map();
88
+
86
89
  async function getLabelIDs(labels) {
87
90
  let cannyConfig;
88
91
  try {
@@ -133,17 +136,21 @@ async function fetchNewLink(oldLink, params) {
133
136
  return;
134
137
  }
135
138
 
136
- const uploadToCannyInternal = async () => {
137
- const changes = getChanges(params);
138
- const jiraVersions = getJiraVersions(changes);
139
- const labels = getLabels(changes);
140
- const labelIDs = await getLabelIDs([...labels, ...jiraVersions]);
141
- if (labelIDs.length > 0) {
142
- const data = await uploadToCanny(releaseNote, labelIDs);
143
- return data;
144
- } else {
145
- return null;
139
+ const uploadToCannyInternal = () => {
140
+ if (!cannyUploadCache.has(mainTicketId)) {
141
+ const uploadPromise = (async () => {
142
+ const changes = getChanges(params);
143
+ const jiraVersions = getJiraVersions(changes);
144
+ const labels = getLabels(changes);
145
+ const labelIDs = await getLabelIDs([...labels, ...jiraVersions]);
146
+ if (labelIDs.length > 0) {
147
+ return uploadToCanny(releaseNote, labelIDs);
148
+ }
149
+ return null;
150
+ })();
151
+ cannyUploadCache.set(mainTicketId, uploadPromise);
146
152
  }
153
+ return cannyUploadCache.get(mainTicketId);
147
154
  };
148
155
 
149
156
  const uploadToJiraInternal = async (ticketId, url) => {
@@ -121,7 +121,7 @@ export async function deployMicroservice(
121
121
  process.env.BITBUCKET_USERNAME &&
122
122
  process.env.BITBUCKET_APP_PASSWORD
123
123
  ) {
124
- repoUrl = `https://${process.env.BITBUCKET_USERNAME}:${process.env.BITBUCKET_APP_PASSWORD}@bitbucket.org/dp-cloud/${repoName}.git`;
124
+ repoUrl = `https://${encodeURIComponent(process.env.BITBUCKET_USERNAME)}:${process.env.BITBUCKET_APP_PASSWORD}@bitbucket.org/dp-cloud/${repoName}.git`;
125
125
  } else {
126
126
  throw new Error(
127
127
  'No authentication credentials found for GitOps repository',
@@ -302,7 +302,7 @@ export async function microserviceBuildPushImage(repoName, options = {}) {
302
302
  const imageExists = await checkLocalImage(TAG_IMAGE_NAME);
303
303
  let SHA_IMAGE_NAME = '';
304
304
  if (!imageExists) {
305
- const repoUrl = `https://${process.env.BITBUCKET_USERNAME}:${process.env.BITBUCKET_APP_PASSWORD}@bitbucket.org/dp-cloud/${repoName}.git`;
305
+ const repoUrl = `https://${encodeURIComponent(process.env.BITBUCKET_USERNAME)}:${process.env.BITBUCKET_APP_PASSWORD}@bitbucket.org/dp-cloud/${repoName}.git`;
306
306
  await $`git clone --branch ${options.tag} --depth 1 ${repoUrl} ${repoName}`;
307
307
 
308
308
  console.log('Checking if directory exists...');
@@ -133,7 +133,8 @@ export const getBitbucketInfo = () => {
133
133
 
134
134
  export const getRepUrl = (repoName) => {
135
135
  const { username, password, workspace } = getBitbucketInfo();
136
- return `https://${username}:${password}@bitbucket.org/${workspace}/${repoName}.git`;
136
+ const encodedUsername = encodeURIComponent(username);
137
+ return `https://${encodedUsername}:${password}@bitbucket.org/${workspace}/${repoName}.git`;
137
138
  };
138
139
 
139
140
  export const jfRegistryUrl = 'registry.paperout.com';
@@ -63,7 +63,7 @@ async function gitCheckout(repository, destDir, branch = 'master') {
63
63
  const password = process.env.BITBUCKET_APP_PASSWORD;
64
64
 
65
65
  // Construct clone command
66
- const cloneUrl = `https://${username}:${password}@bitbucket.org/dp-cloud/${repository}.git`;
66
+ const cloneUrl = `https://${encodeURIComponent(username)}:${password}@bitbucket.org/dp-cloud/${repository}.git`;
67
67
 
68
68
  log(`Perform cloning`);
69
69
  await $`git clone --branch=${branch} --depth 1 ${cloneUrl} ${destDir}`;