saagie / gradle-saagie-dataops-plugin

Saagie Gradle Plugin for the new version (2.0) of Saagie Dataops Orchestrator
Apache License 2.0
2 stars 0 forks source link

Export Variable V1 - Scope is not part of requirement #302

Open sgokaram-saagie opened 4 years ago

sgokaram-saagie commented 4 years ago

Looks like there was some confusion. For V1 there is no scope, all env are technically Global in V1.

medamineziraoui commented 4 years ago

Can you confirm that we can reset default value like this example build import for v1 environment variable :

plugins {
    id 'groovy'
    id 'io.saagie.gradle-saagie-dataops-plugin' version '2.1.4'
}

saagie {
    server {
        url = saagieurl
        login = saagieuserid
        password = saagiepassword
        environment = saagieplatformid
        jwt = true
        acceptSelfSigned = true
    }

    env {
         scope = 'project' // <==== override scope for variables to be soon imported
     }

    project {
        id = saagieprojectid
    }

    importArtifacts {
        import_file = "path/export.zip"
    }
}
sgokaram-saagie commented 4 years ago

No thats not correct. Its

saagie { server {...}

project {
  id = <project_uid> 
}
importArtifacts {
      import_file = <File Name with full path>  
      temporary_directory= < temporary directory used for extracting archive >        
}
propertyOverride{
      scope='project'
 }

}

sgokaram-saagie commented 4 years ago

The override is during import of artifacts not during export

sgokaram-saagie commented 4 years ago

To clarify further , V1 does not have a concept of Global or Project but V2 has scope at Project and Global. To ensure compatibility between then below is the expected behavior

  1. ExportV1 - When you export the variables from V1 you do not specify the 'scope' variable in the gradle task but the export artifact file ( i.e json file ) will have the scope always set to project, this way it can be directly imported into V2.

  2. If an artifacat exported from V1 , you want to import this as a Global scope instead of project scope then you would use the propertyOverride during import and import them to be Global Variables.

ZouhairBear commented 4 years ago

How to test :

Version to test : 2.1.6

The Export phase:

Create a build file: Example of build.projectsExport.gradle:

plugins {
    id 'groovy'
    id 'io.saagie.gradle-saagie-dataops-plugin' version '2.1.6'
}

saagie {
    server {
        url = saagieurl
        login = saagieuserid
        password = saagiepassword
        environment = 4
        jwt = true
        acceptSelfSigned = true
    }

    env {
        include_all_var=true
    }

    exportArtifacts {
        export_file = "/home/zouhair/bear/saagie/test_gradle/302.zip"
        temporary_directory = '/home/zouhair/bear/saagie/test_gradle/tmp'
        overwrite = true
    }
    importArtifacts {
        import_file = "./job/export.zip"
        temporary_directory='./tmp'
    }
}

Export job using this commande : The command line : gradle -b build.projectsExport.gradle projectsExportV1

The import phase:

Create a new build file: Example : build.projectsImport.gradle:

plugins {
    id 'groovy'
    id 'io.saagie.gradle-saagie-dataops-plugin' version '2.1.4'
}

saagie {
    server {
        url = "REPLACE_SAAGIEURL"
        login = "REPLACE_SAAGIELOGIN"
    password = "REPLACE_SAAGIEPASSWORD"
        environment = "REPLACE_SAAGIE"
    jwt = true
        acceptSelfSigned = true
    }
    project {
        id = "REPLACE_SAAGIE_PROJECT_ID"
    }

    propertyOverride{
        scope='global'
    }

    importArtifacts {
        import_file = "./job/export.zip"
        temporary_directory='./tmp'
    }
}

Then use this command line: The command line : gradle -b build.projectsImport.gradle projectsImport

Expected behvior

Success message and importing jobs but not importing all theirs versions