Created
November 27, 2020 20:08
-
-
Save AnandShiva/2bd8973c33e4534c98bbdbae1bac1706 to your computer and use it in GitHub Desktop.
Jenkins Job with only string parameters in nodejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var axios = require('axios'); | |
var qs = require('qs'); | |
const jenkinsUrl = 'http://example_jenkins_server_url.com/job/<JOB_NAME>/buildWithParameters'; | |
// notice the url has buildWithParameters instead of build ^ | |
const userName = 'example_user'; | |
const password = 'example_pass'; | |
const jobParametersObject = { | |
'stringParam1': 'value' | |
} | |
var data = qs.stringify(jobParametersObject); | |
var config = { | |
method: 'post', | |
url: jenkinsUrl, | |
headers: { | |
Authorization: `Basic ${Buffer.from(`${userName}:${password}`).toString('base64')}`, | |
}, | |
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