# withCredentials method using groovy script to use in Jenkins shared library

**URL:** <https://community.jenkins.io/t/withcredentials-method-using-groovy-script-to-use-in-jenkins-shared-library/14149>\
**Category:** Community\
**Created:** [April 11, 2024, 3:21pm UTC](https://community.jenkins.io/t/withcredentials-method-using-groovy-script-to-use-in-jenkins-shared-library/14149 "2024-04-11T15:21:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![neeraja3](https://avatars.discourse-cdn.com/v4/letter/n/258eb7/32.png) [@neeraja3](https://community.jenkins.io/u/neeraja3)\
**Post date:** [April 11, 2024, 3:21pm UTC](https://community.jenkins.io/t/withcredentials-method-using-groovy-script-to-use-in-jenkins-shared-library/14149/1 "2024-04-11T15:21:50Z")

</div>

Can anyone help me how to use the git credentials using a shared library concept in groovy script using withCredentials method and how to call in another shared library groovy file.  
or point to a post which is related to this query.

---

<div class="post-metadata">

**Author:** ![cheerbuzz](https://avatars.discourse-cdn.com/v4/letter/c/5fc32e/32.png) [@cheerbuzz](https://community.jenkins.io/u/cheerbuzz)\
**Post date:** [April 1, 2025, 8:41am UTC](https://community.jenkins.io/t/withcredentials-method-using-groovy-script-to-use-in-jenkins-shared-library/14149/2 "2025-04-01T08:41:32Z")

</div>

I ran into this issue as well. What i do instead is save the cedential in environment variables or pass it to the method called.

1Year too late but, might be interesting for others
