I'm trying to clone a private github enterprise repository using jenkins job builder. How do I provide the username/password or API token of the github user so that jenkins can clone the directory?
Doing all this through an ansible playbook, so manually adding the git credentials to jenkins is not possible
You have to use credentials plugin for that. Here I am attaching the link to it. Feel free to explore around it. Hope this helps. If you find any trouble, comment here.
https://wiki.jenkins.io/display/JENKINS/Credentials+Plugin
Related
I am using Jenkins with my Linux box. I have two bitbucket repositories. I am trying to create a Jenkins pipeline.
Repo_A - Jekinsfile resides here.
Repo_B - Project's source code resides here.
I want Jenkins to take configurations (Jenkinsfile) from Repo_A. Also, I want Jenkins to clone my source code to /some/random/directory. The credentials are stored in Jenkins, and can be used for both repos.
How can I use multiple repos in a single pipeline? Can somebody please tell me how to do this?
You need to use ssh authentication, it is suported by Genkins
Here is similar question: how to setup ssh keys for jenkins to publish via ssh
To add new repository
So we migrated all our Gitlab projects to Bitbucket. We'd like to use the existing gitlab-ci.yml files for Bitbucket pipelines. Could we do that? If yes, could someone please give some steps to carry that out?
Thanks!
No, you can not, recently I did the same job and I wrote all the pipeline yamls from scratch. They don't behave the same.
Gitlab supports mirroring repositories between git servers, but it’s only free for public/open source repositories. Otherwise you have to be on a paid plan, regardless if you use gitlab.com or an on-premise installation. Pushing from Gitlab to another server is free, but pulling from elsewhere to Gitlab is a Premium feature. You can read more about this in the docs
Otherwise, there are open source utilities that will mirror repositories for you but they have to be configured and maintained properly. One such utility is gitlab-mirror.
I'm experiencing an issue with Bluemix DevOps continuous integration system when it comes to linking the project to an existing private Bitbucket repository.
I tried the steps presented in this link and although I'm able to see the content of the Bitbucket folder, the devOps is still stuck to the initial commit and it does not take the appropriate files during the building stage.
Can anyone provide any tips or suggestions?
Many thanks
Those instructions, although it mentions "private", are only valid for a Public repository, as you have noted without a similar style to the GitHub integration we don't have a way to setup a shared token you would need to be able to authenticate. That said today, you cannot really use a pull method to pull changes from BitBucket to DevOps Services, you will need to use a push method from somewhere that you can authenticate to your private repo and the DevOps Services git repo to keep them in sync.
https://developer.ibm.com/answers/questions/197619/continuous-delivery-with-bitbucket-and-jazzhub.html
There are lots of question on here about Permission denied (publickey) errors when using the Jenkins git plugin.
Can someone explain the authentication flow this plugin uses to check out a repository? I can't find a good description on the plugin page.
I want to just SSH into the build slave, checkout the repository there, then run my job, but clearly that is not how it works.
I guess I could add my credentials to the jenkins master, but I dont want any code there. I want it on my build slave.
Issue has nothing to do with git really. As their documentation states, it relies on git runtime which in its turn relies on system environment when it comes to secure connections. Ssh requires client to have valid key to connect and fails to that message if client does not provide one. Without any additional actions, key is not injected into environment, so client could not provide any valid key.
What you actually can use is ssh agent plugin. That allows to add key to ssh-agent on slave that will be catched up by git.
I've just setup Jenkins and i have some Repositories in my Stash.
I installed the "Git plugin" in jenkins.
I can now enter the repository url but there is nothing to enter my credentials.
It's possible using
http://username:password#mydomain/xx/yy.git
but that is something i dont want to do.
What else can i do to authenticate?
I am the author of this stash plugin that might help you: https://github.com/palantir/stashbot
Taking selectively from the readme:
To work with Jenkins, you MUST install the following jenkins plugins first.
Jenkins GIT plugin
Post build task
Next, build and install the plugin using the plugin SDK (more details in the readme)
Next, the stash admin goes into the Stashbot Admin page and creates a jenkins server config - here you give it the URL, username/password, etc details of the jenkins server.
Next, for each repository a "Stashbot CI Admin" link shows up for repo admins. From there you can check the "enabled" checkbox and tell it what branches you want build (via a regex) and what command it should run to do the build (optionally verifies and publishes).
After this point, the remainder is completely self-service. Any repo admin can ask for their project to "have CI" by filling out that form, and the jobs will automatically be created in the jenkins server.
Hope that helps.
Set up an SSH key for the user that runs your Jenkins builds and add it to the repository's SSH keys in Stash. See the Stash docs for instructions.
Two things to add to Gareth's answer.
While I agree that using SSH keys are definitely better than hard-coding the username/password, it's worth mentioning that Stash (currently) scales better with HTTP when it comes to CI. If you have quite a few builds we generally recommend using HTTP. We are currently extending our Git cache support to support SSH so this no longer an issue.
Somewhat related, you might be interested in watching and voting for the following feature which will make it easier to create CI specific keys.
Lastly having build icons show up in Stash is surprisingly handy, and you should have a look at the following plugin if you haven't already:
https://github.com/jenkinsci/stashNotifier-plugin
Since version 2.0 of "Git Plugin" for jenkins you should be able to directly add the required credentials for both ssh and username/password (based on credentials plugin).
See changelog of Git plugin: https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin#GitPlugin-Changelog for details.
For further integration of git and stash regarding pull requests you additionally need the "Stash Webhook for jenkins" add-on in stash and the "Stash Notifier" plugin for jenkins to connect each other.