【问题标题】:credential variable in jenkins publish over sshjenkins 中的凭证变量通过 ssh 发布
【发布时间】:2021-01-21 18:59:52
【问题描述】:

这是我的 Jenkins 流水线脚本。 TOOL_CREDS_USR 和 TOOL_CREDS_PSW 变量不会传递到远程主机。由于变量为空,我的工作挂起询问用户名

我验证了 python 命令有效,通过直接在远程主机上运行并替换变量来验证它

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:$TOOL_CREDS_PSW@sample.com/repository/pypi-hosted/simple testpackage')
                            ],
                            verbose: true
                        )
                    ]
                )
            }
        }
    }
}

我试过 ${} 但也失败了。请帮忙

【问题讨论】:

    标签: jenkins ssh jenkins-pipeline jenkins-plugins jenkins-groovy


    【解决方案1】:

    我不得不使用双引号而不是单引号

    sshTransfer(execCommand: "python3 -m pip install --index-url https://$TOOL_CREDS_USR:$TOOL_CREDS_PSW@sample.com/repository/pypi-hosted/simple testpackage")

    【讨论】:

      猜你喜欢
      • 2023-03-06
      • 1970-01-01
      • 2016-05-30
      • 2017-10-11
      • 2017-05-07
      • 1970-01-01
      • 1970-01-01
      • 2017-02-26
      • 2019-10-25
      相关资源
      最近更新 更多