如何从一个阶段到另一个阶段访问Jenkinsfile中的目录

时间:2019-07-27 22:28:21

标签: variables jenkins-pipeline workspace

在Jenkinsfile中,我尝试将Checkout代码svn到Stage1和Stage2中的特定文件夹中,我想CD到该文件夹​​中并运行构建脚本,在Stage3中,我想将成功创建的工件推送到关系。我在不同阶段无法访问该特定目录。请帮忙。

我尝试在stage1中使用dir命令,并尝试在stage2中访问它。但是,没有成功的结果。

pipeline {
    agent { label 'ABCD' 
        }
         stages {
                stage ('SCM Checkout') {
                      steps{
                          dir('xyz_directory')
                    checkout changelog: false, poll: false, scm: [$class: 'SubversionSCM', additionalCredentials: [], excludedCommitMessages: '', excludedRegions: '', excludedRevprop: '', excludedUsers: '', filterChangelog: false, ignoreDirPropChanges: false, includedRegions: '', locations: [[credentialsId: '', depthOption: 'infinity', ignoreExternalsOption: true, local: '.', remote: 'http://abcd-abcd']], workspaceUpdater: [$class: 'UpdateUpdater']]
                         }  

                 }
                 stage ('Build') {
                        steps{
                        sh " cd xyz_directory"
                        sh "pwd"
            sh "ls -ltr"       
                        sh "runBuild.sh" 
                    sh "pwd"
            sh "ls -ltr"
                     }
                       stage ('Nexus Upload') {
                        steps{
                        sh"cd xyz_directory/target"


                     }  

       }
        }   

    }
}

我希望在jenkinsfile中的所有阶段都可以访问创建的目录。但是它不起作用。 stage1的pwd路径与stage2的pwd路径不同。不知道为什么。

stage1-结帐成功 //完整路径名称 stage2-这是错误消息: //完整路径名称/@tmp/durable-2b4e9b74/script.sh:第2行:runBuild.sh:找不到命令

这是@ tmp / durable-2b4e9b74。请帮忙。

0 个答案:

没有答案
相关问题