Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Apps Export and Import #350

Open
sgokaram-saagie opened this issue Oct 14, 2020 · 6 comments
Open

Support Apps Export and Import #350

sgokaram-saagie opened this issue Oct 14, 2020 · 6 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@sgokaram-saagie
Copy link
Contributor

Supporting Exporting and Importing Apps.
https://github.com/saagie/gradle-saagie-dataops-plugin/wiki/projectsExport

@sgokaram-saagie sgokaram-saagie added the enhancement New feature or request label Oct 14, 2020
@sgokaram-saagie sgokaram-saagie added this to the 2.4 milestone Oct 14, 2020
@ZouhairBear
Copy link
Contributor

@ZouhairBear
Copy link
Contributor

ZouhairBear commented Oct 27, 2020

  • test for script of all tasks

How to test :

Version to test : 2.1.19
Create a build file:
Example of build.newTask.gradle:

import io.saagie.plugin.dataops.tasks.projects.artifact.ProjectsExportJobV1Task
import io.saagie.plugin.dataops.tasks.projects.artifact.ProjectsImportJobTask
import groovy.json.JsonSlurper;
plugins {
    id 'groovy'
    id 'base'
    id 'io.saagie.gradle-saagie-dataops-plugin' version '2.1.19'
}
dependencies {
    implementation group: 'gradle.plugin.io.saagie', name: 'gradle-saagie-dataops-plugin', version: '2.1.12'
}
def exportLocation = ' ' // <=== edit this with the export path
def tmpLocation = ' ' // <=== edit this with the tmp file path
task projectExportSqoop(type: ProjectsExportJobV1Task) { // <====== Create the first job
    configuration = saagie {}
    doFirst {
        projectExportSqoop.configuration = saagie {
            server {
                url = saagieurl
                login = saagieuserid
                password = saagiepassword
                environment = saagieplatformid
                jwt = true
                acceptSelfSigned = true
            }
            job {
                ids = ['21025']
            }
            exportArtifacts {
                export_file = exportLocation + '/job/sqoop.zip'
                overwrite=true
                temporary_directory= tmpLocation
            }
        }
    }
    taskName = 'projectExportSqoop'
    group = 'Saagie'
    description= 'export v1 sqoop job for saagie'
}
task projectExportJava(type: ProjectsExportJobV1Task) { // <====== Create the second job
    configuration = saagie {}
    doFirst {
        projectExportJava.configuration = saagie {
            server {
                url = saagieurl
                login = saagieuserid
                password = saagiepassword
                environment = saagieplatformid
                jwt = true
                acceptSelfSigned = true
            }
            job {
                ids = ['21754']
            }
            exportArtifacts {
                export_file = exportLocation + '/job/java.zip'
                overwrite=true
                temporary_directory= tmpLocation
            }
        }
    }
    taskName = 'projectExportJava'
    group = 'Saagie'
    description= 'export v1 Java job for saagie'
}
task projectExportR(type: ProjectsExportJobV1Task) { // <====== Create the second job
    configuration = saagie {}
    doFirst {
        projectExportR.configuration = saagie {
            server {
                url = saagieurl
                login = saagieuserid
                password = saagiepassword
                environment = saagieplatformid
                jwt = true
                acceptSelfSigned = true
            }
            job {
                ids = ['20983']
            }
            exportArtifacts {
                export_file = exportLocation + '/job/r.zip'
                overwrite=true
                temporary_directory= tmpLocation
            }
        }
    }
    taskName = 'projectExportR'
    group = 'Saagie'
    description= 'export v1 R job for saagie'
}
task projectExportTalend(type: ProjectsExportJobV1Task) { // <====== Create the second job
    configuration = saagie {}
    doFirst {
        projectExportTalend.configuration = saagie {
            server {
                url = saagieurl
                login = saagieuserid
                password = saagiepassword
                environment = saagieplatformid
                jwt = true
                acceptSelfSigned = true
            }
            job {
                ids = ['21439']
            }
            exportArtifacts {
                export_file = exportLocation + '/job/talend.zip'
                overwrite=true
                temporary_directory= tmpLocation
            }
        }
    }
    taskName = 'projectExportTalend'
    group = 'Saagie'
    description= 'export v1 talend job for saagie'
}
task projectExportDocker(type: ProjectsExportJobV1Task) { // <====== Create the second job
    configuration = saagie {}
    doFirst {
        projectExportDocker.configuration = saagie {
            server {
                url = saagieurl
                login = saagieuserid
                password = saagiepassword
                environment = saagieplatformid
                jwt = true
                acceptSelfSigned = true
            }
            job {
                ids = ['13592']
            }
            exportArtifacts {
                export_file = exportLocation + '/job/docker.zip'
                overwrite=true
                temporary_directory= tmpLocation
            }
        }
    }
    taskName = 'projectExportDocker'
    group = 'Saagie'
    description= 'export v1 Docker job for saagie'
}
task projectExportPipeline(type: ProjectsExportJobV1Task) { // <====== Create the second job
    configuration = saagie {}
    doFirst {
        projectExportPipeline.configuration = saagie {
            server {
                url = saagieurl
                login = saagieuserid
                password = saagiepassword
                environment = saagieplatformid
                jwt = true
                acceptSelfSigned = true
            }
            pipeline {
                ids = ['526']
                include_job=true
                include_all_versions=true
            }
            exportArtifacts {
                export_file = exportLocation + '/pipeline/pipeline.zip'
                overwrite=true
                temporary_directory= tmpLocation
            }
        }
    }
    taskName = 'projectExportPipeline'
    group = 'Saagie'
    description= 'export Pipleline with out dependency'
}
task projectImportSqoop( // <======== Import artifacts, see that we use the gradle dependOn
        type: ProjectsImportJobTask) {
    dependsOn(['projectExportSqoop'])
    configuration = saagie {
        server {
            url = saagieurl
            login = saagieuserid
            password = saagiepassword
            environment = saagieplatformid
            jwt = true
        }
    }
    doFirst {
        projectImportSqoop.configuration = saagie {
            project {
                id = saagieprojectid
            }
            importArtifacts {
                import_file = exportLocation + '/job/sqoop.zip'
                temporary_directory= tmpLocation
            }
        }
    }
    description= 'import sqoop job for saagie'
    taskName = 'projectImportSqoop'
}
task projectImportJava( // <======== Import artifacts, see that we use the gradle dependOn
        type: ProjectsImportJobTask) {
    dependsOn(['projectExportJava'])
    configuration = saagie {
        server {
            url = saagieurl
            login = saagieuserid
            password = saagiepassword
            environment = saagieplatformid
            jwt = true
        }
    }
    doFirst {
        projectImportJava.configuration = saagie {
            project {
                id = saagieprojectid
            }
            importArtifacts {
                import_file = exportLocation + '/job/java.zip'
                temporary_directory= tmpLocation
            }
        }
    }
    description= 'import java job for saagie'
    taskName = 'projectImportJava'
}
task projectImportR( // <======== Import artifacts, see that we use the gradle dependOn
        type: ProjectsImportJobTask) {
    dependsOn(['projectExportR'])
    configuration = saagie {
        server {
            url = saagieurl
            login = saagieuserid
            password = saagiepassword
            environment = saagieplatformid
            jwt = true
        }
    }
    doFirst {
        projectImportR.configuration = saagie {
            project {
                id = saagieprojectid
            }
            importArtifacts {
                import_file = exportLocation + '/job/r.zip'
                temporary_directory= tmpLocation
            }
        }
    }
    description= 'import R job for saagie'
    taskName = 'projectImportR'
}
task projectImportTalend( // <======== Import artifacts, see that we use the gradle dependOn
        type: ProjectsImportJobTask) {
    dependsOn(['projectExportTalend'])
    configuration = saagie {
        server {
            url = saagieurl
            login = saagieuserid
            password = saagiepassword
            environment = saagieplatformid
            jwt = true
        }
    }
    doFirst {
        projectImportTalend.configuration = saagie {
            project {
                id = saagieprojectid
            }
            importArtifacts {
                import_file = exportLocation + '/job/talend.zip'
                temporary_directory= tmpLocation
            }
        }
    }
    description= 'import Talend job for saagie'
    taskName = 'projectImportTalend'
}

task projectImportDocker( // <======== Import artifacts, see that we use the gradle dependOn
        type: ProjectsImportJobTask) {
    dependsOn(['projectExportDocker'])
    configuration = saagie {
        server {
            url = saagieurl
            login = saagieuserid
            password = saagiepassword
            environment = saagieplatformid
            jwt = true
        }
    }
    doFirst {
        projectImportDocker.configuration = saagie {
            project {
                id = saagieprojectid
            }
            importArtifacts {
                import_file = exportLocation + '/job/docker.zip'
                temporary_directory= tmpLocation
            }
        }
    }
    description= 'import Docker job for saagie'
    taskName = 'projectImportDocker'
}
task projectImportPipeline( // <======== Import artifacts, see that we use the gradle dependOn
        type: ProjectsImportJobTask) {
    dependsOn(['projectExportPipeline'])
    configuration = saagie {
        server {
            url = saagieurl
            login = saagieuserid
            password = saagiepassword
            environment = saagieplatformid
            jwt = true
        }
    }
    doFirst {
        projectImportPipeline.configuration = saagie {
            project {
                id = saagieprojectid
            }
            importArtifacts {
                import_file = exportLocation + '/pipeline/pipeline.zip'
                temporary_directory= tmpLocation
            }
        }
    }
    description= 'Import Pipeline with Dependency Job and all versions'
    taskName = 'projectImportPipeline'
}
task projectTestAll( // <======== Import artifacts, see that we use the gradle dependOn
        type:Exec) {
    dependsOn(['projectImportSqoop','projectImportJava','projectImportR','projectImportTalend','projectImportDocker', 'projectImportPipeline' ])
    commandLine 'echo','Testing'
}

Executing the script using this commande :
The command line : gradle -b build.newTask.gradle projectTestAll

@ZouhairBear
Copy link
Contributor

  • I have tested the script for all tasks : it works as expected

testall

@ZouhairBear
Copy link
Contributor

  • test for export all artifacts

How to test :

Version to test : 2.1.19

The Export all artifacts phase:

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

plugins {
  id "io.saagie.gradle-saagie-dataops-plugin" version "2.1.19"
}
saagie {
    server {
        url = "REPLACE_SAAGIEURL"
        login = "REPLACE_SAAGIELOGIN"
	password = "REPLACE_SAAGIEPASSWORD"
        environment = "REPLACE_SAAGIE"
	jwt = true
    }
    project {
        id = "REPLACE_SAAGIE_PROJECT_ID"
   include_all_artifacts = true
    }

    env {
        scope = 'project'
    }
        }
    exportArtifacts {
          export_file = "./export_all_artifacts.zip" // <=== url  should exist  
          overwrite=true  // <=== temporary_directory ./tmp'  should exist        
    }
}

Export all project artifacts using this commande :
The command line : gradle -b build.exportAllArtifcats.gradle projectsExport

@ZouhairBear
Copy link
Contributor

  • I have tested the export project with all artifacts : it works as expected

exportallartifacts

@ZouhairBear
Copy link
Contributor

  • test for import all artifacts

How to test :

Version to test : 2.1.19

The Export all artifacts phase:

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

plugins {
  id "io.saagie.gradle-saagie-dataops-plugin" version "2.1.19"
}
saagie {
    server {
        url = "REPLACE_SAAGIEURL"
        login = "REPLACE_SAAGIELOGIN"
	password = "REPLACE_SAAGIEPASSWORD"
        environment = "REPLACE_SAAGIE"
	jwt = true
    }
    project {
        id = "REPLACE_SAAGIE_PROJECT_ID"
   
    }

   
        }
    exportArtifacts {
          export_file = "./export_all_artifacts.zip" // <=== url  should exist  
          overwrite=true  // <=== temporary_directory ./tmp'  should exist        
    }
}

Export all project artifacts using this commande :
The command line : gradle -b build.importAllArtifcats.gradle projectsImport

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants