Hello,
I premit I'm quite new to jenkins and to pipeline in particular.
I've a web application that's composed of a main application and several 
modules.

My jenkins pipeline is the following

node
{
    def libName     = "Project"
    def slnPath     = "F:\\Build\\Jenkins\\jobs\\Project\\workspace\\"
    def slnName     = "${slnPath}${libName}.sln"
    def nuget       = "F:\\NugetBin\\nuget.exe"
    def msbHome     = "C:\\Program Files (x86)\\Microsoft Visual 
Studio\\2017\\Professional\\MSBuild\\15.0\\Bin\\msbuild.exe"
    def webProject  = "${slnPath}Project.Server\\Project.Server.csproj"
    def profile     = getProperty("PublishProfile");
    def version     = getProperty("Version");
    def deployFolder= "${slnPath}Deploy"
    
    def buildName = profile + "_" + version;
    

    stage('SCM update')
    {
        checkout([$class: 'SubversionSCM', additionalCredentials: [], 
excludedCommitMessages: '', excludedRegions: '', excludedRevprop: '', 
excludedUsers: '', filterChangelog: false, ignoreDirPropChanges: false, 
includedRegions: '', locations: [[credentialsId: 
'08ae9e8c-8db8-43e1-b081-eb352eb14d11', depthOption: 'infinity', 
ignoreExternalsOption: true, local: '.', remote: 
'http://myserver:18080/svn/Prod/Projects/Project/Project/trunk']], 
workspaceUpdater: [$class: 'UpdateWithRevertUpdater']])
    }
    
     stage('SCM Revision')
    {
       bat("svn info ${slnPath} >revision.txt");

        for (String i : readFile('revision.txt').split("\r?\n"))
        {
            if(i.contains("Last Changed Rev: ")) //This is odd but it's the 
only way I've found to get revision
            {
                def splitted = i.split(": ")
                
                echo "Revisione : "+ splitted[1];
                
                buildName += "." + splitted[1];
                currentBuild.displayName = buildName;
            }
        }
    }
    
    stage('Nuget restore')
    {
         bat("${nuget} restore \"${slnName}\"")
    }
    
    stage('Build Web Main project')
    {
        bat("\"${msbHome}\" \"${webProject}\" 
/p:Configuration=\"${profile}\" /p:DeployOnBuild=true 
/p:publishUrl=\"${deployFolder}\\${profile}\" /nologo /t:Clean,Build" )
    }
    
    stage('Build modules')
    {
         def moduleName = getProperty("modules");
         
         if(moduleName != "")
         {
             
         
         def modules = moduleName.split(',');

         echo "Processing " + modules.length + "modules";

         for(int i=0;i<modules.length;i++)
         {
             bat("\"${msbHome}\" ${slnPath}IFMS.Modules\\" + modules[i] + 
"\\" + modules[i] + ".csproj /p:Configuration=Release /nologo 
/t:Clean,Build" )
             //step to pack it as nuget
             bat("\"${nuget}\" pack ${slnPath}Project.Modules\\" + 
modules[i] + "\\" + modules[i] + ".csproj -ForceEnglishOutput 
-IncludeReferencedProjects -Prop Configuration=Release;Platform=AnyCPU 
-ExcludeEmptyDirectories  -OutputDirectory " + deployFolder +"\\" + profile 
+"\\packages" )
         }
         }
         else
         {
         echo "No module selected";
         }
   
   
//   parallel jobs;
    }
    
    stage('Compress artifacts')
    {
        def filename= buildName + ".zip";
        bat("del "+ filename);
        
        zip(zipFile:filename, dir:"Deploy\\" + profile)
        
        archiveArtifacts artifacts: filename
    }
}

My code smell is here when I define  stage('Build modules'), I wish to call 
a build and call another jenkins job so that it can be build in parallel. 
But as far I've seen using the simple build(....) I've to do again the svn 
checkout, nuget package restore and so on.... what's the best way to pass 
the pipeline workspace down to the modules?

Thanks
Paolo

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/c5006a4f-ec8e-4155-ae9a-bf7c9f36c805%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to