【问题标题】:How to execute git bundle command on some branch on jenkins如何在詹金斯的某个分支上执行 git bundle 命令
【发布时间】:2020-07-04 19:23:47
【问题描述】:

我的问题是克隆一些分支后执行 git bundle 命令要写什么,然后将输出文件复制到远程机器:

stage('克隆项目') { git 分支:'release_branch',url:'repo_url' } 阶段('创建捆绑'){ 混帐包………… }

【问题讨论】:

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


    【解决方案1】:

    并非所有 git 命令都可用作本机工作流程步骤。作为替代方案,我自己已经成功地为此目的使用了 shell 脚本,其中所有不受支持的命令都包含在 shell 脚本中。这些脚本是 git 存储库本身的一部分(通常在 build 目录中,但可以是任何你想要的)。

    对于您的用例,您可以使用类似的方法并将“git bundle ...”与文件传输(使用 sftp、curl、aws cli 或任何在您的环境中可用的工具)一起包装在单个 shell 脚本中。假设此文件在路径 build/bundle_transfer.sh 签入,那么您可以在管道中使用以下语法调用此脚本。

    
        stage('Cloning project') {
            git branch: 'release_branch', url: 'repo_url'
        }
        
        stage('create bundle') {
            sh 'build/bundle_transfer.sh'
        }
    

    确保您的脚本已使用设置的可执行属性签入,否则它将在 jenkins 环境中执行失败。如果您希望在远程存储库上使用任何写入操作(“git bundle ...”不需要),那么您最终可能会在管道中使用Credentials Binding。

    【讨论】:

    • 感谢您的建议,它对我很有效.. stage('create bundle') { sh 'bash ./bundle_script.sh' }
    猜你喜欢
    • 2011-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-19
    • 1970-01-01
    • 2019-06-03
    • 1970-01-01
    • 2020-07-20
    相关资源
    最近更新 更多