Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
869 views
in Technique[技术] by (71.8m points)

credential variable in jenkins publish over ssh

This my Jenkins pipeline script. TOOL_CREDS_USR and TOOL_CREDS_PSW variables are not passed to the remote host. Since variables are null, my job hangs asking for username

I verified python command works, verified it by running directly on remote host with variables substituted

pipeline {
    environment {
        TOOL_CREDS = credentials('hello')
    }
    stages {
        stage('Deploy') {
            steps {
                echo 'Deploying....'
                sshPublisher(
                    continueOnError: false, 
                    failOnError: true,
                    publishers: [
                        sshPublisherDesc(
                            configName: "world",
                            sshTransfer(execCommand: 'python3 -m pip install --index-url https://$TOOL_CREDS_USR:[email protected]/repository/pypi-hosted/simple testpackage')
                            ],
                            verbose: true
                        )
                    ]
                )
            }
        }
    }
}

I tried ${} but that also fails. Please help

question from:https://stackoverflow.com/questions/65834063/credential-variable-in-jenkins-publish-over-ssh

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I had to use double quotes instead of single

sshTransfer(execCommand: "python3 -m pip install --index-url https://$TOOL_CREDS_USR:[email protected]/repository/pypi-hosted/simple testpackage")


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...