jenkins - 有没有办法在声明性 Jenkins 管道中运行预结帐步骤?

Jenkins declarative pipelines提供一个 post 指令以在阶段完成后执行代码。是否有类似的事情来运行代码阶段运行之前,最重要的是,在 SCM 结帐之前?

例如:

pre {
    always {
        rm -rf ./*
    }
}

这将在 checkout 源代码之前清理我的构建工作区。

最佳答案

pre 是一个很酷的功能想法,但还不存在。 skipDefaultCheckoutcheckout scm(与默认 checkout 相同)是键:

pipeline {
  agent { label 'docker' }
  options {
    skipDefaultCheckout true
  }
  stages {
    stage('clean_workspace_and_checkout_source') {
      steps {
        deleteDir()
        checkout scm
      }
    }
    stage('build') {
      steps {
        echo 'i build therefore i am'
      }
    }
  }
}

https://stackoverflow.com/questions/45348629/

相关文章:

java - Gradle:如何使用并排项目配置多项目设置

node.js - Nodejs npm 步骤在 TeamCity 的每个构建中下载包

javascript - 如何在 Grunt 目标之间共享文件?

c++ - 在 Visual Studio 中运行小型 C++ 程序而不创建项目

powershell - 如何显示 Visual Studio Online 构建任务 Write-

java - Android Gradle 将外部库和嵌套的外部库添加到项目中

java - 如何创建一个包含 shell 脚本和不在 jar 中的属性文件的 maven 程序集?

eclipse - 用ant构建eclipse项目

build - 何时使用门控值机?

process - 为什么要自动化构建?