0

Jenkinsfile calls a python script that incremented the version number. I was wondering if there was a way to write the incremented version number in the description "currentBuild.description" for easy viewing.

My python script knows the version number of this, but the difficulty is that I don't know how to pass it to Jenkinsfile, or how Jenkinsfile captures it.

def ret = sh(returnStdout: true, script: "python test.py")

I have tried this method, but it is not suitable for me, because I need to display the specific execution steps to the Console Output, If I used this method, my output would all go into the variable 'ret'.

Of course, I could print the 'ret' to the Console Output again, but doing so would be awkward, and it would be weird if python had an exception

thanks, I hope to get your help.

gozheng
  • 1
  • 2
  • I've also tried writing the version number into another file and Jenkinsfile reads the file, but I don't think this is very convenient and wish there was a more elegant way to do it – gozheng May 29 '23 at 01:02
  • perhaps the [envinject](https://plugins.jenkins.io/envinject/) plugin can help here. – M B May 29 '23 at 06:19
  • actually the extra file is more elegant than you may think (and obviously good enough). the other alternative is to make the version the only standard output of the python script and take care that all other (diagnostic) messages go to the diagnostic channel (standard error). This is the typical use-case, e.g. the backtrace should go to standard error already, Groovy/Jenkins does not care about it. Cf. https://www.jenkins.io/doc/pipeline/steps/workflow-durable-task-step/#sh-shell-script and https://stackoverflow.com/q/36547680/367456 - and welcome to SO! – hakre May 29 '23 at 12:22

0 Answers0