I'm trying to configure a well-known incident management tool to perform a POST request to a Jenkins job build URL to respond to some alerts.
In this tool, for some reason I cannot put the Jenkins job build endpoint as follows:
https://<user>:<apiToken>@my-jenkins.com/blabla/job/blabla/build?token=<myTokenName>
So, the only alternative the tool provides is putting the authorization details as a header.
Before doing that, I'm trying to check if that would work, using curl. For that reason, I'm calling that Jenkins URL with the Basic auth header, with the following curl command:
curl -X POST -H 'Authorization:Basic <user:apiToken in base64>' -H 'Jenkins-Crumb:<my-crumb>' 'https://my-jenkins.com/blabla/job/blabla/build?token=<myTokenName>'
But is giving me a 401: Not authorized (Invalid password/token for user: my-user). If I place the same credentials in the URL as the first code snippet it works.
I have read the following docs: https://wiki.jenkins.io/display/JENKINS/Authenticating+scripted+clients and it seems setting the Basic auth header is pretty straight forward, but I think I'm missing something here because it doesn't work for me when I use curl.
Also I Googled a little bit and it seems everyone calls the Jenkins job build URL with the user:apiToken in the URL, but as I mentioned, the tool doesn't allow to put URLs like that.
Has anyone performed a Jenkins job launch with a basic auth header?
Any help would be appreciated. Thanks a lot!