Freestyle Jobs

Building a Freestyle Job by Hand

From here on BookNest's code lives in a public repository of its own, github.com/binarybehemoth/booknest-jenkins (https://github.com/binarybehemoth/booknest-jenkins): the baseline plus Docker's Dockerfile and Compose 514 file, kept apart from GitHub's repository so that Jenkins 8,793 ' webhooks and status checks do not mix with its Actions workflows.

In New Item, name the job booknest-freestyle and choose Freestyle project. Restrict it to the label linux; under Source Code Management pick Git 1,932 , the repository URL and branch */main; under Triggers, Poll SCM with H/15 * * * * (H spreads jobs over the hour); add an Execute shell build step with the script in the figure; and Archive the artifacts booknest-*.tgz as a post-build action.

The Build Steps section of booknest-freestyle
The Build Steps section of booknest-freestyle

Build Now starts it, and so does a POST to the job's build URL:

Starting the freestyle job and reading its logGroovy
J=http://localhost:32080; AUTH="admin:$JENKINS_TOKEN"
curl -s -u "$AUTH" -X POST $J/job/booknest-freestyle/build; sleep 25
curl -s -u "$AUTH" $J/job/booknest-freestyle/lastBuild/consoleText
Output
Building remotely on agent-1 (linux booknest) in workspace
  /home/jenkins/agent/workspace/booknest-freestyle
...
Books in the seed data: 6
+ tar czf booknest-2.tgz app.js server.js package-lock.json package.json db public
+ ls -l booknest-1.tgz booknest-2.tgz
-rw-r--r-- 1 jenkins jenkins 13870 Sep 25 14:34 booknest-1.tgz
-rw-r--r-- 1 jenkins jenkins 13870 Sep 25 14:34 booknest-2.tgz
...
Finished: SUCCESS

This was the second build. The Git plugin exported GIT_COMMIT and GIT_BRANCH, and Jenkins BUILD_NUMBER. But look at the ls: build 1's tarball was still in the workspace, and the pattern archived it again. A freestyle job keeps its workspace unless you add a cleanup step.