Home > Net >  Jenkinsfile use Output Environment variable in stage input parameter description
Jenkinsfile use Output Environment variable in stage input parameter description

Time:07-26

Below my Jenkins file.

stage('App Store Build Number') {
    steps {
        script {
            sh(script: "/bin/bash -c 'bash script.sh > test'", returnStdout: true).trim()
            env.APP_NUM=sh(script: "/bin/bash -c 'cat test'", returnStdout: true).trim()
            echo "${env.APP_NUM}"
            slack_send("${env.APP_NUM}")

        }
    }
}

stage('build ios')
{
    input {
    message "Should we continue?"
    ok "Yes, we should."
    parameters {
        string(defaultValue: "", name: 'APP_NUM', trim: true, description: "${env.APP_NUM}") 
    }
}
}

we using fastlane cli command to get app live version.

fastlane run app_store_build_number api_key_path:"key.json" app_identifier:"com.projectname.app"|grep -o 'Latest upload for live-version.*'

Output of above command looks like this :- Latest upload for live-version 1.0.10 is build: 5

we want this output in build ios stage input param in description.

CodePudding user response:

Got Solution : we can create script in steps

steps{
   script {                
      env.BRANCHDEPLOY = input message: 'User input required',
      ok: 'Deploy!',
      parameters{string(defaultValue:"",name:'APP_NUM',trim:true,description: "${env.APP_NUM}") 
}}
  • Related