0

We have a build job that clones the git repository and the builds it using maven to generate a jar file. We then trigger a separate deployment job to copy that jar and then deploy it using come script to AWS through cloudformation.

However, that deployment code has now been added to the git repository itself, and we would like to have those scripts get copied (first archived) to the deployment job so that we can cut down on the amount of script be keep carrying around.

Is there a way to archive the cloned repository along with the generated jar? If yes, then how to get (copy) the entire folder (workspace for a particular build) to a different job?

This is what I am using in the deployment job to get the jars:

copyArtifacts(projectName: 'my-demo-build-job/master', selector: specific(params.buildnumber))

However, I only get the jars and not the cloned repository source code with this and I guess that's because the source code is discarded (not archive) in the build job.

Saif Ur Rahman
  • 1,034
  • 15
  • 27
  • 1
    You do you need to preserve the source code? You already have your source in your git repo. You just need to push a tag for your build back to the repo to act as a reference. You should then be able to reference or rebuild based on that tag if you need. You can use [`archiveArtifacts`](https://www.jenkins.io/doc/pipeline/steps/core/#archiveartifacts-archive-the-artifacts) to [preserve the artifacts](https://stackoverflow.com/q/5821545/598141) along with your build logs. Make sure to set a [retention policy ](https://stackoverflow.com/a/64475906/598141). – Ian W May 10 '21 at 01:09

0 Answers0