我能够轻松地在 Jenkins 管道中启动一个进程,但我正在努力避免被该进程阻止。
目前,Jenkins 正在等待其结束,然后再继续下一步,但我需要此过程在整个构建过程中处于活动状态。
我尝试了很多不同的方法,但没有成功。这里有一个片段: 詹金斯管道:
stage ('Start process') {
steps {
script {
powershell """
try {
. ${WORKSPACE}\\Scripts\\StartMyProcess.ps1 `
-BuildID ${env.BUILD_NUMBER} `
-BuildNumber ${env.BUILD_NUMBER} `
-BuildVCSBranch ${GIT_BRANCH}
} catch {
Write-Error \$_
exit 1
}
"""
}
}
}
PS1 文件:
param (
[Parameter(Mandatory)] [string] $BuildId,
[Parameter()] [string] $BuildNumber,
[Parameter()] [string] $BuildVCSBranch
)
& "${PSScriptRoot}\MyBot.exe" `
-MyBot `
-BuildID $BuildID `
-BuildNumber $BuildNumber `
-BuildVCSBranch $BuildVCSBranch
提前谢谢您, 卢卡
您可以使用并行阶段: 文档 https://www.jenkins.io/doc/book/pipeline/syntax/#parallel
pipeline {
agent any
stages {
stage('Build'){
failFast true
parallel {
stage('Start process') {
agent {
label "windows"
}
steps {
script {
powershell """
try {
. ${WORKSPACE}\\Scripts\\StartMyProcess.ps1 `
-BuildID ${env.BUILD_NUMBER} `
-BuildNumber ${env.BUILD_NUMBER} `
-BuildVCSBranch ${GIT_BRANCH}
} catch {
Write-Error \$_
exit 1
}
"""
}
}
}
stages {
stage('Nested 1') {
steps {
echo "In stage Nested 1 within Branch C"
}
}
stage('Nested 2') {
steps {
echo "In stage Nested 2 within Branch C"
}
}
}
}
}
}
}