与工作流脚本触发的作业共享工作区

时间:2015-06-19 15:45:06

标签: jenkins jenkins-workflow

我想在我通过'build'命令触发的其他任务中使用我的工作流任务中的工作区。 我需要使这个灵活,因为我希望能够从具有不同工作空间的各种工作流程中触发这些工作,这就是为什么我无法提供硬编码工作区路径。

以下是一些代码:

node {

    git branch: branchName, credentialsId: '1337', url: 'https://i-didnt-provide-this.but-this-is-working.git'  

    def buildType = 'xxx'
    def buildFlavor = 'yyy'
    def hockeyAppId = 'zzz'

    def buildTypeParam = new hudson.model.StringParameterValue('buildType', buildType)
    def buildFlavorParam = new hudson.model.StringParameterValue('buildFlavor', buildFlavor)
    def hockeyAppIdParam = new hudson.model.StringParameterValue('hockeyAppId', hockeyAppId)
    def outputApkFilenameParam = new hudson.model.StringParameterValue('fileName', '*-{buildFlavor}-{buildType}.apk')
    def proguardMappingParam = new hudson.model.StringParameterValue('mappingFile', '{buildFlavor}/{buildType}/mapping.txt')

    build job: 'android_compile', parameters: [buildTypeParam, buildFlavorParam] //This needs the same workspace
    build job: 'android_lint', parameters: [buildTypeParam, buildFlavorParam] //same here
    build job: 'android_upload_hockey', parameters: [hockeyAppIdParam, outputApkFilenameParam, proguardMappingParam] //and here
}

感谢您提前帮助

1 个答案:

答案 0 :(得分:0)

不是尝试共享一个无效的工作空间,而是archive下游作业所需的任何文件。然后,他们可以使用Copy Artifact插件访问这些文件。

在这种情况下,如果您只想在下游作业中检出相同的Git修订版,请确定其提交哈希值并将其作为参数传递给下游版本。 JENKINS-26100可以避免您手动运行git rev-parse HEAD等。

相关问题