Can I save a list of reviewers in Gerrit? - gerrit

Gerrit 2.13.8-4-gb79a18cfff-dirty
I just joined a new project.
Every time I push committed code to Gerrit I need to manually feed it a list of reviewers for my ticket/issue.
Is there any way I can save this list in Gerrit or does the owner of the project need to do that ( how? )
Thanks.

A solution would be to have the reviewers plugin installed/configured in your Gerrit server. Only the Gerrit administrators can do that.
See more info about Gerrit plugins here.
See more info about the reviewers plugin here.

Yes, you can set push options in your Git configuration to automatically add reviewers for every push. For example, to add john.doe as reviewer for every change pushed from this repository:
git config --local --add push.pushOption r=john.doe
The above approach requires Git 2.16+, though. See also Can I set push-options (git push -o “…”) in git config?.
If you are still on an older Git version locally, you could pass the option via a Bash or Git alias or even use the old syntax for push options, e.g.:
alias gpr 'git push origin HEAD:refs/for/master%r=john.doe'

Related

Jenkins git plugin query

With Jenkins git plugin, you have options for branch, url and credentials. How do I pass the revision (SHA1), in order to checkout a particular revision of the branch?
https://wiki.jenkins.io/display/JENKINS/Git+Plugin
Thanks.
In general, you can't. The plugin will always fetch and check out references, not commits.
Fetching specific commits by SHA1 is a relatively new feature (see Retrieve specific commit from a remote Git repository); it is not even support by all repository servers.
If you're sure that the SHA1 exists on the branch that has been fetched, then you're free to git reset the working copy in a build step. However, you'd mess with a git clone that's maintained by the git plugin -- so I recommend to take care of the entire clone/fetch/checkout step yourself, not using the git plugin.

Jira: assign an existing git branch to an issue

In JIRA connected with STASH you can create a feature branch for an issue using the button 'create branch'. (That is nice to track the commits in this issue.)
If a developer started working but did not know that there is such an issue he did not click the 'create branch'.
Is there any possibility to assign an existing git branch to an issue?
ex-Stash developer here.
Yes and no. Creating the branch though the UI is just a convenience. The important thing is that the name contains the JIRA key. If only one developer is working on the branch, it's fairly easy to just rename (delete + add) a branch with the appropriate name.
git checkout old-branch
git push -u origin old-branch:JIRAKEY-1234-something
git push origin :old-branch
Does that help?
Update
As for january 2017 if you have an already exiting branch and you want to attach it to a Jira Issue you can do the following:
Checkout to the branch you want to rename
Execute the following command
git branch -m JIRA_ISSUE_ID-Whatever
Assuming that mine Jira issue is SO-01 I can do the following:
git branch -m SO-01-Whatever
This will change the name locally, push it to remote with:
git push origin :old_name
Command Syntax
git branch (-m | -M) [<oldbranch>] <newbranch>
Related question for more info
This is no longer the case. With a common setup between bitbucket and Jira, simply including the issue ID in the commit message will create a link between the commit, and thus the branch, and the issue in Jira.
I just tested the theory that having the Jira ID in the branch name creates an automatic link.
It does.
To see the effect, you have to push a commit. Then the branch will show up in the Jira.
The branch shows up in Jira, but to get an individual commit to show up in Jira I have to refer to the Jira ID in the commit message.
The web interface option is to branch off a branch but merge back to master in the pull request.
eg:
click create branch in jira
set the repo, branch type and name to what you want
set the branch from to be the existing branch
click create
when creating a pull request set the destination branch to what you want eg master
If you include the JIRA-ID in the branch name, by creating out of an existing commit, all you have to do is:
git push --set-upstream origin <new-branch-name>
and the branch is attached to the JIRA ticket.
Just add a new commit with the Jira issue key in the commit message

Gerrit does not trigger my jenkins job

I have installed Gerrit 2.8 and configured it with two users (my local developer machine and jenkins) and imported an existing repository based on this guide:
https://review.openstack.org/Documentation/install-quick.html
I have cloned the gerrit repo with:
git clone ssh://user#gerrit-test:29418/repo_test
committed some changes and pushed them to gerrit with:
git push origin HEAD:refs/for/master
I see the changes in the gerrit web UI. I have then installed:
https://wiki.jenkins-ci.org/display/JENKINS/Gerrit+Trigger
and configured a maven job based on the above instructions:
And:
But when I push a change to gerrit the job is not triggered. I can trigger the changes manually from the Query and Trigger Gerrit Patches page though.
Any suggestions?
Does the user have the Stream Events permission?
Ensure that you set "Submit Type" as "Fast Forward Only" in your Gerrit Project Options.

not to create new commit-id on gerrit

I use two gerrit now.
When I push the code, I used to this.
git add
git commit -m "Update OOOO module, fix the bug A1-09000"
git push origin HEAD:refs/for/master
-----modify sth.
git add src/editedfile.c
git commit --amend
git push origin HEAD:refs/for/master
The problem is, it works only for a gerrit A. The other gerrit B always create a new commit-id. So I couldn't push changes for a new patch set.
I tried to put this.
scp -p -P 29417 id#gerritUrl:hooks/commit-msg .git/hooks
Problems on gerrit A
Create patch set is ok. But always asking a gerrit password on push. Even I register ssh key.
Problems on gerrit B
Can not create a patch set. but it does not ask password.
For me, more important proejct is on the gerrit B. So I need to push the new patch set. What is the problem of this?
After git commit check the commit message itself by git log. the changeId should be placed in the commit msg. I think the first commit did not contain changeId either. You can deny commits without changeId - it can be set in the project admin page. Also check the content of the downloaded hook in .git/hooks. commit-msg should have a header in the beginning. For the first problem, can you ssh into gerrit A without password? this behavior only happens at push?

Need some basic github help

I am trying to learn github to deploy a webpage. Here are the steps I am taking:
git checkout master
git pull origin master
git checkout –b my-awesome-branch
Do some work, do a git status to check on everything, everything is ok.
git add .
git commit –m "awesome message here"
git push origin my-awesome-branch
git checkout integration
git merge my-awesome-branch
git push origin integration
cap development deploy
this will push a file to the dev server we have so people can look at it - this worked fine for me you won't be able to see the link but it generates something like this:
http://dev.mywebsite.com/events/email/welcome
Let's go live (pretending there are no further changes)
git checkout master
git merge my-awesome-branch
git push origin master
cap production deploy
In theory, the file should push to the live website (which would be http://mywebsite.com/events/email/welcome) but that webpage is not created when i cap production deploy.
Another developer more familiar with this system says :
It looks like you forked "my party events" repo and have pushed the
master there. You'll want to push master to the upstream remote (the
main "my party events", or my_events repo.)
I don't follow this step. Can anyone follow this logic? If so, do you have a suggestion for me on what i may be doing wrong? Any help is appreciated.
If you have a forked branch on Github, that means you have a copy of the entire git repo under your name. Check your Github account to verify this.
To do this, go to https://github.com/your-github-user-name-here. On the left side, look for "my-party-events" (assuming that's the repo name). Underneath it, look for "forked from xyz/my-party-events".
If you don't see 'forked from ...', then you're the original owner of that repo. This shouldn't be the case.
If you do see 'forked from ...', then you have a copy under your name (that's what a fork is). Any changes you make to a fork don't affect the original repo.
If you're with me up to here, there's 2 ways you can go.
Via Git (Recommended)
Whenever you did a git pull or git push earlier, you were specifying origin, which is a human-readable name for a repo that you set up earlier. The repo address actually looks like this
git#github.com:your-user-name/project-name.git
As you can see, referring to it by a nickname like 'origin' is way easier to remember.
Assuming you have write access to the main project repo, you can just add another repo to your config. Make sure you have write access before attempting this, otherwise you're just wasting your time. Ask your coworker if you're not sure.
Lets say you wanted to nickname the repo as 'production', you would do this
git remote add production git#github.com:PROJECT_OWNER/project-name.git
The git repo address looks almost identical to your fork repo. It differs only by username. On the front page of all Github projects, the repo address is in a text field. It's next to the "SSH | HTTPS | Git Read-only" buttons. Get the address from there, replace it in the command above, and finally, do this in your command line
git push production master
From now on, you can just git push production master, which is pretty simple. If you don't have write access, then you'll have to submit changes via pull requests.
Through the Website
You can submit a pull request to the repo you forked from. A pull request asks the original repo admin to include changes you've made on your fork.
To submit a pull request, click on your project fork from your projects page. Look for the 'Pull Request' icon near the top right. That should take you to a page where you can choose the target and source branches.

Resources