在Jenkinsfile中调用python函数

问题描述

我有一个Jenkinsfile,它有两个并行阶段。在一个阶段中,我想从python脚本中调用一个函数

Jenkinsfile

pipeline {
  agent any
    stages {
      stage('Main') {
        parallel {
          stage('Build') {
            steps {
              script {
                  ********I want to call python function here ********
              }
            }
          }
          stage('Test'){
              steps{
                  echo "It is a test stage."
              }
          }
        }
      }
    }
}

Python脚本:

class Build:

    def A():
        try:
            print("Build stage")
            return True
        except Exception as e:
            print(str(e))

我想在我的Jenkinsfile中在那里调用此A()函数,并希望在那里获得返回值。 有什么机制可以做到这一点。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)