Is there any way to send release pipeline data to GIT repo in devops? - azure

Is there any task or something which will send the release pipeline data to git repo instead of sending it to any evironment?

You need to use the Invoke HTTP REST API task to call github api and create a file there.

No, there is not.
The only way you could do is running git commands in a release to git push files/data.
How to do this, you could refer below links:
Executing git commands inside a build job in Visual Studio Team Services (was VSO)
Run Git commands in a script

Related

How to publish to another git after build using jenkins

I have a private repo and want to publish the build artifacts to another public repo (it's the packaged application)
How can I do that in jenkins? I could only find publish on the git I've used to build.
Thanks
There are multiple ways to do this:
- Using a shell script that calls the GIT command line tool. This can be a post-build script, the same script compiling the code, etc.
- Same thing in groovy
- Call a downstream job to do that for you (probably the best solution IMHO)
The main problem would be the GIT credentials, but that is not an big issue...

How do I keep a git clone updated?

I am developing a project on my laptop that is to be implemented on my VPS. I am continually making updates on my laptop and pushing them to my git repo, but I am in the dark on how I should keep the clone I made on my server, updated.
When I try to run git clone <url> in my directory, it tells me 'file already exists!' or something along those lines. Do I just delete the entire folder and reclone the repo like that? Or is there a way, other than initiating the directory as git, and creating an upstream, that I can reclone without having to delete everything first?
How do I keep a git clone updated?
I generally clone git project.
git clone git#source.golabs.io:mobile/project-name.git
and after that I start developing my feature by creating new branch branch.
so for up to date with remote project you need to checkout to master branch. and just do
git pull and sync your project using ./gradlew clean build
If your project have submodules- you need to do
git submodule update --init --remote --recursive
try to use git pull. it will automaticly analyze the difference .And try to fix it
Instead of having to go to your server and pulling, you could setup a listener in order to do the pull for you.
For instance, if you are ushing to GitHub or BitBucket or GitLab, you can setup a webhook (GitHub webhook, BitBucket webhook, GitLab webhook), and a local listener in order detect the push, and triggger a git -C /path/to/your/repo pull.

Execute a script after every git push

There is a server running and has a git instance on it. I want a script to run everytime a user does git push to the server. I want my script to be executed then git push to continue.
Any work arounds?
You've tagged this GitHub so I'm assuming that you are referring to public GitHub and not GitHub enterprise.
You cannot run a script "server-side" on GitHub's servers because that would obviously be a massive vulnerability but you can set up a web hook to trigger a script on another server.
Basically whenever someone does a push, a specific URL will be sent data about the push. You can then trigger a script from this. For more information on web hooks, see the GitHub API docs.
I am not sure If you want a scipt to run prior to push or after. So here is my answer for pre-push. But if you want post-push (i.e after push) you have to change the pre-push hooks accordingly to check if pushed successfully and then you can do post push thing.
As suggested by #Travis, git hooks is the one that you are looking for. So to execute a script pre-push, you have to do is to create a pre-push file in the .git/hooks. So in this case put your bunch of code in the pre-post script file .git/hooks/pre-push and save it. Then make it executable by chmod +x .git/hooks/pre-push. After you done with this successfully you will be able to see the script gets executed each time you do run push command.
PS: Please note that I haven't tested this whole but expected to work in this way.
In Short, assuming you(Linux user) are in the project directory
vim .git/hooks/pre-push # then add your code and save the file
# Also put the shebang on top to identify the interpreter
chmod +x .git/hooks/pre-push # make it executable
You should look into git hooks:
8.3 Customizing Git - Git Hooks
and, another site regarding this technology:
githooks.com

Automatically Sync Local Github Repository with Directory on Server

I have been attempting to use hooks to automatically pull the updated repo from github to my remote web server. This is the code on the post-receive hook:
cd /home/[my username]/document_root/[github repo name]/
git pull origin master
I expect this to run when there is a new commit from my development machine that syncs with the one on github, but it doesn't update the files inside of that repo directory. Any help is appreciated, but I am new to using git and github in general.
EDIT: I tried to follow this tutorial but it still doesn't work.
http://ryanflorence.com/deploying-websites-with-a-tiny-git-hook/
You can push git post-hook to Github. Instead, you can use Github's Webhooks
you can customize a schedule with crontab.
for example, crontab -e , and input
5 * * * snyc_git.sh
Then it will snyc your respository.

Git - Syncing a Github repo with a local one?

First off, forgive me if this is a duplicate question. I don't know anything but the basic terminology, and it's difficult to find an answer just using laymen's terms.
I made a project, and I made a repository on Github. I've been able to work with that and upload stuff to it for some time, on Windows. The Github Windows application is nice, but I wish there was a GUI for the Linux git.
I want to be able to download the source for this project, and be able to edit it on my Linux machine, and be able to do git commit -m 'durrhurr' and have it upload it to the master repository.
Forgive me if you've already done most of this:
The first step is to set up your ssh keys if you are trying to go through ssh, if you are going through https you can skip this step. Detailed instructions are provided at https://help.github.com/articles/generating-ssh-keys
The next step is to make a local clone of the repository. Using the command line it will be git clone <url> The url you should be able to find on your github page.
After that you should be able to commit and push over the command line using git commit -am "commit message" and git push
You can use SmartGit for a GUI for git on Linux: http://www.syntevo.com/smartgit/index.html
But learning git first on the command line is generally a good idea:
Below are some basic examples assuming you are only working from the master branch:
Example for starting a local repo based on what you have from github:
git clone https://github.com/sampson-chen/sack.git
To see the status of the repo, do:
git status
Example for syncing your local repo to more recent changes on github:
git pull
Example for adding new or modified files to a "stage" for commit
git add /path/file1 /path/file2
Think of the stage as the files that you explicitly tell git to keep track of for revision control. git will see the all the files in the repo (and changes to tracked files), but it will only do work on the files that you add to a stage to be committed.
Example for committing the files in your "stage"
git commit
Example for pushing your local repo (whatever you have committed to your local repo) to github
git push
What you need to do is clone your git repository. From terminal cd to the directory you want the project in and do
git clone https://github.com/[username]/[repository].git
Remember not to use sudo as you will mess up the remote permissions.
You then need to commit any changes locally, i.e your git commit -m and then you can do.
git push
This will update the remote repository.
Lastly if you need to update your local project cd to the required directory and then:
git pull
To start working on the project in linux, clone the repo to linux machine. Add the ssh public key to github. Add your username and email to git-config.
For GUI you can use gitg.
PS : Get used to git cli, It is worth to spend time on it.

Resources