How can I define the teamcity['build.number'] property in gradle from command line

前端 未结 3 1725
天命终不由人
天命终不由人 2021-01-03 02:42

Is there a way to define teamcity[\'build.number\'] property from command line? I tried -Pteamcity.build.number=1 but it didn\'t work.

I have a build.gradle file wit

3条回答
  •  耶瑟儿~
    2021-01-03 03:29

    It's a bit of hack, but this is the temporary solution I came up with. Still waiting for a better one though.

    in build.gradle I added:

    if (hasProperty("dev")) {
        apply from: 'teamcity.gradle'
    }
    

    I have this in teamcity.gradle:

    task teamcity {
        teamcity['build.number'] = 1
        teamcity['build.vcs.number.1'] = 0
    }
    

    And I have this in gradle.properties:

    dev=1
    

    gradle.properties and teamcity.gradle is in .gitignore. Optionally instead of adding dev=1 to gradle.properties, you can define it in the command line: -Pdev=1, this way you can do with or without the hack on the same machine (though I don't think it's useful)

提交回复
热议问题