Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jenkins continuous delivery with shared workspace

Background:

We have one Jenkins job (Production) to build a deliverable every night. We have another job (ProductionPush) that pushes out the deliverable over a proprietary protocol to production machines the next day. This is because some production machines are only available during certain hours during the day (It also gives us a chance to fix any last-minute build breaks). ProductionPush needs access to the deliverable built by the Production job (so it needs access to the same workspace). We have multiple nodes and concurrent builds (and thus unpredictable workspaces) and prefer not to tie the jobs to a fixed node/workspace since resources are somewhat limited.

Questions:

  1. How to make sure both jobs share the same workspace and ensure that ProductionPush runs at a fixed time the next day only if Production succeeds -- without fixing both jobs to run out of the same node/workspace? I know the Parameterized Trigger Plugin might help with some of this but it does not seem to have time delay capability and 12 hours seems too long for a quiet period.

  2. Is sharing the workspace a bad idea?

like image 654
user2120303 Avatar asked Feb 28 '13 16:02

user2120303


People also ask

What is shared workspace Jenkins?

This plugin allows to share workspaces by Jenkins jobs with the same SCM repos. It should save you some disk space, if you have different jobs with identical repos.

How do I keep my Jenkins workspace?

You could simply archive the complete workspace at the end of a build. It would then get deleted when the job is deleted. To do this: Add post-build action -> "Archive the artifacts"

How do I create a deployment pipeline in Jenkins?

Step 1 − Go to Manage Jenkins → Manage Plugin's. In the available tab, search for 'Build Pipeline Plugin'. Click On Install without Restart. Once done, restart the Jenkins instance.

What is a Jenkins build?

Jenkins is an open-source automation tool written in Java with plugins built for Continuous Integration purposes. Jenkins is used to build and test your software projects continuously making it easier for developers to integrate changes to the project, and making it easier for users to obtain a fresh build.


1 Answers

Answer 2: Yes, sharing workspace is a bad idea. There is possibility of file locks. There is the issue of workspace being wiped out. Just don't do it...

Answer 1: What you need is to Archive the artifacts of the build. This way, the artifacts for a particular build (by build number) will always be available, regardless of whether another build is running or not, or what state the workspaces are in

To Archive the artifacts

  • In your build job, under Post-build Actions, select Archive the artifacts
  • Specify what artifacts to archive (you can use a combination of below)
    a) You can archive all: *.*
    b) You can archive a particular file with wildcards: /path/to/file_version*.zip
    c) You can ignore the intermediate directories like: **/file_version*.zip
  • To avoid storage problems with many artifacts, on the top of configuration you can select Discard Old Builds, Click Advanced button, and play around with Days to keep artifacts and Max # of builds to keep with artifacts. Note that these two settings do not control for how long the actual builds are kept (other settings control that)

To access artifacts from Jenkins

  • In the build history, select any previous build you want.
  • In addition to SCM changes and revisions data, you will now have a Build Artifacts link, under which you will find all the artifacts for that particular build.
  • You can also access them with Jenkins' permalinks, for example
    http://JENKINS_URL/job/JOB_NAME/lastSuccessfulBuild/artifact/ and then the name of the artifact.

To access artifacts from another job

I've extensively explained how to access previous artifacts from another deploy job (in your example, ProductionPush) over here:
How to promote a specific build number from another job in Jenkins?

If your requirements are to always deploy latest build to Production, you can skip the configuration of promotion in the above link. Just follow the steps for configuration of the deploy job. Once you have your deploy job, if it is always run at the same time, just configure its Build periodically parameters. Alternatively, you can have yet another job that will trigger the deploy job based on whatever conditions you want.

In either case above, if your Default Selector is set to Latest successful build (as explained in the link above), the latest build will be pushed to Production

like image 151
Slav Avatar answered Sep 23 '22 03:09

Slav