Hello everyone! Tell me please.

I'm using Jenkins to build a project that's running in a docker container and I've run into a problem.

When executing this piece of code:

stage('deploy front') {
        when { equals expected: 'do', actual: buildFront }
        agent {docker{image 'ebiwd/alpine-ssh'}}
            sh 'chmod 400 .iac/privatekey'
            sh "ssh -i .iac/privatekey [email protected] 'cd /opt/docker/test &
 docker-compose pull nginx &
 docker-compose up -d --force-recreate --no-deps nginx '"

I get an error:

+ ssh -i .iac/privatekey [email protected]

Pseudo-terminal will not be allocated because stdin is not a terminal.

Warning: Permanently added '' (ECDSA) to the list of known hosts.

bind: No such file or directory

At the same time, if you execute the following script manually in the container, then everything works

ssh -i .iac/privatekey [email protected]

I start the container itself using docker-compose.yaml

version: '3.1'
    container_name: jenkins
    hostname: jenkins
    restart: always
    user: root
    privileged: true
      -/var/run/docker.sock: /var/run/docker.sock

What could be the problem?

At the very least, the problem is that by using a command in this form, you tell ssh to start an interactive session from a script, i.e. from a context that does not imply interactivity. From the console, you start the shell and everything works, but what do you expect from this command when you run the script from Jenkins?

Roman Konoval2022-02-03 10:01:42

In fact, initially the script is a little longer, I shortened it trying to localize the error. I will now return the original script by editing the question. Can you please tell me how can I use this script without interactivity?

Anton Danilov2022-02-03 10:17:31