Confused about the Jenkins build ID

I have a question about the Jenkins build ID. Is it that possible a build ID is not an integer?

Why ask this?

We have maintained a Golang Jenkins client. There is a pull request that can replay or tiggger a Jenkins build. But I’m not sure the build id should be string or integer.

You can see the discussion details from Add replay function in blueocean client by JohnNiang · Pull Request #26 · jenkins-zh/jenkins-client · GitHub

Are you talking about BUILD_ID the environmental variable? it used to be a string/timestamp, but then switched to run id. Blueocean might be old enough that it supported that value.

The Java code does have getId() (which is kinda an interface) return a string for runs, but runs will always be a number - jenkins/Run.java at 632033d6ada7c04bbc77ae710dc0a4635fdf9baa · jenkinsci/jenkins · GitHub ← has integer to string

All environmental variable is in the string format.

What is your suggestion if there is a variable of the build id which in a method? Make the variable type be string or integer? See here.

I don’t get involved with core so my opinion is just as a random user for a while. String is safest, Int is probably fine, and if its not you can always change the code in the future.

1 Like