BlueOcean并没有要求我的一些Jenkins多分支参数



我最近修改了我的分支的 Jenkinsfile(目前,我只有一个分支包含这个 jenkins 分支(。

当我尝试启动此分支的多分支管道时,我请求了很多参数,但没有我添加的新参数。

如果我进入 Jenkins(不是 BlueOcean(,在配置中我会看到它们,如果我从那里开始构建,我也会看到它们。

这是我的 Jenkinsfile:

pipeline {
agent {
node{
label 'windows-node'
customWorkspace "D:\ws\${env.BRANCH_NAME}"            
}
}
options{
skipDefaultCheckout()
}
triggers{
pollSCM 'H 23 * * *'
}
stages {        
stage('Initialization started'){
steps{
echo "Job parameters:nt- Build X86: ${params.buildX86}nt- Build X64: ${params.buildX64}nt- Commit Version changes: ${params.commitVersionChanges}.${env.BUILD_NUMBER}nt- Setup Version: ${params.version}nt- Setup Configuration: ${params.setupConfiguration}nCurrent repository: ${workspace}"                 
}
}
stage('Checkout'){
steps{
echo "Custom checkout: ${env.BRANCH_NAME}"
checkout scm
}
}
stage('ABC Solution Pre-build') {
steps {
changeAsmVer "${params.version}.${env.BUILD_NUMBER}"
bat 'nuget.exe restore Solution\ABC.sln'
powershell 'ContinuousIntegration\Scripts\ChangeBindingVersion.ps1 "HDAPluginNet4" "Src\Clients\OpcServer\Xms.OpcHda.Server\HDANSrv.Net4.exe.config"'             
}           
}
stage('Preparing SonarQube'){
when{
expression{ params.runTests == true && env.BRANCH_NAME == 'develop'}
}
steps{
withSonarQubeEnv('XYZ SonarQube') {
script{
def sqScannerMsBuildHome = tool 'SonarQube.Runner-3.0'
}
bat "${sqScannerMsBuildHome}\SonarQube.Scanner.MSBuild.exe begin /k:ABC /n:ABC /v:${params.version}.${env.BUILD_NUMBER} /d:sonar.host.url=%SONAR_HOST_URL% /d:sonar.login=%SONAR_AUTH_TOKEN% /d:sonar.cs.nunit.reportsPaths=TestResult.xml /d:sonar.cs.dotcover.reportsPaths=dotcover.html"      
}
}
}
stage('Build ABC Solution') {
steps{
bat ""${tool 'MSBUILD15'}" Solution\ABC.sln /p:Configuration=${params.setupConfiguration} /p:Platform="Any CPU" /t:Rebuild"
}
}
stage('ABC Solution Pre-setup') {
when{
expression{ params.buildX64 == true || params.buildX86 == true}
}
steps{
bat ""Src\Obfuscation\XmsApplicationsObfuscation\Release\obfuscationProcess.cmd" "${workspace}" "${workspace}\output\dotfuscator.zip" "XXXXXXXX""
bat "Doc\BuildDocumentation.bat"
}
}
stage('X64 Setup build') {
when{
expression{ params.buildX64 == true}
}
steps{
bat ""${tool 'MSBUILD15'}" Solution\SetupWix.sln /p:Configuration=${params.setupConfiguration} /p:Platform=x64 /t:Rebuild /p:Version="${params.version}.${env.BUILD_NUMBER}""
bat "move SetupWix\SetupWix\bin\Release\en-us\ABCSetup.msi SetupWix\SetupWix\bin\Release\en-us\ABCSetup_64_bit.msi"
}
}
stage('X86 Setup build') {
when{
expression{ params.buildX86 == true}
}
steps{
bat ""${tool 'MSBUILD15'}" Solution\SetupWix.sln /p:Configuration=${params.setupConfiguration} /p:Platform=x86 /t:Rebuild /p:Version="${params.version}.${env.BUILD_NUMBER}""
bat "move SetupWix\SetupWix\bin\Release\en-us\ABCSetup.msi SetupWix\SetupWix\bin\Release\en-us\ABCSetup_32_bit.msi"
}
}
stage('Post-setup'){
when{
expression{ params.buildX64 == true || params.buildX86 == true}
}
steps{
powershell 'ContinuousIntegration\Scripts\MoveSetups.ps1'
}
}
stage('Commit version change'){
when{
expression{ params.commitVersionChanges == true}
}
steps{
bat 'git add "./*AssemblyInfo.*"'
bat 'git commit -m "Assembly infos changed by Jenkins"'
bat "git push origin HEAD:${env.BRANCH_NAME}"
}
}
stage('Testing'){
when{
expression{ params.runTests == true}
}
steps{
bat 'dotcover.exe analyze ContinuousIntegration/DotCoverConfig.xml'   
nunit testResultsPattern: 'TestResult.xml'              
}
}
stage('Finishing SonarQube'){
when{
expression{ params.runTests == true && env.BRANCH_NAME == 'develop'}
}
steps{
withSonarQubeEnv('XYZ SonarQube') {
script{
def sqScannerMsBuildHome = tool 'SonarQube.Runner-3.0'
}
bat "${sqScannerMsBuildHome}\SonarQube.Scanner.MSBuild.exe end"   
}
}
}
}
post{
failure {
emailext body: "<b>Error while excuting the following job</b><br><br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br>Build URL: ${env.BUILD_URL}", mimeType: 'text/html', recipientProviders: [brokenTestsSuspects(), brokenBuildSuspects()], subject: "ERROR CI: Project name -> ${env.JOB_NAME}"
}
unstable{
emailext body: "<b>Error while excuting the following job</b><br><br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br>Build URL: ${env.BUILD_URL}", mimeType: 'text/html', recipientProviders: [brokenTestsSuspects(), brokenBuildSuspects()], subject: "ERROR CI: Project name -> ${env.JOB_NAME}"
}
}
parameters {
booleanParam(name: 'buildX86', defaultValue: false, description: 'Build for X86 platform')
booleanParam(name: 'buildX64', defaultValue: true, description: 'Build for X64 platform')
booleanParam(name: 'commitVersionChanges', defaultValue: false, description: 'Commit the version changes')
booleanParam(name: 'runTests', defaultValue: false, description: 'Run unit tests')      
string(name: 'version', defaultValue: '3.6.0', description: 'Version of the setup to build')
choice(name: 'setupConfiguration', choices: '''Release
Debug''', description: 'Setup configuration to use')
}
}

我没有收到任何请求的"新"参数(仅在 BlueOcean 中(是"运行测试"。

我该怎么做才能得到它们?我尝试重新启动,没有改变任何东西。

根据文档示例,parameters {}需要在stages{}之前声明,否则它不知道在模板变量中放置什么值,因为脚本化管道是从上到下串行执行的。

此外,如果它刚刚添加到 Jenkinsfile 中,您可能需要运行它两次,它不会知道第一次有参数需要处理。

相关内容

  • 没有找到相关文章

最新更新