I want have a patch run every Monday to get the latest Android source code and have it built. It seems everything goes well except I have to help 'repo' to confirm my username and email when I get the patch run. The patch will be scheduled in midnight so I guess I have no chance to offer my help to confirm it... How could I configure repo to dismiss the step? Otherwise, is there any way to input 'enter' by bash script once the script gets prompt?
repo simply builds on top of git.
To set your name in git,
git config --global user.name "Your Name"
git config --global user.email you#example.com
I solved this problem by 'expect', here is the script looks like
expect - << EOF
exec repo init -u ssh://${USER}#<your_repo_server>/<your_manifest.git>
exepect “Your name \[Your Name\]:"
send "\r"
expect "Your Email" \[Your#email.com\]:"
send “\r"
expect "is this correct \[y/n\]?"
send "y\r"
EOF
Related
When I do
git push
I get the command prompt like
Username for 'https://github.com':
then I enter my username manually like
Username for 'https://github.com': myusername
and then I hit Enter and I get prompt for my password
Password for 'https://myusername#github.com':
I want the username to be written automatically instead of manually having to type it all the time.
i tried expect but could not use it
can anyone help me to write a shell script for it?plz:)
Well here is a very small script that would do what you want
#!/bin/expect
spawn git push origin master
expect "Username for 'https://github.com': "
send "MY_NAME_IN_GITHUB"
interact
This way you just have to type your password. You can bind this script to some git command and it can take in extra parameters so that it changes your branches.
But I would advise you to create yourself ssh keys and use them. Here is a great tutorial how to do that :) ssh_tutorial and connect GH to ssh
I wrote a bash script to get pulled automatically from master repository After it run that means auto enter the username and password. But it's not working. After executing fist command it again asked for a username.
my script is like this
#!/usr/bin/expect
git pull origin master
expect "Username for 'http://192.168.2.xx:xxx':"
send "myUsername\r"
expect "Password for 'http://192.168.2.xx:xxx':"
send "myPassword\r"
interact
Please help me out. Where I am mistaken
I recently read a post called "Tag a Repo from a Jenkins Workflow Script", my question is pretty similar but using a bash script (not a workflow script)
Inside of my script I have
#!/bin/bash
...
git push origin :refs/tags/${NEW_TAG}
git tag -fa $NEW_TAG
git push origin master --tags
but at first "git" command I've got
fatal: could not read Username for 'https://github.com': No such device or address
Thank you for your help !
can you please check origin url by using command git remote -v.
Please change origin url to https://USERNAME:PASSWORD#github.com.... and it will work.
In non interactive mode you need to specify credentials in remote url.
My bash script is:
#!/bin/bash
git clone https://abc#xyz.com/xxx/xxxx/pqr.git
git clone https://abc#xyz.com/xxx/xxxx/pqr2.git
git clone https://abc#xyz.com/xxx/xxxx/pqr3.git
git clone https://abc#xyz.com/xxx/xxxx/pqr4.git
Now it asks me the password every time .,ie 4 times....and I have to enter the password 4 times .,ie each time it does the git clone.
I want to store the password in a variable say 'passwd' and use it to give as a input the the "Enter password" statement. Basically need to automate it.
A simple solution would be git credential. Just set the timeout to a large enough value to clone those repositories:
git config --global credential.helper 'cache --timeout=3600' # 1 hour
But if you really want to do it the way you described, then monitor the output of a command with expect and send the password with exp_send "passwd\r" when Enter password is encountered.
I want to create a bat file that allow me to run the hg pull command. When i run hg pull, it get some server information and then ask for "user name" and "password". i want to add user name and password automatically. Could you some one please tell me how to solve this.
Here's how you can pass credentials to command-line invocation of Mercurial:
hg pull http://.../ --config ui.username={username} --config ui.password={password}
And I recommend using environment variables to store username and password:
hg pull --config ui.username=%HG_USERNAME% --config ui.password=%HG_PASSWORD%
I have found a solution for this. What we have to do is modify the URl as follow with user input
hg pull http://UserName:Password#yourserver.com/hg/yourRepo