Connect many Jenkins servers with different branches of the same github repo - github

I want to set up a staging server where each developer will have his own docker container running the app and Jenkins .
I want each one to be able to connect his github branch with his jenkins server with the github plugin for jenkins and create the automated build pipeline. But every branch will be in the same corporate private repository.
Push code from IDE -> Code goes on Github -> Github pushes to jenkins(in container) -> jenkins builds new code(in container) -> tester connects to container and browses the app branch
I have made 2 containers each with a jenkins server. One is connected with master branch and the other with branch1 of the same repo. But each repo allows only one implementation of the github plugin for jenkins.
Setting one new repo for every branch seems kind of silly and wasteful.
Best case scenario would be to connect many jenkins servers with the same repo but on different ports by specifying different branches.
Is something like this possible?

If those docker container can mount the same data container with the git repo in it, that means they can checkout different branches per repo.
For that, they need a recent git (2.5+) and to use the new git worktree add command.
Then those containers would work in a worktree set to a different branch per container, but all pointing to the same repo.

Related

Why does adding a repository in GitHub Desktop locally not show my pull requests

So I have a GitHub Enterprise account. On GitHub Desktop when I clone my repository from the server it goes under Enterprise and I can see the list of branches and Pull requests as shown below.
If I simply add an existing repository from my local machine onto GitHub Desktop, then it goes under Other and now I can't see the option for showing me my pull requests.
I don't want to have to reclone all my repo because that just seems silly but is there a way I can still see if there's any pull request from my repo that I simply added in from my local machine?

GitHub Actions: How to let a local server pull the change automatically from remote branch

I have the followings.
Apache server hosted on centos
GitHub (GitHub Actions)
An web app hosted on the local apache server.
Every time I make a change to a local branch and push to remote master branch in GitHub, I have to ssh into the apache server and run git pull origin master. What is the best way and how to set up an automatic pull/deployment on the local server so that it will listen and pull the change automatically?
I have read about GitHub Actions self-hosted runner and ssh solution. but I am not sure how to achieve this in the most efficient way.
You can use GitHub actions to do this by specifically using the action SFTP-Deploy which essentially copies your code from your GitHub repo and places it in your apache server directory.

Connect Github project with Gitlab

Is there a way to connect a GitLab project with Github? I mean when I push or make any modification to the Gitlab project it should be done automatically to another same copy in Github.
Is there a way to do that?
Yes there is. Gitlab offers Repository mirroring out of the box for all tiers:
Repository mirroring allows for the mirroring of repositories to and from external sources. You can use it to mirror branches, tags, and commits between repositories. It helps you use a repository outside of GitLab.
A repository mirror at GitLab updates automatically. You can also manually trigger an update at most once every five minutes on GitLab.com with the limit set by the administrator on self-managed instances.
There are two kinds of repository mirroring supported by GitLab:
Push: for mirroring a GitLab repository to another location.
Pull: for mirroring a repository from another location to GitLab.
I use this to synchronize my repos between Github and Gitlab and works fine for me

how do i automatically pull code from master to fork in azure repos using azure devOps pipeline

I was trying to pull the code from master to fork repository automatically through the azure pipeline. If any one know about this?
If you fork azure repo and want to automatically sync the Fork repo using VSTS Git, please follow below steps.
Supposed the url of original repo is https://dev.azure.com/{organization}/{project}/_git/test, and the url of forked repo is https://dev.azure.com/{organization}/{project}/_git/test_fork.
If you click "Clone" button in test repository, you will see below panel.
Clicking "Generate Git Credentials" button will show the following panel.
So we can use command git remote add upstream https://username:password#dev.azure.com/{organization}/{project}/_git/test to specify it as the upstream of test_fork repo in script.
Now creating a build pipeline using Microsoft-hosted Windows agents, setting the test_fork as the source.
Adding the Command Line task with below script.
git remote add upstream https://username:password#dev.azure.com/{organization}/{project}/_git/test
git fetch upstream
git rebase upstream/master
git push -f origin HEAD:master
Queuing a new build and it will succeed to sync the test_fork repo using VSTS Git.
You can also configure schedules for this pipeline. Now everything is done.
If you use GitHub repo, please refer to this thread for guidance.

Heroku pipeline promotion not updating github

I have a project in Github with 2 branches, [master] and [production].
I linked them with Heroku's pipeline and made it deploy automatically from [master] (but not for [production]) . So whenever my team pushes code into the master branch, the project hosted on Heroku is automatically updated and we can see the changes in the web application. Also, there is now a [Promote to production...] button available.
When I clicked this button, the [production] web application was updated with no issues, but the codes in github under the [production] branch was still the old one.
Earlier, I had changed one config file in the production branch manually (to match the production environment) so it now says [This branch is 1 commit ahead, xx commits behind master.] Maybe I have to resolve this first before I promote to production?? Can I do this in the Github UI in the browser?
Heroku integrates with GitHub to make it easy to deploy code living on GitHub to apps running on Heroku. When GitHub integration is configured for a Heroku app, Heroku can automatically build and release (if the build is successful) pushes to the specified GitHub repo.
You're seeing the correct behaviour. Heroku's GitHub Integration lets you automate Heroku deploys based on pushes to your GitHub repository. It isn't supposed to go the other way.
This is a good thing. What would you expect to happen in the case of a merge conflict?
I had an issue where my project would deploy to Heroku without issue but github would not be updated. I did this and it worked for me:
git push --set-upstream origin main