13
13
logging .basicConfig (level = logging .INFO ,
14
14
format = '%(asctime)s - %(levelname)s - %(message)s' )
15
15
16
- CODACY_PROJECT_TOKEN = os .getenv ('CODACY_PROJECT_TOKEN' )
17
16
CODACY_BASE_API_URL = os .getenv ('CODACY_API_BASE_URL' , 'https://api.codacy.com' )
18
17
URL = CODACY_BASE_API_URL + '/2.0/coverage/{commit}/python'
19
18
DEFAULT_REPORT_FILE = 'coverage.xml'
@@ -180,6 +179,7 @@ def run():
180
179
default = [], type = str ,
181
180
action = 'append' )
182
181
parser .add_argument ("-c" , "--commit" , type = str , help = "git commit hash" )
182
+ parser .add_argument ("-t" , "--token" , type = str , help = "Codacy project token" )
183
183
parser .add_argument ("-d" , "--directory" , type = str , help = "git top level directory" )
184
184
parser .add_argument ("-v" , "--verbose" , help = "show debug information" , action = "store_true" )
185
185
@@ -188,9 +188,13 @@ def run():
188
188
if args .verbose :
189
189
logging .Logger .setLevel (logging .getLogger (), logging .DEBUG )
190
190
191
- if not CODACY_PROJECT_TOKEN :
192
- logging .error ("environment variable CODACY_PROJECT_TOKEN is not defined." )
193
- exit (1 )
191
+ if args .token :
192
+ codacy_project_token = args .token
193
+ else :
194
+ codacy_project_token = os .getenv ('CODACY_PROJECT_TOKEN' )
195
+ if not codacy_project_token :
196
+ logging .error ("environment variable CODACY_PROJECT_TOKEN is not defined." )
197
+ exit (1 )
194
198
195
199
if not args .commit :
196
200
args .commit = get_git_revision_hash ()
@@ -212,4 +216,4 @@ def run():
212
216
report = merge_and_round_reports (reports )
213
217
214
218
logging .info ("Uploading report..." )
215
- upload_report (report , CODACY_PROJECT_TOKEN , args .commit )
219
+ upload_report (report , codacy_project_token , args .commit )
0 commit comments