@@ -571,6 +571,27 @@ def test_fetch_blacklist(self):
571571 # Builds just from JOB_BUILDS_2
572572 self .assertEqual (len (builds ), 37 )
573573
574+ @httpretty .activate
575+ def test_fetch_blacklist_build (self ):
576+ """Test whether builds in blacklist are not retrieved"""
577+
578+ blacklist = ["apex-build-brahmaputra:106" ,
579+ "apex-build-brahmaputra:107" ]
580+
581+ configure_http_server ()
582+
583+ jenkins = Jenkins (SERVER_URL , blacklist_builds = blacklist )
584+
585+ with self .assertLogs (logger , level = 'WARNING' ) as cm :
586+ builds = [build for build in jenkins .fetch ()]
587+ self .assertIn ('WARNING:perceval.backends.core.jenkins:'
588+ 'Skipping blacklisted build: apex-build-brahmaputra:107' , cm .output )
589+ self .assertIn ('WARNING:perceval.backends.core.jenkins:'
590+ 'Skipping blacklisted build: apex-build-brahmaputra:106' , cm .output )
591+
592+ # Builds from JOB_BUILDS_1 + JOB_BUILDS_2 except those 2 in blacklist
593+ self .assertEqual (len (builds ), 67 )
594+
574595
575596class TestJenkinsBackendArchive (TestCaseBackendArchive ):
576597 """Jenkins backend tests using an archive"""
@@ -834,6 +855,7 @@ def test_setup_cmd_parser(self):
834855
835856 args = ['--tag' , 'test' , '-u' , USER , '-t' , TOKEN ,
836857 '--no-archive' , '--sleep-time' , '60' , '--detail-depth' , '2' ,
858+ '--blacklist-builds' , 'job_1:123' ,
837859 '--blacklist-ids' , '1' , '2' , '3' , '4' , '--' ,
838860 SERVER_URL ]
839861
@@ -846,6 +868,7 @@ def test_setup_cmd_parser(self):
846868 self .assertEqual (parsed_args .sleep_time , 60 )
847869 self .assertTrue (parsed_args .no_archive )
848870 self .assertListEqual (parsed_args .blacklist_ids , ['1' , '2' , '3' , '4' ])
871+ self .assertListEqual (parsed_args .blacklist_builds , ['job_1:123' ])
849872
850873
851874if __name__ == "__main__" :
0 commit comments