Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins - execute a script before building, then have the user confirm to build

Tags:

jenkins

I have a bash script that looks like this:

#!/bin/sh
previousRelease=`git describe --tags --match "release*" origin/release`
git diff --name-status $previousRelease..origin/release

Is there a way of having Jenkins execute it as part of a build process? The intention is to see a list of files that have changed since the last release, as a manual step to confirm that the release should go up. The user who has triggered the build needs to read the output and then confirm the release should go ahead.

like image 735
bcmcfc Avatar asked Nov 04 '22 03:11

bcmcfc


1 Answers

Most things are possible to do in Jenkins but if it is the best way of doing it is another question.

To solve this I would use an approach with two jobs one for checking the diff (hock that one on to the git repository) The other job for doing the actual release.

The check diff job

1 Create a job of the type freestyle project with build type "execute shell" and run your script above. Add some prints at the end of the log to create a clickable link to manually start the release job with current git-id as argument.

Just printing an URL in console output will make it clickable so:

export GITID=`git log -n| grep and sed or awk something`
echo http://jenkins.example.com:8888/job/releaseme/buildWithParameters?label=$GITID&parameters=build

will create the accept changes user interface you requested.

The release job

2 Create another job(above I assumed you named it releaseme) let the job have one parameter as argument (tick "This build is parameterized") make let the argument be the git-id you would like to release. Create your release script in this job.

like image 153
Simson Avatar answered Nov 09 '22 13:11

Simson