步骤1:
在jenkins 内配置 项目参数栏,进行参数配置 :General->This project is parameterized 中进行设置
步骤2:
项目中的流水线中配置传参数的动作,将参数传入流水线
pipeline { agent { label 'slave-02-per' } stages { stage('Checkout') { steps { checkout scmGit(branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: '', url: 'ssh://git']]) } } stage('Prepare'){ steps{ echo 'Initialize the execution environment: install dependent packages and tools...' bat 'D:\\soft_test\\anaconda\\condabin\\conda.bat activate model && python --version' } } stage('Run Test Case') { failFast false steps { parallel( 'Run Pytest Case': { bat 'D:\\soft_test\\anaconda\\condabin\\conda.bat activate model && python replaceEnvvar.py %run_label% %version%' bat 'D:\\soft_test\\anaconda\\condabin\\conda.bat activate model && python per_run.py %run_label% %version%' } ) } } } post { always { allure includeProperties: false, jdk: '', results: [[path: 'report']] } } }
步骤3:
获取传入命令行的参数,再进行逻辑处理
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') run_label = sys.argv[1]
标签:bat,run,传入,python,steps,参数,jenkins,soft From: https://www.cnblogs.com/liu-Gray/p/18419832