Jenkins github username password login - github

I have installed Jenkins ver. 1.653 on OSX 10.11.3 using standard installer and added git plugin. I tried to create job for public project from github and it works. Now I am trying to create job for private repo using username and password but it always fails. This is log:
Started by user anonymous
Building in workspace /Users/Shared/Jenkins/Home/workspace/MyProject
git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
git config remote.origin.url https://github.com/myproject/myproject-android.git # timeout=10
Fetching upstream changes from https://github.com/myproject/myproject-android.git
git --version # timeout=10
using .gitcredentials to set credentials
git config --local credential.username vandzi # timeout=10
git config --local credential.helper store --file=/Users/Shared/Jenkins/tmp/git428140271294555744.credentials # timeout=10
git -c core.askpass=true fetch --tags --progress https://github.com/myproject/myproject-android.git +refs/heads/:refs/remotes/origin/
ERROR: Timeout after 10 minutes
git config --local --remove-section credential # timeout=10
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://github.com/myproject/myproject-android.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:766)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1022)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1053)
at hudson.scm.SCM.checkout(SCM.java:485)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1269)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:607)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
at hudson.model.Run.execute(Run.java:1738)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Caused by: hudson.plugins.git.GitException: Command "git -c core.askpass=true fetch --tags --progress https://github.com/myproject/myproject-android.git +refs/heads/:refs/remotes/origin/" returned status code 143:
stdout:
stderr:
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1719)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1463)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:63)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:314)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:764)
... 11 more
ERROR: null
Finished: FAILURE
Any idea what can be problem?

Also had ERROR: null in the end, for me it was timeout issue. You can increase timeout for cloning and checkout like this:
Go to job configuration and find git section
Add -> Advanced clone behaviours. There you can specify timeout and check 'shallow copy' (which is faster)
Add -> Advanced checkout behaviours. You can set time out for checkout.

Related

Why cant I upload any new project to GitHub?

I have been going at the endlessly all semester. I was able to add project from my prior year in school but have been unable to push and new projects to my repository.
I have tried deleting my key credentials via my key access chain.
I have created a new GitHub account and tried using that one.
I have deleted repositories started from scratch over and over.
I have read question on question and tried following multiple different answers on here.
What I wouldn't give to understand what is going on and why nothing seems to allow me to push a project anymore.
The most current attempt was going back to my original GitHub account.
I created a brand new repository.
I created a new folder and copied my simple python project into it and saved.
error: remote origin already exists.
(base) stephaniebrandon#Stephanies-MacBook-Pro-2 pythonGame % git remote rm origin
(base) stephaniebrandon#Stephanies-MacBook-Pro-2 pythonGame % git remote rm upstream
error: No such remote: 'upstream'
(base) stephaniebrandon#Stephanies-MacBook-Pro-2 pythonGame % git remote add origin https://github.com/stephanieBrandon/GuessARandomNumberGame.git
(base) stephaniebrandon#Stephanies-MacBook-Pro-2 pythonGame % git push -u origin main
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/stephanieBrandon/GuessARandomNumberGame.git'
(base) stephaniebrandon#Stephanies-MacBook-Pro-2 pythonGame % ls -a
. .. guess_a_random_number.py
(base) stephaniebrandon#Stephanies-MacBook-Pro-2 pythonGame % git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in /Users/stephaniebrandon/Documents/GitHubPortfolio/Python/GuessARandomNumberGame/pythonGame/.git/
(base) stephaniebrandon#Stephanies-MacBook-Pro-2 pythonGame % git remote add origin https://github.com/stephanieBrandon/GuessARandomNumberGame.git
(base) stephaniebrandon#Stephanies-MacBook-Pro-2 pythonGame % git push -u origin main
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/stephanieBrandon/GuessARandomNumberGame.git'
(base) stephaniebrandon#Stephanies-MacBook-Pro-2 pythonGame % ls -a
. .. .git guess_a_random_number.py
(base) stephaniebrandon#Stephanies-MacBook-Pro-2 pythonGame % git status
On branch master
I am hoping there is just some simple thing I am missing, if someone could explain and help me out it would be much appreciated.
Stephanie, your local branch name is "master", not "main" as you can see from the "git status" output.
If you try "git push origin master", it should work.
You dont have branch main, you have branch master. 😊
Try:
git push origin master
You need to have some commits before pushing your repository to Github.
Moreover, your local default branch name is master, so you have to use git push -u origin master instead of git push -u origin main
$ ls
guess_a_random_number.py
$ git init
Initialized empty Git repository in /Users/stephaniebrandon/Documents/GitHubPortfolio/Python/GuessARandomNumberGame/pythonGame/.git/
$ git add .
$ git commit -m "initial commit"
$ git remote add origin https://github.com/stephanieBrandon/GuessARandomNumberGame.git
$ git push -u origin master # not main

Error failed to push some refs to git commit

I'm trying to upload a navbar file to git, but it keeps saying that some references couldn't be pushed, and I don't know where I'm going wrong.
PS E:\navbar> git init
Initialized empty Git repository in E:/navbar/.git/
PS E:\navbar> git add README.md
fatal: pathspec 'README.md' did not match any files
PS E:\navbar> git commit -m "first commit"
Author identity unknown
*** Please tell me who you are.
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got '신은영#DESKTOP-0T69V65.(no
PS E:\navbar> git remote add origin https://github.com/kimdohyeon0811/learnit
PS E:\navbar> git push -u origin main
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/kimdohyeon0811/learnit'
PS E:\navbar> git remote -v
origin https://github.com/kimdohyeon0811/learn_css.git (fetch)
origin https://github.com/kimdohyeon0811/learn_css.git (push)
PS E:\navbar> git push origin master
error: src refspec master does not match any
error: failed to push some refs to 'https://github.com/kimdohyeon0811/learn_css.git'
PS E:\navbar>
You have two separate problems here, and they're related. The first is that you've failed to configure your the name and email used in your commits, and so Git is refusing to commit any changes. The second is that because you have no commits in your repository, trying to push the branch main or master doesn't work, because it doesn't exist. That's the message that you're getting when you see “src refspec…does not match any.”
You need to configure your name and email, which are stored in user.name and user.email. Note that user.name is a personal name, not a username. So, for example, someone might run these commands:
$ git config --global user.name "Pat Doe"
$ git config --global user.email pdoe#example.com
Then, once you've made those changes, you can commit and it should succeed. Once you have commits, you can push them.
Note that if you want to use main as the default branch but your repository is using master, you can run git branch -m main and that will rename the branch. If you want to do that, do it before you push.

How to add/update files in git repository from Azure DevOps Pipeline Dynamics 365 CE

Short Version
When a build pipeline is triggered, one of the build pipeline task will get the latest files and it has to be added/updated in the git repository of current running pipeline. I tried to do it by using command line task but its failing as not git repository
fatal: not a git repository (or any of the parent directories): .git
Long Version
I m tried to achieve solution pack and unpack process for dynamics 365 instance. So the build pipeline have the following tasks
Export solution from Dynamics 365 and store it in $(build.binariesdirectory)
Unpack the solution zip file and store in $(Build.Repository.LocalPath) i.e., adding/updating existing files
Command line task to commit and push the files to current pipeline repository
ECHO "Setting git config..."
git config --global user.email "xxx#xyz.com"
git config --global user.name "Admin"
ECHO "CHECK GIT STATUS..."
git status
ECHO "GIT ADD..."
git add -A
ECHO "CHECK GIT STATUS..."
git status
ECHO "Commiting the changes..."
git commit -m "Latest Customizations updated"
ECHO "Pushing the changes..."
git push -u origin master
ECHO "Customization Committed Successfully"
Updated
If a pipeline is created with 2 command line task i.e. one to create a random file in the Build.Sourcedirectory and another to commit the changes, then the git commit and push commands are working.
But if we add other tasks (such as unzip files in Build.Sourcedirectory directory) before the command line task then getting error as not a repository.
If you see the below screenshot, in the checkout phase the git repo is cloned to D:\a\1\s
And below screenshot is from command line task, where the current working directory is same as the checkout task (i.e., D:\a\1\s) and we can see that the ".git" folder is present so the current directory has local repository in it, but still getting error as fatal: not a git repository
Am I missing anything here?
By default the source files are checked out to the Build.SourcesDirectory (e.g : Directory: D:\a\1\s), it can be considered as a temporary git repository.
According to the error message, it appears that the working directory of the command line task is not under the Build.SourcesDirectory and you did't git checkout again to that working directory.
So, please try unpack the solution zip file and store in Build.SourcesDirectory, then run below Command line to push the commits (it works for me):
ECHO "Setting git config..."
git config --global user.email "xxx#xyz.com"
git config --global user.name "Admin"
ECHO "CHECK GIT STATUS..."
git status
git checkout -b master
ECHO "GIT ADD..."
git add -A
ECHO "CHECK GIT STATUS..."
git status
ECHO "Commiting the changes..."
git commit -m "Latest Customizations updated"
ECHO "Pushing the changes..."
git push -u origin master
ECHO "Customization Committed Successfully"
Please note that you need to Grant version control permissions to the build service and enable Allow scripts to access the system token.

Modifying a github public repository from a travis build

In the build of my first public repository https://github.com/yafred/test-push/ I try to modify my second repository https://github.com/yafred/test
1/ I am using the same personal access token with scope repo (GH_TOKEN) that I'm using to deploy releases.
2/ The commands I am executing from the .travis.yml are
language: generic
script:
- git clone https://github.com/yafred/test.git
- cd test
- echo "hello" > test.txt
- git add .
- git -c user.name='travis' -c user.email='travis' commit -m refresh
- git push -f -q https://{$GH_TOKEN}#github.com/yafred/test master
I have tried a few variations in the commands based on my searches but I keep getting an authentication error
0K$ git push -f -q https://{$GH_TOKEN}#github.com/yafred/test master
remote: Invalid username or password.
fatal: Authentication failed for 'https://{[secure]}#github.com/yafred/test/'
Is it at all possible ?
What am I doing wrong ?

Jenkins integration with Github plugin for Private repository

I have installed Jenkins in an Azure VM.
Version - 1.651.2
Path to Git :
Installed Plugins :
Credentials Plugin - 2.0.7
Git Hub Credentials Plugin - 0.24
Git Hub Plugin - 1.19.1
SSH Credentials Plugin - 1.12
In the repo Url tried both https and ssh with username/password and ssh/private key aswell, still unable to pull from git server.
Console Output :
Started by user anonymous
Building in workspace C:\Program Files (x86)\Jenkins\workspace\Staging Build
[WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Done
Cloning the remote Git repository
Cloning repository https://github.com/--/--.git
C:\Program Files\Git\bin\git.exe init C:\Program Files (x86)\Jenkins\workspace\Staging Build # timeout=10
Fetching upstream changes from https://github.com/---/---.git
C:\Program Files\Git\bin\git.exe --version # timeout=10
using GIT_SSH to set credentials
using .gitcredentials to set credentials
C:\Program Files\Git\bin\git.exe config --local credential.username jenkins # timeout=10
C:\Program Files\Git\bin\git.exe config --local credential.helper store --file=\"C:\Windows\TEMP\git7879671492423343442.credentials\" # timeout=10
C:\Program Files\Git\bin\git.exe -c core.askpass=true fetch --tags --progress https://github.com/---/---.git +refs/heads/*:refs/remotes/origin/* # timeout=2
ERROR: Timeout after 2 minutes
C:\Program Files\Git\bin\git.exe config --local --remove-section credential # timeout=10
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "C:\Program Files\Git\bin\git.exe -c core.askpass=true fetch --tags --progress https://github.com/---/---.git +refs/heads/*:refs/remotes/origin/*" returned status code -1:
stdout:
stderr:
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1719)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1463)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:63)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:314)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:506)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1057)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1097)
at hudson.scm.SCM.checkout(SCM.java:485)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1269)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:607)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
at hudson.model.Run.execute(Run.java:1738)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
ERROR: null
Finished: FAILURE
Note: https://github.com/--/--.git
I have replace my repo names with --- for security purpose and I have checked urls don't mismatch.
What is going wrong here?
EDIT :
I am able to clone from gitbash successfully using both ssh and https url.
Added deploy keys in github repo aswell.