[英]Jenkins declarative pipeline for simple basic code
我正在嘗試從 git 獲取代碼,然后在 Jenkins 上運行它。 目前,我在 windows 機器上運行 Jenkins。 但是這段代碼給了我一個錯誤“不是有效的階段部分定義:”
pipeline {
agent any
stages {
stage('Hello') {
try
{
git 'https://github.com/AnikQUPS/learning.git'
sh "python3 python.python"
}
catch(err)
{
echo err
}
}
}
}
在聲明式管道中,您需要將try-catch
包含在 script{} 塊中。
所以,你的管道應該是這樣的:
pipeline {
agent any
stages {
stage('Hello') {
steps {
script {
try
{
git 'https://github.com/AnikQUPS/learning.git'
sh "python3 python.python"
}
catch(err)
{
echo err
}
}
}
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.