Powershell Jenkinsfile管道从git运行PS1脚本

Powershell Jenkinsfile管道从git运行PS1脚本,powershell,jenkins-pipeline,Powershell,Jenkins Pipeline,我真的很难做到这一点,我能找到的唯一例子似乎是运行cmdlet,而不是从Git repo克隆脚本。我有以下资料: 管道{ environment { JOB_BASE_NAME="org-onprem-2016" VERSION="$BUILD_NUMBER" teamsColorRed="C50E2E" teamsColorGreen="7FBA00" } // Helper function to run PowerShell

我真的很难做到这一点,我能找到的唯一例子似乎是运行cmdlet,而不是从Git repo克隆脚本。我有以下资料:

管道{

environment {
        JOB_BASE_NAME="org-onprem-2016"
        VERSION="$BUILD_NUMBER"
        teamsColorRed="C50E2E"
        teamsColorGreen="7FBA00"
}
// Helper function to run PowerShell Commands

agent {
    node {
        label 'Windows'
    }
}

stages {
    stage('Checkout SCM') {
        steps {
        step([$class: 'WsCleanup'])
            dir ('inv_onprem_2016') {
            git url: 'https://github.local/org-cit/org_onprem_2016.git', credentialsId: 'svc-tokenauth'
            }
        }
    }
    stage('Initiate Build Variables') {
        steps {
            powerShell('scripts\\2012\\initiatevars.ps1')
            }
    }        

我在步骤位上尝试了多次迭代,但总是在路径未找到等方面出现某种形式的错误。我想我不知道应该如何处理工作区,但在前面尝试了$ENV:workspace,并得到了相同的结果(没有定义“ENV”的不同错误)。有人能帮我找到正确的方向吗?

这样的路径总是相对于jenkins工作区。您的脚本是否位于文件系统中的某个位置?据我所知,它位于工作区中,因为我在每次运行时都要克隆repo。您能添加工作区目录结构吗?这将有助于重新生成lotah吗tive很有意义。签出阶段的“dir”项向我没有预料到的路径添加了一个额外的目录层。非常感谢。dir将您设置为目录workspace/inv\ux…相对于工作区。