Reputation: 1183
How does one use Artifactory in a Pipeline Jenkins job with Conan, and run everything in a Docker container?
I have this Jenkinsfile
right now:
def LINUX_DOCKER_IMAGE = "<docker_image>"
def ARTIFACTORY_NAME = "<server-name>"
def ARTIFACTORY_REPO = "<repo-name>"
String setup_conan = "config install <git url>"
node('linux') {
stage("Get Sources"){
checkout scm
}
docker.image(LINUX_DOCKER_IMAGE) {
def server = Artifactory.server ARTIFACTORY_NAME
def client = Artifactory.newConanClient userHome: "/tmp/conan_home"
def serverName = client.remote.add server: server, repo: ARTIFACTORY_REPO
stage("Setup Conan") {
client.run(command: setup_conan)
}
stage("Build package") {
client.run(comnand: "create --profile Linux-Release . foo/bar")
}
stage("Upload package") {
String command = "upload -r ${serverName} --all --check --confirm \"myproject/*\""
def b = client.run(command: command)
server.publishBuildInfo b
}
}
}
But the Artifactory.newConanClient()
function fails:
[...]
[Pipeline] InitConanClient
[myproject] $ docker exec --env BUILD_DISPLAY_NAME=#19 ... <container sha> sh -c 'conan config set log.trace_file="/tmp/conan-home/conan_log.log" '
[Pipeline] ConanAddRemote
[myproject] $ docker exec --env BUILD_DISPLAY_NAME=#19 ... <container sha> sh -c "conan remote add <server ID> <repo url> "
WARN: Remotes registry file missing, creating default one in /tmp/conan-home/.conan/registry.txt
[Pipeline] ConanAddUser
Adding conan user '<username>', server '<server ID>'
[myproject] $ docker exec --env BUILD_DISPLAY_NAME=#19 ... <container sha> sh -c ********
sh: -c: line 0: unexpected EOF while looking for matching `''
sh: -c: line 1: syntax error: unexpected end of file
[Pipeline] }
[...]
Can I setup the client differently? I can run the Conan commands in s regular sh {}
but then how would I tell Artifactoy about it?
Upvotes: 0
Views: 1128
Reputation: 6033
This is an escaping issue. Jenkins-Artifactory-plugin run Conan executable with /bin/sh
.
There is a Jira issue for that. There you can find a snapshot which resolves the problem.
The fix will be included in the next Jenkins-Artifactory-plugin release. In the meantime, you can download the snapshot version
Upvotes: 1