I am trying to deploy my microservice application using kops on aws through jenkins CI/CD pipeline but I am getting error authentication required
my jenkins helm chart and jenkins file
https://github.com/chuksdsilent/ci-cd-kube.git
Error
> git rev-parse --resolve-git-dir /home/ubuntu/3.80.38.55/3.80.38.55/workspace/k8-Jenkins/.git # timeout=10
> git config remote.origin.url https://github.com/chuksdsilent/ci-cd-kube.git # timeout=10
Fetching upstream changes from https://github.com/chuksdsilent/ci-cd-kube.git
> git --version # timeout=10
> git --version # 'git version 2.25.1'
using GIT_ASKPASS to set credentials github-login
> git fetch --tags --force --progress -- https://github.com/chuksdsilent/ci-cd-kube.git +refs/heads/*:refs/remotes/origin/* # timeout=10
> git rev-parse refs/remotes/origin/main^{commit} # timeout=10
> git config core.sparsecheckout # timeout=10
> git checkout -f 451949675ad9895645597a3b25d3a200ef8d1de5 # timeout=10
+ helm upgrade --install --force vprofile-stack helm/vprofilecharts --set appimage=oshabz/k8-jenkins:V9 --namespace prod
Error: Kubernetes cluster unreachable: <html><head><meta http-equiv='refresh' content='1;url=/login?from=%2Fversion'/><script>window.location.replace('/login?from=%2Fversion');</script></head><body style='background-color:white; color:white;'>
Authentication required
Related
I am trying to create a test helm chart in private gitrepo and it is not working.
Here are the Steps:
$ helm create helm-test
$ cd <private-gitrepo-dir>
$ cp -r <helm-test-dir> .
$ helm package . # I see the helm-test-<ver>.tgz
$ helm repo index --url https://github.int.privatename.com/<repo-name>
# tgz file and index.yaml are there in the directory
$ git add . && git commit -m "initial commit " && git push
# now pull the chart
$ helm repo add helm-test https://github.int.privatename.com/<repo-name>/
Error: looks like "https://github.int.privatename.com/<repo-name>/ is not a valid chart repository or cannot be reached: error converting YAML to JSON: yaml: line 182: mapping values are not allowed in this context```
Can you please help me, where is line 182?
I want to deploy ma test app from local repo to gitlab repo and with gitlab ci push it to my remote server. SSH connection is working, gitlab CI shows that job is passed, but code on remote server is not updated.
I made bare repo in: /home/repos/testDeploy.git
And folder for files is in: /home/example.com/web/testDeploy
I added
My .gitlab-ci.yml file
stages:
- deploy
deployment:
stage: deploy
environment:
name: production
url: http://www.example.com/testDeploy
only:
- master
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- chmod 600 ~/.ssh/id_rsa_gitlab && chmod 700 ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
- git remote add production ssh://user#server:port/home/repos/testDeploy.git
- git push -f production master
- echo "Deployed to production!"
Also, i have post-receive hook:
#!/bin/sh
git --git-dir=/home/repos/testDeploy.git --work-tree=/home/example.com/web/testDeploy checkout -f
I make changes in my local repo, commit and push to origin master to gitlab. Job is passed, but as I mention above, file on remote server is not update.
Output from gitlab job is:
Fetching changes...
HEAD is now at 595db67 as
Checking out 595db67b as master...
Skipping Git submodules setup
$ which ssh-agent || ( apt-get update -y && apt-get install openssh- client -y )
/usr/bin/ssh-agent
$ eval $(ssh-agent -s)
Agent pid 40589
$ chmod 600 ~/.ssh/id_rsa_gitlab && chmod 700 ~/.ssh
$ [[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
$ git branch
* (HEAD detached at 595db67)
master
production
$ git push -f production master
Everything up-to-date
$ echo "Deployed to production!"
Deployed to production!
Job succeeded
What I am doing wrong? Can you someone help me please to figure it out? Thank you for all your answers.
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.
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.
I want to sync my code to my github repo, so anytime I update my code it should be updated in the repo. Is there any proper and structured way of doing this.
So this is how I am doing it now
1
$ cd my-project
$ git init
$ git remote add origin GITHUB_URL
$ git pull origin master
$ git status
$ git add .
$ git commit -m "Init repo."
$ git push -u origin master
then just repeat following steps
$ git add .
$ git commit -m "Init repo."
$ git push -u origin master