Closed h2oboy closed 5 years ago
Hi @h2oboy, we currently aren't encoding the raw build parameters when creating the jenkins URL which is why the job does not build. While it would be nice to encode the whole string properly, this would break the bitbucket variable templating.
I'll look into getting this working but it's a bit trickier than I expected.
Thank you @a-hacker for looking in to this new feature/issue!. BTW Will be possible to pass JSON parameters?
@h2oboy, support for special characters has been released in version 4.0.4.
As for JSON parameters, I'm not sure what jenkins plugin you are referring to that creates JSON parameters. If you can send me a link to the plugin, I can try to see how the parameter is passed through the Jenkins rest api.
@a-hacker Thank you for your hard work :-). The Jenkins plugin that I am using is called Extended Choice Parameter plugin. You can find more details about this plugin here: https://wiki.jenkins.io/display/JENKINS/Extended+Choice+Parameter+plugin
I would like to inject some JSON paramters to to my Groovy script. Here is how the Extended Choise Parameter is used in my Jenkins Job:
This Project is parametrized -> Enable Extended Choice Parameter -> Name = GIT_BRANCH JSON Parameter Type -> Enable JSON Parameter Config Groovy Scrip
` import org.boon.Boon;
def jsonEditorOptions = Boon.fromJson(/{
disable_edit_json: true,
disable_properties: true,
no_additional_properties: true,
disable_collapse: true,
disable_array_add: true,
disable_array_delete: true,
disable_array_reorder: true,
show_errors: "always"
theme: "bootstrap2",
iconlib:"fontawesome4",
schema: {
"title": "What do you want to use to build WD?",
"oneOf": [
{
"title": "Source Branch",
"type": "object",
"properties": {
"branchType": {
"title": "Branch Name",
"type": "string",
}
}
},
{
"title": "Source Tag",
"type": "object",
"properties": {
"tagType": {
"title": "Tag Name",
"type": "string",
}
}
},
{
"title": "Prebuild Binary",
"type": "object",
"properties": {
"prebuildType": {
"title": "Component version Tag",
"type": "string",
}
}
}]
}
}/);
return jsonEditorOptions ;`
@a-hacker I tried to use the plugin and passing some special characters, but still not able to trigger the job using your plugin :-(. This is what I have on your plugin:
Build Parameters -> GIT_BRANCH="{\\"branchType\\":\\"M5\\"}\"
This is the curl sequence that I use to mimic the execution: curl -X POST -H "Jenkins-Crumb:5c40e759cca771b286a0c88931056d21" --user myuser:1197084e4d98207d89d42ca05df15e234 --data-urlencode json="{\"parameter\":[{\"name\":\"GIT_BRANCH\", \"value\":\"{\\"branchType\\":\\"M5\\"}\"}]}" "http://myjenkins.local/jenkins/job/test3/build?token=wtthothuothuththtg" -v
@h2oboy, do you know what exception is being raised in the bitbucket logs? I suspect the issue is not with special characters but with the JSON parameter type. If you were to create a dummy job with a string parameter and you passed in the same value, "{\"branchType\":\"M5\"}"
, would the jenkins job build?
Hi,
I have the following issue
I tried to trigger a simple parameterized (1 parameter) jenkins job ( details down below) and the job was not event started. I do know how to findout if the actual job build request was sent or not.
Jenkins Settings (Bitbucket)
I saved the configuration and Tested Jenkins Settings and the Connection successful!
Parameterized Builds for Jenkins (Bitbucket)
NOTE: I tried with/without the escape characters "\" on the string and it does not make any difference.
Job (Jenkins)
I created a simple freestyle job to test the communication. This job has the following parameters:
Things that I tried:
I ran the following command on the Bitbucket Server, to verify the communication between both servers (jenkins/bitbucket)
The job was executed on jenkins without any issues and I can see that the full string: {"branchType":"M56"} get displayed in Jenkins console.