I have configured Jenkins using Gitlab OAuth configuration for authentication purpose
Gitlab API token is configured in Jenkins
Role based authentication is given for Gitlab user
Web hook configuration is done for the project in Gitlab
Jenkins init method is given like in below format
var jenkins = jenkinsapi.init('http://Gitlabuser:password#IP');
when navigate to http://Gitlabuser:password#IP link it goes to Gitlab login page
The question is
why the link navigates to gitlab login page even though Gitlab
username and password provided in link
How to handle Jenkins Init method for Gitlab OAuth configuration
please let me know if any issues in the configuration also suggest a way to achieve gitlab OAuth configuration in Jenkins
Related
Having issues creating an ssh credential in Jenkins that allows access to GitLab. I have 2 AWS instances, one with GitLab and one with Jenkins. I would like to setup a multibranch pipeline in Jenkins to run a GitLab repo. I am able to create the pipeline and can access GitLab if I use a username/password credential (using "root"/initial password) but would like to use the more secure route of using a username/SSH credential. I have generated the SSH (of the ed25519 variety) in the GitLab instance (while in root). Then, in GitLab, supplied the public key to the root user. Then, in Jenkins, provided the private SSH key and set username as "root" in a username/SSH credential. When I try to run the pipeline using the username/SSH credential I get an error indicating that it is not authorized. Should I be using a different username? Should I be generating the SSH key in a different location?
Well, I figured it was something small I was missing. I was configuring the pipeline job for the http url of the repo rather than the SSH url. Once I changed that, it worked right away.
I am using jenkins as CI server and Gitlab as Codebase both are running into two serpent docker containers.
I have created CICD pipeline into jenkins and gitlab repo. also setup webhook which working fine. Now I want to integrate jenkins from gitlab and inserted required details but it showing 401 error while test. please note entered details are verified and credentials are working.
enter image description here
enter image description here
401 indicates that the request is unauthorized. So, stated another way: your credentials are correctly set, but the credentials do not have the appropriate permission needed.
You should make sure your API keys are generated with appropriate scope and/or that the user account associated with the keys have appropriate permission.
I've followed this gitlab tutorial link, to connect my jenkins server to Gitlab.
Everyting went fine, and I've :
created a personnal access token in my GitLab profile
created a GitLab API Token using the my GitLab access token in jenkins system configuration as stated in the tutorial
create a freestyle jenkins job and Choose my GitLab connection from the dropdown
checked the Build when a change is pushed to GitLab checkbox.
checked the Accepted Merge Request Events and Closed Merge Request Events checkboxes
generated a secret token from the above freestyle project
use the freestyle jenkins project secret token to create a webhook in the GitLab project repository integration settings
Till there everything went fine.
Then I added and push code including a jenkinsFile to my GitLab repository, and get to the Jenkins WebUI to view the build status, but the pipeline shown green saying build success, while nothing happened, no code has been retrieved from GitLab (as shown in the attached console output screenshot), thus no jenkinsFile executed nor error message shown.
I tried to run the buils manually from WebUI but same result, no way to trigger my pipeline on git push events from GitLab
I thought may be I should select Git in Source Code Management section (I left it to None as the tutorial doesn't mention it) but if I choose Git as SCM I cannot select my GitLab API Token credentials, seeming like we cannot use GitLab plugin (API Token) and Git plugin for the same build project.
SO how should I proceed to be able build my jenkins project from GitLab with a jenkinsFile, using GitLab API Token?
Does the GitLab tutorial miss some useful steps?
OK, I think I understand the issue now.
There are two sets of credentials: GitLab API token for access to GitLab Webhooks and a separate one for cloning the git repo during builds.
So we can't use the GitLab API token for cloning the repository. For this you have to use either a SSH key or a Username/Password combination. Furthermore this dropdown is part of the git plugin not the gitlab plugin.
So the gitlab plugin can't tell which credentials are available as credentials for this dropdown.
I've got a webhook setup in GitLab to detect whenever changes are pushed to the project repo. This works as needed, however the URL in use contains my Jenkins credentials and I'd like to make this more secure. e.g.:
https://username:password#jenkins.url.com/project/git-project
Is there a way to generate a token of sorts in Jenkins instead of providing my username and password?
There are access tokens in GitLab, you can use it. From Jenkins part, you can install GitLab plugin and then add new credentials for SSH and GitLab API Token. Please see this and this for more details.
We configured Gitlab oauth plugin in my Jenkin server ,Now i can log with my gitlab credential in Jenkins but logout option not working once signed .
Already below issue reported in Github OAuth plugin but now this same issue in gitlab plugin too.please any one log this issue in Jenkin
https://issues.jenkins-ci.org/browse/JENKINS-16350
Because github server is not aware of your Oauth app logging out mechanism,best way to achieve it is as below;
Provide a link (refer the code snippet,to test open in a new window or tab)
Include the local logout mechanism and also logout from the github simultaneously.
Logout