Search code examples
jenkinscontinuous-integrationgoogle-kubernetes-enginegoogle-cloud-shell

How to consume Jenkins API Rest in Google Kubernetes Engine from external clients


I want to try out continuous deployment with Jenkins on Google Kubernetes Engine. Of course, by using the Jenkins API Rest.

I have gone through https://cloud.google.com/solutions/jenkins-on-container-engine-tutorial

I got Jenkins running. The problem is with regard to the Jenkins API Rest when I try to consume it by using Postman or curl. I'm prompted to Sign in to continue to Google Cloud Shell.

By using curl

curl -X GET https://8080-dot-3828316-dot-devshell.appspot.com/job/dev.ci/api/json\?pretty\=true --user USER:TOKEN

<a href="https://accounts.google.com/o/oauth2/auth?client_id=618104708054-jqgabbtcm3fusmhf5hu82r7j8emh7aoa.apps.googleusercontent.com&amp;redirect_uri=https%3A%2F%2Fdevshell.appspot.com%2F_cloudshellProxy%2Foauth2callback&amp;response_type=code&amp;scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&amp;state=eyJYU1JGVG9rZW4iOiJYUEljQkFETS1uVVFaMndLaF9uMjFvRUhENW86MTU4OTY3NDUzMDE3OSIsIkFwcFVSTCI6Imh0dHBzOi8vODA4MC1kb3QtMzgyODMxNi1kb3QtZGV2c2hlbGwuYXBwc3BvdC5jb20vam9iL2Rldi5jaS9hcGkvanNvbj9wcmV0dHk9dHJ1ZSJ9">Found</a>.

In Postman

enter image description here

In incognito window

enter image description here


Solution

  • My problem was related to the fact that I didn't expose the service properly. I was using the preview URL that Google provides you. So I had to follow the architecture shown here: https://cloud.google.com/solutions/jenkins-on-kubernetes-engine?fbclid=IwAR19Dl_kUSGzK1cfqyYA1s9cNt26CBnSgXf6zV104NGtIiXNtpTTKrfo3TI. I had to expose my jenkins ui as a NodePort and learn about ingress.