I am trying to integrate Jenkins-workflow with artifactory. Since https://github.com/jenkinsci/artifactory-plugin does not support jenkins-workflow so far, I came to the point I should either use shell scripts like https://github.com/JFrogDev/project-examples with sh command or my own groovy script.
I want to share this artifactory publisher librairy within the cps-global-lib. Thus, I can not store JFrogDev shell script within the global-lib as I won't be able to call it from my project flow.groovy file. The only solution I found so far is to script a global utility function that imports
import groovyx.net.http.RESTClient;
Unfortunately, the Snippet generator repots :
unable to resolve class groovyx.net.http.RESTClient
@ line 1, column 1.
import groovyx.net.http.RESTClient;
^
1 error
How could I deal with this jenkins-workflow/artifactory integration ? Is there a way to enable RESTClient in jenkins-workflow global library ?
[EDIT]
Based on Jesse answer, I ended up writing a shell script in the workspace using writeFile
workflow command. The shell script put local file to artifactory using curl
.
Do not try to refer to the RESTClient classes directly from the flow. Instead, run a
groovy
executable from ash
step. (You can define multiline string using a variety of syntaxes in Groovy, such as'''
.)