Skip to content

Instantly share code, notes, and snippets.

@TRahulSam1997
Last active November 17, 2020 01:44
Show Gist options
  • Save TRahulSam1997/8714a6bd2772ee1c55f5bdffbb510384 to your computer and use it in GitHub Desktop.
Save TRahulSam1997/8714a6bd2772ee1c55f5bdffbb510384 to your computer and use it in GitHub Desktop.
function postToJenkins(payload, jenkinsTargetUrl, token, basicAuth, XGithubDelivery) {
let data = new FormData();
data.append('payload', `${JSON.stringify(payload)}`);
let config = {
method: 'post',
url: `${jenkinsTargetUrl}buildWithParameters?token=${token}`,
headers: {
'X-Github-Delivery': `${XGithubDelivery}`,
'X-Github-Event': 'pull_request',
'Authorization': `Basic ${basicAuth}`,
...data.getHeaders()
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment