title: How can I do string to integer conversion in a Jenkinsfile?
body: <p>I have the following in my Jenkinsfile:</p>
  <pre><code>pipeline {
      agent none
      environment {
          timeout_mins = 1
      }
      options {
          timeout(time: &quot;${env.timeout_mins}&quot;, unit: 'MINUTES')
      }
      stages {
          stage(&quot;test print&quot;) {
              steps {
                  echo &quot;timeout_mins: ${env.timeout_mins}&quot;
                  sh &quot;sleep 120&quot;
              }
          }
      }
  }
  </code></pre>
  <p>I'd like to re-use environment params such as timeout_mins in multiple places, but need to convert it to integer in certain places for certain plugins. The error I get with the above example is as follows:</p>
  <pre><code>Processing environment for org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty
  java.lang.IllegalArgumentException: Could not instantiate {time=null, unit=MINUTES} for TimeoutStep(time: int, unit?: TimeUnit[NANOSECONDS, MICROSECONDS, MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS]): java.lang.ClassCastException: org.jenkinsci.plugins.workflow.steps.TimeoutStep.time expects int but received class java.lang.String
      at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:264)
      at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:194)
      at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:181)
      at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:126)
      at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108)
      at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:48)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:18)
      at 
  </code></pre>
  <p>Does any one have a way to convert from String to int in Jenkinsfile?</p>
  <p>I tried
  <code>time: env.timeout_mins</code>, but that yields a null.</p>
  <p><code>time: ${env.timeout_mins}</code>, yields:
  WorkflowScript: 7: Method call arguments @ line 7, column 23.
  timeout(time: ${env.timeout_mins}, unit: 'MINUTES')</p>
  <p><code>time: ${env.timeout_mins}.toInteger()</code>, same as above</p>
  <p><code>time: ${env.timeout_mins.toInteger()}</code>, same as above</p>
  <p>Any other things I can try?</p>