Docker Plugin for Jenkins Pipeline - No user exists for uid 1005

前端 未结 4 778
囚心锁ツ
囚心锁ツ 2021-02-12 23:10

I\'m trying to execute an SSH command from inside a Docker container in a Jenkins pipeline. I\'m using the CloudBees Docker Pipeline Plugin to spin up the container and execute

4条回答
  •  天命终不由人
    2021-02-12 23:39

        agent {
            docker {
                image 'node:14.10.1-buster-slim'
                args '-u root:root'
            }
    
        }
    
        environment {
            SSH_deploy = credentials('e99988ea-6bdc-45fc-b9e1-536b875bcac7')
        }
    
    stage('build') {
                steps {
                    sh '''#!/bin/bash
                        eval $(ssh-agent -s)
                        cat $SSH_deploy | tr -d '\r' | ssh-add -
                        touch .env
                        echo 'REACT_APP_BASE_API = "//172.22.132.115:8080"' >> .env
                        echo 'REACT_APP_ADMIN_PANEL_URL = "//172.22.132.115"' >> .env
                        yarn install
                        CI=false npm run build
                        ssh -t -o StrictHostKeyChecking=no root@172.22.132.115 'rm -rf /usr/local/src/build'
                        scp -r -o StrictHostKeyChecking=no build root@172.22.132.115:/usr/local/src/
                        ssh -t -o StrictHostKeyChecking=no root@172.22.132.115 'systemctl restart nginx'
                     '''
                }
    
    

提交回复
热议问题