2

This is my .gitlab-ci.yml file:

before_script:
  - sudo apt-get install -y python-pip
  - pip install fabric

staging:
  type: deploy
  script:
    - fab -f fab_crawler start:test  
  only:
    - test

production:
  type: deploy
  script: 
    - fab -f fab_crawler start:dev
  only:
    - master

and this is my gitlab-runner config file in /etc/gitlab-runner:

concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "xxx"
  url = "xxx"
  token = "xxx"
  executor = "ssh"
  [runners.ssh]
    user = "root"
    host = "80.xxx.xxx.xx6"
    port = "xxxx"
    identity_file = "/root/.ssh/id_rsa"
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]

when I push something to the test branch, in the jobs I get this error:

Running with gitlab-runner 11.6.0 (f100a208)
  on xxx XMdAz8un
Using Shell executor...
Running on gitlab-runner...
Fetching changes...
HEAD is now at eaffd0f Remove unwanted functions
Checking out eaffd0f2 as test...
Skipping Git submodules setup
$ sudo apt-get install -y python-pip
sudo: no tty present and no askpass program specified
ERROR: Job failed: exit status 1

I also add gitlab-runner ALL=(ALL) NOPASSWD: ALL to the bottom of the /etc/sudoers file but it didnt work this question also has this problem. Is this wierd that I use a ssh runner in config file but gitlab-ci executor says Using Shell executor...?

Emad Helmi
  • 652
  • 8
  • 25

4 Answers4

2

For me the trick was to use visudo to add the line gitlab-runner ALL=(ALL) NOPASSWD: ALL Just using vi didnt work for whatever reasons.

I found details about visudo and this approach here

til
  • 832
  • 11
  • 27
2

add these 2 commands in your /etc/sudoers

gitlab-runner ALL=(ALL) NOPASSWD: ALL
gitlab-runner ALL=(ALL:ALL) ALL
Shaheel_Azhar
  • 73
  • 2
  • 7
0

Is your identity file (/root/.ssh/id_rsa) password protected?

Mihai
  • 9,526
  • 2
  • 18
  • 40
0

ah for ssh executor just for run script on target host, it cant run command like apt install etc.

its write on docs gitlab ci ssh executor https://docs.gitlab.com/runner/executors/ssh.html

The SSH executor supports only scripts generated in Bash and the caching feature is currently not supported.

maybe its help.

Okutasan
  • 36
  • 4