[英]How do I import a Java library in Jenkins pipeline
我在GitHub上推了一個Java庫,我想在管道中使用它。
我試過了:
@Library('test') _
@Library('test') _
import com.bla.bla.Bla
@Library('test') import com.bla.bla.Bla
我總是得到:
無法解決類Bla。
請參閱https://jenkins.io/doc/book/pipeline/shared-libraries/
如“ 使用第三方庫 ”一節所述:
可以使用@Grab注釋從受信任的庫代碼中使用通常在Maven Central中找到的第三方Java庫。 有關詳細信息,請參閱Grape文檔,但只需輸入:
@Grab('org.apache.commons:commons-math3:3.4.1')
import org.apache.commons.math3.primes.Primes
void parallelize(int count) {
if (!Primes.isPrime(count)) {
error "${count} was not prime"
}
// …
}
葡萄文檔: http : //docs.groovy-lang.org/latest/html/documentation/grape.html#_quick_start
如果您想使用本地庫或github,您唯一需要做的就是將項目構建為maven項目,然后相應地使用@Grab 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.