Below is the code written forge ui foir jira…It is bale to trigger jenkins job remotely but when I tried from forge ui it is not working
const auth = Buffer.from(`${jenkinsUser}:${jenkinsToken}`).toString('base64');
try {
const response = await api.asUser().requestJira(buildUrl, {
method: 'POST',
headers: {
'Authorization': `Basic ${auth}`,
'Content-Type': 'application/x-www-form-urlencoded'
},
body: qs.stringify(parameters)
});
const responseData = await response.json();
console.log(`Request URL: ${buildUrl}`);
console.log(`Response: ${response.status} - ${response.statusText}`);
console.log(`Response Content: ${JSON.stringify(responseData)}`);
if (response.status >= 200 && response.status < 300) {
console.log('Jenkins job triggered successfully.');
} else {
console.log(`Failed to trigger Jenkins job: ${response.status} - ${response.statusText}`);
}
} catch (error) {
console.error('Exception occurred:', error.message);
}
};
ERROR 2024-07-02T05:24:07.826Z 6e225de8-58c1-4050-a377-17c9237cb8d6 Exception occurred: Request failed with status code 403
INFO 2024-07-02T05:38:32.148Z 6af3cecd-4c51-4462-a6d5-2c06b0ac7c2a Starting application with values: [ ‘Entity’, ‘Task Attributes’ ]
INFO 2024-07-02T05:38:32.149Z 6af3cecd-4c51-4462-a6d5-2c06b0ac7c2a Starting Jenkins job
ERROR 2024-07-02T05:38:32.150Z 6af3cecd-4c51-4462-a6d5-2c06b0ac7c2a Exception occurred: You must create your route using the ‘route’ export from ‘@forge/api’.
See https://go.atlassian.com/forge-fetch-route for more information.
PS C:\Users\kindinti.anumanthu\OneDrive - BLACKLINE\Desktop\Automation\JiraPRTesting> ^C
PS C:\Users\kindinti.anumanthu\OneDrive - BLACKLINE\Desktop\Automation\JiraPRTesting>