Run build after every commit to git repository at buildbot - buildbot

I'd like to run build after every commit to git repository. I've set-upped GitPoller, which monitors my git repository on new commits and informs me about it, but I couldn't find how to do some action on this event. Maybe I have to use other buildbot functionality to do it?
Thank you in advance!

The GitPoller generates "change" events automatically. What you need is a Scheduler to watch for those change events and kick off builds for them.

Related

GitHub Actions not creating files when it's in a subdirectory

I'm trying to learn how to use GitHub Actions and I'm running into a small issue. When I run the code locally, the files created while python training/train.py is running are created in the correct folder. However, when I try to do the same thing with GitHub Actions, the files are only created when I choose to create them in the root directory rather than /training/outputs/. Is there a way to resolve this?
Here's my GitHub repository: https://github.com/JayThibs/github-actions-ml-template
I've figured out how to resolve this so I figured I should share here.
Since I am using CML (Continuous Machine Learning), I could simply include the following line in my GitHub Actions cml.yaml file:
cml-pr training/outputs/*
This is because cml does not push outputs to my code automatically.
Besides using cml-pr, you can also use the following github push manually:
git config --local user.email "action#github.com"
git config --local user.name "GitHub Action"
git add training/outputs/*
git commit --message "Commit training outputs"
git push
Please keep in mind that the latter solution won't handle merge conflicts gracefully if there is a race condition between several simultaneous runs.
Since the action will push files to your repository, it will trigger another GitHub Action if your action is triggered on push. To resolve this, simply add something like [skip ci] in your commit message and GitHub will prevent an action to be triggered. You can learn more about it here: https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/
0x2b3bfa0 on GitHub helped me resolve this issue, you can find our conversation here: https://github.com/iterative/cml/issues/658

How to push without accepting changes to github

What command do I use to push my code to github through VSCode command line? It is making me pull first, but I don't want to accept any incoming changes.
Maybe that's happening because your current branch (assuming it is main or master) is outdated and wants to update itself first.
There are some ways you can do this:
Using Git in the command line (recommended, easiest way).
Using Visual Studio Code UI.
Using Git in the command line
Say, the current branch you're working on is named updates.
We can use the following command to push to GitHub:
git push origin updates:updates
That will push your changes remotely (GitHub).
You might wonder why updates:updates:
The first one is the name of the local branch, the second one is the name of the remote branch.
After that, your changes will be pushed to GitHub in the branch updates.
If your branch isn't available remotely yet, it will create a new branch named updates with the same commits and changes in the local branch updates. 🙂
Using Visual Studio Code UI
First make sure you're on the correct local branch. You can change branches by clicking on the name of the current branch you're on on the bottom at the left.
Next, go to the Source Control (Ctrl+Shift+G), then click on the ..., then Push.
Your changes will be pushed to GitHub now with the same local branch name.
Hope this answer is useful to you. 🙂

github API code repository state after each commit

Is there any way to have the full source code repo after each commit?
I mean for example using
https://api.github.com/repos/highcharts/highcharts/commits
would give me a list of commits, but I want to realize what was the effect of that commit to whole repo (I want to check whether any code duplication is added to whole project or not using some automatic tools). Is that possible?
I want to see the code effect, so having repo even after merging each commit would be fine.
Simply implement a listener to a webhook (see "Creating a Webhook"). Set it up to ball your listener at each push event.
You can then do a pull when called by the webhook, and get a fresh updated copy of the repo locally.
For other repos you don't have any control or whose owner is in your team, that webhook approach is not possible.
You would need to implement a scheduled polling approach, through a regular cron job for instance.
That would possible multiple commits, so you need to wrap that pull with a git log as in here.
git checkout master
git fetch
refs=$(git log --format='%H' ..origin/master)
for ref in ${refs}; do
# do your analysis commit by commit
done
git merge origin/master

Passing parameters from github to Jenkins on push

We use an internally hosted github server for our SCM, Jenkins for our CI and Git-Flow (via maven's jgitflow plugin) for our branching strategy.
I have a Jenkins build job set up such that it takes the git branch as a parameter and then can check-out and build the correct branch based on what was selected.
.....
.....
.....
What I would like - is to automatically trigger the BASE_JOB to build only the branch that's been pushed. So far, I have been unable to find any way to do this.
If I set up to build when changes are pushed to github, then the job will simply rebuild whatever the last built branch was regardless of the branch that's been pushed.
I've seen some plugins for Jenkins that will auto-generate template jobs when new branches are created - but I think it is over-kill to necessitate having a job per currently active branch.
Is there a way to pass a branch parameter to the "Build when a change is pushed to GitHub"? Or some other way to work around this apparent limitation?
Thanks!
Check with these settings and see if it works.

How to clone a project and stay tuned with new updates

I want to clone POX Controller from Github repository into my laptop. The only way I know is by cloning. However, I think if someone clone a project, he/she won't get the updates that the others have done in it. I have read about forking but I don't really understand the difference between fork and clone. So how do I get a project from Github and still be able to receive updates?
Thank you.
To clone a repository means that you will download the whole code of the repository to your laptop.
A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project.
Most commonly, forks are used to either propose changes to someone else's project or to use someone else's project as a starting point for your own idea. More at Fork A Repo.
as #TimBiegeleisen says, you can get the project and stay updated by clone once then git fetch it periodically.
For example, if you want to cloning POX Controller, clone it:
git clone https://github.com/noxrepo/pox
Then to update it, do the following command on your cloned project:
cd pox // go to your clone project
git fetch
Or you can use git pull instead of git fetch if only need to stay update without keeping your change in the cloned project.
But you must remember the difference between git fetch and git pull. #GregHewgill answers explain it in details:
In the simplest terms, git pull does a git fetch followed by a git merge.
You can do a git fetch at any time to update your remote-tracking branches under refs/remotes/<remote>/. This operation never changes any of your own local branches under refs/heads, and is safe to do without changing your working copy. I have even heard of people running git fetch periodically in a cron job in the background (although I wouldn't recommend doing this).
A git pull is what you would do to bring a local branch up-to-date with its remote version, while also updating your other remote-tracking branches.
Git documentation: git pull