如何在Jenkins管道中导入类文件?

时间:2017-06-28 19:44:15

标签: class jenkins jenkins-pipeline

我有一个包含类的文件。示例:

abstract class TestBase
{
    String name
    abstract def fTest()

    def bobby(){
        return "bobby"
    }
}
class Test extends TestBase
{
    def fTest(){
        return "hello"
    }
}
class Test2 extends TestBase
{
    def fTest(){
        return "allo"
    }
    def func(){
        return "test :)"
    }
}

我想在我的Jenkins管道脚本中导入该文件,因此我可以创建一个类的对象。例如:

def vTest = new Test()
echo vTest.fTest()
def vTest2 = new Test2()
echo vTest2.func()

如何在Jenkins管道中导入文件? THX。

1 个答案:

答案 0 :(得分:6)

你可以这样做:

<强> Classes.groovy

<div class="container">
  <div class="row">
    <h1 style="text-align: center">Edit
      <%= story.title %>
    </h1>
    <div style="width: 40%; margin: 40px auto;">
      <form action="/stories/<%= story._id %>?_method=PUT" method="POST">
        <div class="form-group">
          <label>Title</label>
          <input class="form-control" type="text" name="story[title]" value="<%= story.title %>">
        </div>
        <div class="form-group">
          <label>Image URL</label>
          <input class="form-control" type="text" name="story[image]" value="<%= story.image %>">
        </div>
        <div class="form-group">
          <label>Plot</label>
          <textarea name="story[description]" rows="15" cols="55" class="form-control"><%= story.description %></textarea>
        </div>
        <div class="form-group">
          <label>Category</label>
          <select name="story[category]" class="form-control" value="<%= story.category %>">
            <option value="Fiction">Fiction</option>
            <option value="Sci-Fi">Sci-Fi</option>
            <option value="Fantasy">Fantasy</option>
            <option value="Fan-fiction">Fan-fiction</option>
            <option value="Blog">Blog</option>
            <option value="Romance">Romance</option>
            <option value="Mystery">Mystery</option>
            <option value="Thriller">Thriller</option>
          </select>
        </div>
        <div class="form-group">
          <button class="btn btn-large btn-success btn-block"> Publish </button>
        </div>
      </form>
    </div>
  </div>
</div>

管道:

dependencies{
        classpath 'com.android.tools.build:gradle:3.0.0-alpha4'
}