简体   繁体   中英

Use the tag in GitLab webhook in jenkins build

I have a webhook in GitLab to trigger a Jenkins job when ever a new tag is created. Is there a way to use the new tag that triggered the Jenkins job in the Jenkins job? For example, lets say I pushed the tag v.1.5 to my repo.

git tag -a v1.5 -m "version 1.5"
git push --tags

Now, I want to use the tag v.1.5 in the shell execution in the Jenkins build (Execute shell).

echo <tag that triggered this job>

詹金斯构建

Is there a way to read and use the tag from the POST request?

You can read the tag from the local repo using git describe .

tag=$(git describe --tags)
echo "tag = "$tag

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM