@@ -958,6 +958,99 @@ func TestHelmBuildPublishWithCIVcsProps(t *testing.T) {
958958 assert .Greater (t , artifactCount , 0 , "No artifacts were validated for CI VCS properties" )
959959}
960960
961+ // TestHelmPushWithLocalGitVcsProps verifies local git VCS props on Helm artifacts
962+ // when running build-publish with VCS collection enabled and no CI env.
963+ func TestHelmPushWithLocalGitVcsProps (t * testing.T ) {
964+ initHelmTest (t )
965+ defer cleanHelmTest (t )
966+
967+ buildName := tests .HelmBuildName + "-local-git"
968+ buildNumber := "1"
969+
970+ cleanupEnv := tests .SetupLocalGitVcsEnv (t )
971+ defer cleanupEnv ()
972+
973+ inttestutils .DeleteBuild (serverDetails .ArtifactoryUrl , buildName , artHttpDetails )
974+ defer inttestutils .DeleteBuild (serverDetails .ArtifactoryUrl , buildName , artHttpDetails )
975+
976+ chartDir := createTestHelmChartWithDependencies (t , "test-chart-local-git" , "0.2.0" )
977+ defer func () {
978+ if err := os .RemoveAll (chartDir ); err != nil {
979+ t .Logf ("Warning: Failed to remove test chart directory %s: %v" , chartDir , err )
980+ }
981+ }()
982+ tests .CopyGitFixtureIntoProject (t , chartDir )
983+
984+ originalDir , err := os .Getwd ()
985+ require .NoError (t , err )
986+ defer func () {
987+ if err := os .Chdir (originalDir ); err != nil {
988+ t .Logf ("Warning: Failed to change back to original directory: %v" , err )
989+ }
990+ }()
991+ require .NoError (t , os .Chdir (chartDir ))
992+
993+ helmCmd := exec .Command ("helm" , "dependency" , "update" )
994+ helmCmd .Dir = chartDir
995+ require .NoError (t , helmCmd .Run (), "helm dependency update should succeed" )
996+
997+ jfrogCli := coreTests .NewJfrogCli (execMain , "jfrog" , "" )
998+ require .NoError (t , jfrogCli .Exec ("helm" , "package" , "." ,
999+ "--build-name=" + buildName , "--build-number=" + buildNumber ), "helm package should succeed" )
1000+
1001+ chartFiles , err := filepath .Glob (filepath .Join (chartDir , "*.tgz" ))
1002+ require .NoError (t , err )
1003+ require .NotEmpty (t , chartFiles , "Chart package file should be created" )
1004+ chartFile := filepath .Base (chartFiles [0 ])
1005+
1006+ parsedURL , err := url .Parse (serverDetails .ArtifactoryUrl )
1007+ require .NoError (t , err )
1008+ registryHost := parsedURL .Host
1009+ registryURL := fmt .Sprintf ("oci://%s/%s" , registryHost , tests .HelmLocalRepo )
1010+
1011+ if ! isRepoExist (tests .HelmLocalRepo ) {
1012+ t .Skipf ("Repository %s does not exist. Skipping test." , tests .HelmLocalRepo )
1013+ }
1014+
1015+ err = loginHelmRegistry (t , registryHost )
1016+ if err != nil {
1017+ errorMsg := strings .ToLower (err .Error ())
1018+ if strings .Contains (errorMsg , "account temporarily locked" ) {
1019+ t .Skip ("Artifactory account is temporarily locked. Skipping test." )
1020+ }
1021+ if strings .Contains (errorMsg , "http response to https" ) ||
1022+ strings .Contains (errorMsg , "tls: first record does not look like a tls handshake" ) {
1023+ t .Skip ("Helm registry login failed due to HTTPS/HTTP mismatch. Skipping test." )
1024+ }
1025+ }
1026+ require .NoError (t , err , "helm registry login should succeed" )
1027+
1028+ err = jfrogCli .Exec ("helm" , "push" , chartFile , registryURL ,
1029+ "--build-name=" + buildName , "--build-number=" + buildNumber )
1030+ if err != nil {
1031+ errorMsg := strings .ToLower (err .Error ())
1032+ if strings .Contains (errorMsg , "404" ) ||
1033+ strings .Contains (errorMsg , "not found" ) ||
1034+ strings .Contains (errorMsg , "exit status 1" ) {
1035+ t .Skip ("OCI registry API not accessible (404). Skipping test." )
1036+ }
1037+ }
1038+ require .NoError (t , err , "helm push should succeed" )
1039+
1040+ require .NoError (t , artifactoryCli .Exec ("bp" , buildName , buildNumber ))
1041+
1042+ publishedBuildInfo , found , err := tests .GetBuildInfo (serverDetails , buildName , buildNumber )
1043+ require .NoError (t , err )
1044+ require .True (t , found )
1045+
1046+ serviceManager , err := utils .CreateServiceManager (serverDetails , 3 , 1000 , false )
1047+ require .NoError (t , err )
1048+
1049+ count := tests .ValidateLocalGitVcsPropsOnBuildInfoArtifacts (t , serviceManager , publishedBuildInfo , tests .HelmLocalRepo ,
1050+ tests .VcsFixtureMainURL , tests .VcsFixtureMainRevision , tests .VcsFixtureMainBranch )
1051+ assert .Greater (t , count , 0 )
1052+ }
1053+
9611054// InitHelmTests initializes Helm tests
9621055func InitHelmTests () {
9631056 initArtifactoryCli ()
0 commit comments