小编tml*_*lye的帖子

从Jenkins的管道中止当前构建

我有一个Jenkins管道,它有多个阶段,例如:

node("nodename") {
  stage("Checkout") {
    git ....
  }
  stage("Check Preconditions") {
    ...
    if(!continueBuild) {
      // What do I put here? currentBuild.xxx ?
    }
  }
  stage("Do a lot of work") {
    ....
  }
}
Run Code Online (Sandbox Code Playgroud)

如果不满足某些先决条件并且没有实际工作要做,我希望能够取消(而不是失败)构建.我怎样才能做到这一点?我知道currentBuild变量可用,但我找不到它的文档.

jenkins jenkins-pipeline

45
推荐指数
2
解决办法
5万
查看次数

移至VIM中的下一个打开或关闭括号

我正在寻找一种方法来移动到某种类型的下一个打开或关闭括号,例如{}.例:

if(true)
{
   for(int i = 0; i < 10; i++)
   {
       SomeFunction();
       SomeOtherFuntion();
   }
}
Run Code Online (Sandbox Code Playgroud)

假设我的光标在'S'上SomeFunction(),我想跳转到下一个},即for循环的结束括号.

有效的方法是什么?我能想到的唯一方法是使用/}[ENTER],但我想知道是否有更简单的方法.

vim editor

7
推荐指数
1
解决办法
4975
查看次数

Terraform不尊重git的ssh配置

我的terraform模块位于通过ssh密钥访问的私有bitbucket存储库中。

我不知道什么git命令terraform运行或如何更改身份验证,但它似乎正在使用不同的ssh配置。

这是我的.tf文件:

module "sdfsdfs" {
  source = "git::ssh://bitbucket.org/mycomp/my-module-root//submodule"
}
Run Code Online (Sandbox Code Playgroud)

我在詹金斯管道中运行此程序,并且我正在编辑ssh配置以使用特定的密钥。我已经证明这种方法有效:

sshagent (credentials: ['my-ssh-key']) {
    bat 'git clone git@bitbucket.org:mycomp/my-module.git'
}
Run Code Online (Sandbox Code Playgroud)

ssh配置已正确修改,并在jenkins中使用了我的密钥存储。

我不知道实际上是什么地形从git repo中拉出来的,但是它不尊重ssh的配置:

sshagent (credentials: ['my-ssh-key']) {
    bat 'terraform init'
}
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

C:\Program Files\Git\cmd\git.exe exited with 128: Cloning into 
'.terraform\modules\c760b746e09bd59ba86aae13dc9e9959'...

Permission denied (publickey).

fatal: Could not read from remote repository.
Run Code Online (Sandbox Code Playgroud)

terraform在这里做什么或不做什么?我只想为此会话配置此配置,因此无法为我的jenkins服务器设置全局ssh配置。

git jenkins jenkins-plugins terraform jenkins-pipeline

5
推荐指数
1
解决办法
967
查看次数