How to set Jenkins environment variable from script

前端 未结 2 513
轻奢々
轻奢々 2020-12-25 13:21

I\'m trying to setup a script to increment the build number of my Xcode project. I make an API call to get the current build number, then I wanted to increment it and apply

相关标签:
2条回答
  • 2020-12-25 13:53

    Add a build step to execute shell - in there determine APP_BUILD_NUMBER and output to file, e.g.

    APP_BUILD_NUMBER=$(curl --request GET 'https://api.domain.com/api/GetBuildNumber')
    APP_BUILD_NUMBER=$((APP_BUILD_NUMBER +1))
    echo APP_BUILD_NUMBER=$APP_BUILD_NUMBER > build.properties
    

    then add build step Inject environment variables and set there Properties File Path to $WORKSPACE/build.properties

    after that $APP_BUILD_NUMBER is accessible in all build steps after as environment variable; e.g. in Xcode build step

    0 讨论(0)
  • 2020-12-25 13:56

    These are also worth considering

    • https://wiki.jenkins-ci.org/display/JENKINS/Environment+Script+Plugin.
    • https://wiki.jenkins-ci.org/display/JENKINS/EnvInject+Plugin
    0 讨论(0)
提交回复
热议问题