Parameterized Jenkins builds from Git Repo

46 views
Skip to first unread message

Seb M

unread,
Mar 24, 2015, 2:46:44 PM3/24/15
to jenkins...@googlegroups.com
Hi list,

we are currently using jenkins to do some deployment tasks. It works great except for one little problem:
We are using the git plugin to fetch our repo. As we sometimes want to deploy a tag and sometimes a branch we added 2 parameters to the build. 
- One GIT_TAG which uses the Git Tag Parameter from the Git Plugin
- Another GIT_BRANCH Parameter as a string

What we actually want is: If no GIT_TAG is chosen when running the parameterized build, use the GIT_BRANCH specified. If a GIT_TAG is picked, use the TAG for the build.

Currently i execute this in the shell before doing my deployment:
cd "${WORKSPACE}"
if [ -z "${GIT_TAG}" ] ; then
  git checkout ${GIT_BRANCH}
  git pull origin ${GIT_BRANCH}
else
  git checkout refs/tags/${GIT_TAG}
fi

sometimes this confuses the git plugin though and i also cannot see the changes for this build in the jenkins interface.

Is there a better way to fulfill our requirements?

Regards and thanks in advance
Sebastian
Reply all
Reply to author
Forward
0 new messages