小编lle*_*viy的帖子

如何从 Jenkins 管道中的另一个文件调用函数?

我想将管道常用的函数收集在一个单独的文件中。我创建了目录结构:

vars/
...commonFunctions.groovy
pipeline.jenkinsfile
anotherPipeline.jenkinsfile
Run Code Online (Sandbox Code Playgroud)

commonFunctions.groovy:

def buildDocker(def par, def par2) {
  println("build docker...")
}

return this;
Run Code Online (Sandbox Code Playgroud)

在 pipeline.jenkinsfile 中我想调用 buildDocker 函数。我怎样才能做到这一点?我简单地commonFunctions.buildDocker(par1, par2)在管道中尝试过,但收到 MethodNotFound 错误。

更新:

pipeline.jenkins文件的相关部分:

    stage('Checkout') {
        steps {
            checkout([$class           : 'GitSCM',
                      branches         : [[name: gitCommit]],
                      userRemoteConfigs: [[credentialsId: gitCredId, url: gitUrl]]
            ])
        }
    }

    stage("Build Docker") {
        steps {
            catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
                script {
                    // here want to call function from another file
                    commonFunctions.buildDocker(par1, par2)
                }
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

groovy jenkins jenkins-groovy jenkins-pipeline

8
推荐指数
1
解决办法
9521
查看次数

如何在pgAdmin中通过JDBC连接数据库?

我有数据库连接设置和 pgAdmin (这是我所拥有的全部)。我可以通过 pgAdmin 连接到数据库以使用这些设置对数据库进行必要的更改吗?如果是这样,怎么办?

我还没有找到如何做到这一点。这里的其他答案(以及谷歌中的答案)建议编写Java代码 - 这不是我需要的。我想使用 pgAdmin 界面。我可以在不使用 Java 代码的情况下进行更改吗?

这是我的设置示例:

jdbc.driverClassName - org.postgresql.Driver
jdbc.url - jdbc:postgresql://localhost:4444/
jdbc.username - username
jdbc.password - password
Run Code Online (Sandbox Code Playgroud)

postgresql jdbc pgadmin

4
推荐指数
1
解决办法
8300
查看次数

超时和重试在 Istio 中如何协同工作?

这是 VirtualService 的示例,同时使用超时和重试。

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: sa-logic
spec:
  hosts:
    - sa-logic
  http:
  - route: 
    - destination: 
        host: sa-logic
        subset: v1
      weight: 50
    - destination: 
        host: sa-logic
        subset: v2
      weight: 50
    timeout: 8s
    retries:
      attempts: 3
      perTryTimeout: 3s # perTryTimeout (3s) is different from timeout above (8s)
Run Code Online (Sandbox Code Playgroud)

怎么运行的?该文档没有为这个问题提供明确的答案。我有三个猜测:

  1. 超时始终为 8 秒(超时覆盖 perTryTimeout)。
  2. 超时始终为 3 秒(perTryTimeout 覆盖超时)。
  3. 初始调用的超时为 8 秒,重试的超时为 3 秒(与文档相矛盾。文档说 perTryTimeout 包括初始调用和任何重试)。
  4. 每次尝试的超时始终为 3 秒(包括初始调用),但所有尝试的总超时为 8 秒。

istio

2
推荐指数
1
解决办法
3485
查看次数