Reputation:
I am absolutly new in Jenkins and I have the following problem.
I have 2 jobs representing 2 different projects which are related to each other.
In particular I have the following situation:
I have a main project named main-project: this is a Java EE project. Then I have a Flex project named client-project that represent the web client of the previous project.
Both these project are stored in a specific GIT repository (so I have a specific GIT repository for the main-project Java EE project and another specific repository for the client-project).
The 2 projects (on my local machine) are related in the following way:
The main-project contains the .swf file that represent the compiled version of the client-project.
Something like this:
\main-project\src\main\webapp\Main.swf
So as you can see into the \src\main\webapp** directory of my **main-project is manually putted the Main.swf file that represent the compilation of the Flex client-project.
Ok, so my problem is: I have 2 Jenkins jobs related to these project.
1) main-project-job: that is the Jenkins job that compile and deploy on the srver the main-project project.
2) client-project-job: this job I think should do nothing (it only retrieve the latest compiled version of the client-project project.
I have to automate the building process in this way:
After that a dveloper push on GIT a new version of the main-project project the main-project-job compile and deploy it on server. When this job ends start the client-project-job that replace the Main.swf file into the **\DEPLOYED-PROJECT\src\main\webapp** path on my deployed project on the server.
How can I do something like this using Jenkins? Is it a neat solution to keep synchronized the latest version of the main-project and of the client-project?
Upvotes: 1
Views: 785
Reputation: 7880
Here a few leads that you might want to explore.
As your main-project seems to depend heavily on your swf file (it should probably not be deployed without the swf file), can't you just get and put the swf file as part of the compiled main-project artifact ? It would seem logical to mee that your deployed main-project already contains the swf file at the time it is deployed.
With Jenkins pipelines, something like this would be pretty easy to do :
stage("Build main project") {
// your build step
}
stage("Copy client project to main webapp") {
git 'your-git/client-project'
sh "cp client-project/generated-swf /main-project/src/main/webapp/Main.swf"
}
stage("Deploy main project") {
// your deploy step
}
If you cannot integrate the swf file directly to the main-project before deploy, you could still use the same job to do that, again if the main project heavily depends on the swf file, you probably want to copy it as part of the job. In this case, only the copy step will change and you will need to use some scp
command to copy the swf file to the deployed app, on the distant server.
Something along these lines :
stage("Build main project") {
// your build step
}
stage("Copy client project to main webapp") {
git 'your-git/client-project'
sh "scp client-project/generated-swf user@deployServer:/main-project/src/main/webapp/Main.swf"
}
stage("Deploy main project") {
// your deploy step
}
If you are sure that you want to make the copy action as part of another job (let's say, if you sometimes needs to manually trigger the job to copy the modified swf file in the running webapp, on the server), you can just trigger another job from the main-project-job :
main-project-job
stage("Build main project") {
// your build step
}
stage("Deploy main project") {
// your deploy step
}
stage("Copy client project to main webapp") {
build job: copy-client-project
}
copy-client-project
stage("Copy client project to main webapp") {
git 'your-git/client-project'
sh "scp client-project/generated-swf user@deployServer:/main-project/src/main/webapp/Main.swf"
}
One last detail: if you do decide to use a separate job for copy, I would recommend not calling the job "client-project-job" which often implies a standard build/deploy job, instead I would name it "copy-client-files" or something similar.
Upvotes: 0
Reputation: 777
> How can I do something like this using Jenkins?
Sounds to me like that's can be easily done with the Parametrized Trigger Plugin or something similar.
Just add a post-build step Trigger/call builds on other projects
to main-project-job which will start client-project-job.
If that's not enough for some reason, please add further details on needed workflow.
Upvotes: 1