How to add timestamp for artifacts in Jenkins - jenkins

I have following Jenkisfile and I'm trying to upload the artifacts with a timestamp.
import groovy.transform.Field
#Field def timeStamp = Calendar.getInstance().getTime().format('YYYYMMdd-hhmmss',TimeZone.getTimeZone('CST'))
node {
stage('Creating some artifacts') {
sh 'touch hello.txt hi.txt'
}
stage('Uploading artifacts') {
def server = Artifactory.server ('art-1')
def uploadSpec = """{
"files": [
{
"pattern": "*.txt",
"target": "repo1/Dev/${env.BUILD_NUMBER}/*.txt.${timeStamp}"
}
]
}"""
def buildInfo1 = server.upload(uploadSpec)
server.publishBuildInfo(buildInfo1)
}
}
However, I'm getting the following error while trying this.
[consumer_1] Deploying artifact: http://learner.blr.example.com:8081/artifactory/repo1/Dev/12/*.txt.20180913-044451
[Thread consumer_1] An exception occurred during execution:
java.lang.RuntimeException: java.io.IOException: Failed to deploy file. Status code: 500 Response message: Artifactory returned the following errors:
Invalid path. '*' is not a valid name character: repo1/Dev/12/*.txt.20180913-044451 Status code: 500
at org.jfrog.build.extractor.clientConfiguration.util.spec.SpecDeploymentConsumer.consumerRun(SpecDeploymentConsumer.java:44)
at org.jfrog.build.extractor.producerConsumer.ConsumerRunnableBase.run(ConsumerRunnableBase.java:11)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Failed to deploy file. Status code: 500 Response message: Artifactory returned the following errors:
Invalid path. '*' is not a valid name character: repo1/Dev/12/*.txt.20180913-044451 Status code: 500
at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBuildInfoClient.uploadFile(ArtifactoryBuildInfoClient.java:692)
at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBuildInfoClient.doDeployArtifact(ArtifactoryBuildInfoClient.java:374)
at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBuildInfoClient.deployArtifact(ArtifactoryBuildInfoClient.java:362)
at org.jfrog.build.extractor.clientConfiguration.util.spec.SpecDeploymentConsumer.consumerRun(SpecDeploymentConsumer.java:39)
... 2 more
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
java.lang.Exception: Error occurred during operation, please refer to logs for more information.
at org.jfrog.build.extractor.producerConsumer.ProducerConsumerExecutor.start(ProducerConsumerExecutor.java:84)
at org.jfrog.build.extractor.clientConfiguration.util.spec.SpecsHelper.uploadArtifactsBySpec(SpecsHelper.java:71)
at org.jfrog.hudson.generic.GenericArtifactsDeployer$FilesDeployerCallable.invoke(GenericArtifactsDeployer.java:190)
Caused: java.lang.RuntimeException: Failed uploading artifacts by spec
at org.jfrog.hudson.generic.GenericArtifactsDeployer$FilesDeployerCallable.invoke(GenericArtifactsDeployer.java:194)
at org.jfrog.hudson.generic.GenericArtifactsDeployer$FilesDeployerCallable.invoke(GenericArtifactsDeployer.java:131)
at hudson.FilePath.act(FilePath.java:1042)
at hudson.FilePath.act(FilePath.java:1025)
at org.jfrog.hudson.pipeline.executors.GenericUploadExecutor.execution(GenericUploadExecutor.java:52)
at org.jfrog.hudson.pipeline.steps.UploadStep$Execution.run(UploadStep.java:65)
at org.jfrog.hudson.pipeline.steps.UploadStep$Execution.run(UploadStep.java:46)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
at hudson.security.ACL.impersonate(ACL.java:290)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE
Are there any alternative/simple way to add timestamp in artifacts in Jenkins?
P.S.: I'm new to Jenkins groovy scripting and JFrog

The error message says that * is an invalid character for a file name so I don't think you can use it in the target field. However, the artifactory docs say you can do this instead (links for docs bellow):
def uploadSpec = """{
"files": [
{
"pattern": "(*).txt",
"target": "repo1/Dev/${env.BUILD_NUMBER}/{1}.txt.${timeStamp}"
}
]
In this code, {1} stands for "whatever got matched inside the first parenthesis in the pattern" (every open+close parenthesis in a regex defines a capture group).
Note: I don't use artifactory so I didn't test the above code, I am going off of the artifactory docs:
https://www.jfrog.com/confluence/display/RTF/Using+File+Specs
https://www.jfrog.com/confluence/display/RTF/Using+File+Specs#UsingFileSpecs-UsingPlaceholders
I'd also suggest you move the timestamp to the file name instead of the file extension, so that when you download the file, your computer knows which program to use to open it. So i'd change target to something like:
files shorted fist by name then by timestamp: repo1/Dev/${env.BUILD_NUMBER}/{1}-${timeStamp}.txt
files shorted fist by timestamp then by name:
repo1/Dev/${env.BUILD_NUMBER}/${timeStamp}-{1}.txt

Related

JFrog Artifactory upload tar via Jenkins failes with 404

Since a few days we got an error on a Jenkins Pipeline when we want to upload a tar archive via spec to the Artifactory.
All the Maven builds with goal deploy works well and the artifacts gets deployed.
I checked the docs, logs and Stackoverflow.
At the moment I have no further ideas except asking here.
This is the error message of the console output from the Jenkins Pipeline:
[...]
[Pipeline] script
[Pipeline] {
[Pipeline] newBuildInfo
[Pipeline] artifactoryUpload
Executing command: /bin/sh -c git log --pretty=format:%s -1
[consumer_0] Deploying artifact: http://artifactory.name.de/artifactory/snapshots/dir/app-name/release-bundles/1.62.0/app-name-release-bundle-1.62.0.tar.gz
Failed to upload file
[consumer_0] An exception occurred during execution:
java.lang.RuntimeException: java.io.IOException: JFrog service failed. Received 404: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
</body></html>
at org.jfrog.build.extractor.clientConfiguration.util.spec.SpecDeploymentConsumer.consumerRun(SpecDeploymentConsumer.java:44)
at org.jfrog.build.extractor.producerConsumer.ConsumerRunnableBase.run(ConsumerRunnableBase.java:11)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.io.IOException: JFrog service failed. Received 404: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
</body></html>
at org.jfrog.build.extractor.clientConfiguration.client.JFrogService.throwException(JFrogService.java:49)
at org.jfrog.build.extractor.clientConfiguration.client.artifactory.services.Upload.handleUnsuccessfulResponse(Upload.java:59)
at org.jfrog.build.extractor.clientConfiguration.client.JFrogService.execute(JFrogService.java:121)
at org.jfrog.build.extractor.clientConfiguration.client.artifactory.services.Upload.execute(Upload.java:77)
at org.jfrog.build.extractor.clientConfiguration.client.artifactory.ArtifactoryManager.upload(ArtifactoryManager.java:262)
at org.jfrog.build.extractor.clientConfiguration.client.artifactory.ArtifactoryManager.upload(ArtifactoryManager.java:257)
at org.jfrog.build.extractor.clientConfiguration.util.spec.SpecDeploymentConsumer.consumerRun(SpecDeploymentConsumer.java:39)
... 2 more
[...]
That's the relevant part of the pipeline with the upload spec:
def artifactoryServer = Artifactory.server 'art1'
[...]
pipeline {
stages {
stage('Transfer release bundle to artifactory.') {
steps {
script {
parentArtifactId = parentPom.artifactId
def repository = "snapshots"
if(params.branchName == "master") {
repository = "releases";
}
def uploadReleaseArchiveSpec = """{
"files": [
{
"pattern": "release-bundle-${releaseBundleVersion}.tar.gz",
"target": "${repository}/path/to/file/${parentArtifactId}/release-bundles/${parentPom.version}/"
}
]
}"""
artifactoryServer.upload spec: uploadReleaseArchiveSpec, failNoOp: true
}
}
}
}
}
In the router-request.log I found this:
{
"ClientAddr": "127.0.0.1:56828",
"DownstreamContentSize": 95,
"DownstreamStatus": 404,
"Duration": 2531738,
"RequestMethod": "GET",
"RequestPath": "/access/api/v1/users/jffe#000?expand=groups",
"ServiceAddr": "localhost:8040",
"StartUTC": "2022-09-08T09:39:50.224317922Z",
"level": "info",
"msg": "",
"request_Uber-Trace-Id": "745779c57b007818:30fa1347695348a7:062656bb9a6ef6c9:0",
"request_User-Agent": "JFrog Access Java Client/7.43.6 74306900 Artifactory/7.38.10 73810900",
"time": "2022-09-08T11:39:50+02:00"
}
There is also an error message in the catalina log from Tomcat of Artifactory:
08-Sep-2022 13:52:42.392 SEVERE [http-nio-127.0.0.1-8091-Acceptor] org.apache.tomcat.util.net.Acceptor.run Socket accept failed
java.io.IOException: Duplicate accept detected. This is a known OS bug. Please consider reporting that you are affected: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1924298
at org.apache.tomcat.util.net.NioEndpoint.serverSocketAccept(NioEndpoint.java:548)
at org.apache.tomcat.util.net.NioEndpoint.serverSocketAccept(NioEndpoint.java:78)
at org.apache.tomcat.util.net.Acceptor.run(Acceptor.java:129)
at java.base/java.lang.Thread.run(Thread.java:829)
But we are using RedHat Enterprise Linux and not Ubuntu. Otherwise there is an error.
Our environment:
Jenkins 2.346.3
Artifactory OSS 7.38.10
Jenkins Artifactory Plug-in 3.17.0 (and 3.16.2 former attempts)
RedHat Enterprise Linux 8.6
Has anybody an idea? Did I overseen something in the logs above? Where else should I look?
I saw also this post. Unfortunately without answer.
UPDATE - 2022-09-13
I found the issue:
The upload works with a directly in the Jenkins Job (via the corresponding text area) inserted Pipeline script and it doesn't work with the same Pipeline script requested from a Git repository.
Now, it would be interesting to know why the second approach fails.
I guess you are using your own private Jfrog? In that case, does the Jenkins machine have access to your JFrog? Can you ssh into your Jenkins machine and upload a random artifact using curl?
This may not be the best answer, but when dealing with Jfrog, I always simply use curl within the Jenkins pipeline to upload artifacts:
curl -u <user>:<password> -X PUT "<jfrog_url>/path/to/upload/artifact.zip" -T "path\on\jenkins\artifact.zip"
I hade the same issue. The problem is Jenkins injects GIT_ environment variables when checking out Pipeline from SCM.
I worked around the problem by resetting GIT_ environment variables.
pipeline {
agent {
label("some-agent")
}
environment {
GIT_BRANCH = ""
GIT_COMMIT = ""
GIT_PREVIOUS_COMMIT = ""
GIT_PREVIOUS_SUCCESSFUL_COMMIT = ""
GIT_URL = ""
}
stages {
stage("Push to Artifactory") {
steps {
rtUpload(
serverId: "your-artifactory-instance-id",
"buildName": "Your-Build-Name",
"failNoOp": true,
spec: """
{
"files": [
{
"pattern": "target/app.jar",
"target": "libs-release-local/some/path/in/artifactory/app.jar"
}
]
}
""".stripIndent()
)
rtPublishBuildInfo(
serverId: "your-artifactory-instance-id",
"buildName": "Your-Build-Name"
)
}
}
}
}

jenkins pipeline giving inexplicable NullPointerException at GenericDownloadExecutor.java: 52

I followed the example given in this page to download artifacts from JFrog artifactory:
https://www.jfrog.com/confluence/display/JFROG/Scripted+Pipeline+Syntax#ScriptedPipelineSyntax-UploadingandDownloadingFiles
But I have been getting NullPointerException. Below is the script output and error:
[Pipeline] echo
download spec {
"files": [
{
"pattern": "aod-libs-release/path-to-artifact/deployment/DM-DP-V3A.24-RELEASE/deployment-DM-DP-V3A.24-RELEASE.zip",
"target": "./artifacts"
}, {
"pattern": "aod-libs-release/path-to-artifact/dm-auth-web-services/DM-AU-V3A.88-RELEASE/dm-auth-web-services-DM-AU-V3A.88-RELEASE.war",
"target": "./artifacts"
}
]
}
[Pipeline] echo
artifactory server org.jfrog.hudson.pipeline.common.types.ArtifactoryServer#66026154
[Pipeline] newBuildInfo
[Pipeline] artifactoryDownload
[Pipeline] End of Pipeline
java.lang.NullPointerException
at org.jfrog.hudson.pipeline.common.executors.GenericDownloadExecutor.execute(GenericDownloadExecutor.java:52)
at org.jfrog.hudson.pipeline.scripted.steps.DownloadStep$Execution.runStep(DownloadStep.java:67)
at org.jfrog.hudson.pipeline.scripted.steps.DownloadStep$Execution.runStep(DownloadStep.java:53)
at org.jfrog.hudson.pipeline.ArtifactorySynchronousNonBlockingStepExecution.run(ArtifactorySynchronousNonBlockingStepExecution.java:54)
at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE
Below is my jenkins pipeline script
def artifactoryServer = Artifactory.server("Artifactory-instance-id")
artifactoryServer.connection.timeout = 300
def artifactDownloadSpec = """{
"files": [
{
"pattern": "aod-libs-release/path-to-artifact/deployment/${env.DP_VERSION}/deployment-${env.DP_VERSION}.zip",
"target": "./artifacts"
}, {
"pattern": "aod-libs-release/path-to-artifact/dm-auth-web-services/${env.VERSION}/dm-auth-web-services-${env.VERSION}.war",
"target": "./artifacts"
}
]
}"""
echo "download spec " + artifactDownloadSpec
echo "artifactory server " + artifactoryServer
artifactoryServer.download spec: artifactDownloadSpec
I googled for GenericDownloadExecutor.java and found below code, but cannot figure out what I am missing that line 52 needed. Looks like a field is not set.
https://github.com/jenkinsci/artifactory-plugin/blob/master/src/main/java/org/jfrog/hudson/pipeline/common/executors/GenericDownloadExecutor.java
Running artifactoryServer.download step requires using an agent.
For example:
Jenkins scripted pipeline
node {
...
artifactoryServer.download spec: artifactDownloadSpec
...
}
Jenkins declarative pipeline
The recommended way is to use the rtDownload step, however, if you still want to use artifactoryServer.download:
pipeline {
agent any // <- Make sure there is an active agent
stages {
stage('Example') {
steps {
script {
...
artifactoryServer.download spec: artifactDownloadSpec
...
}
}
}
}
}
Read more:
Uploading and Downloading Files
Scripted pipeline example
Declarative pipeline example
Scripted pipeline inside declarative pipeline example - Less recommended, but this example is like your case

docker push to artifactory gives error : "Target host is not specified "

I am trying to push docker image to artifactory using jenkins declarative pipeline. Below is my code-
stage('Push Image to Artifactory') {
steps {
script{
def buildInfo = Artifactory.newBuildInfo()
def server = Artifactory.newServer url: 'artifactory.org', credentialsId: 'artifactsId'
def rtDocker = Artifactory.docker server: server
def tagDockerApp = "artifactory.org/docker-repository/venus:1.0.3"
docker.build(tagDockerApp)
buildInfo = rtDocker.push(tagDockerApp,'docker-repository',buildInfo)
// Publish build info.
buildInfo.env.capture = true
buildInfo.env.collect()
server.publishBuildInfo buildInfo
}
}
}
I am getting below error after rtDocker.push command :
org.apache.http.ProtocolException: Target host is not specified
at org.apache.http.impl.conn.DefaultRoutePlanner.determineRoute(DefaultRoutePlanner.java:71)
at org.apache.http.impl.client.InternalHttpClient.determineRoute(InternalHttpClient.java:125)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
Caused: org.apache.http.client.ClientProtocolException
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:187)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.jfrog.build.client.PreemptiveHttpClient.execute(PreemptiveHttpClient.java:102)
at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryDependenciesClient.execute(ArtifactoryDependenciesClient.java:200)
at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryDependenciesClient.downloadArtifact(ArtifactoryDependenciesClient.java:170)
at org.jfrog.hudson.pipeline.docker.DockerImage.findAndSetManifestFromArtifactory(DockerImage.java:162)
at org.jfrog.hudson.pipeline.docker.DockerImage.generateBuildInfoModule(DockerImage.java:146)
at org.jfrog.hudson.pipeline.steps.DockerPushStep$Execution.run(DockerPushStep.java:135)
at org.jfrog.hudson.pipeline.steps.DockerPushStep$Execution.run(DockerPushStep.java:86)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
at hudson.security.ACL.impersonate(ACL.java:367)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Although i can see the image pushed on to the artifactory , but due to the exception i am not able publish build info and execute other stages
Try providing a full url including protocol (http/https) such as https://artifactory.org in line:
def server = Artifactory.newServer url: 'artifactory.org', credentialsId: 'artifactsId'

Unable to push Docker image to Artifactory

I am running a Jenkins Pipeline and trying to upload a docker image but it is failing using the Artifactory command.
This is a snippet of my Jenkinsfile stage:
stage("Build docker image") {
steps {
container('docker') {
sh 'docker -v'
script {
def rtServer = Artifactory.server "artifactory"
def rtDocker = Artifactory.docker server: rtServer
docker.build("app", "--build-arg JAR_FILE=app.jar -f Dockerfile .")
def buildInfo = rtDocker.push '<companyname>.jfrog.io/app','docker-snapshot-local'
}
}
}
}
This fails after the docker.build with the following message:
[Pipeline] newBuildInfo
[Pipeline] dockerPushStep
expected to call org.jfrog.hudson.pipeline.common.types.Docker.push but wound up catching dockerPushStep; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/
[Pipeline] }
Jenkins EOF log:
Also: hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection from ip-XX-XX-XX-XX.ec2.internal/XX.XX.XX.XX:42790
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1743)
at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:357)
at hudson.remoting.Channel.call(Channel.java:957)
at org.jfrog.hudson.pipeline.common.docker.utils.DockerAgentUtils.getImageIdFromAgent(DockerAgentUtils.java:291)
at org.jfrog.hudson.pipeline.common.executors.DockerExecutor.execute(DockerExecutor.java:59)
at org.jfrog.hudson.pipeline.scripted.steps.DockerPushStep$Execution.run(DockerPushStep.java:104)
at org.jfrog.hudson.pipeline.scripted.steps.DockerPushStep$Execution.run(DockerPushStep.java:71)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
at hudson.security.ACL.impersonate(ACL.java:290)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at ...io.netty.channel.epoll.AbstractEpollChannel.doConnect(AbstractEpollChannel.java:713)
at io.netty.channel.epoll.EpollDomainSocketChannel.doConnect(EpollDomainSocketChannel.java:87)
at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.connect(AbstractEpollChannel.java:555)
at io.netty.channel.DefaultChannelPipeline$HeadContext.connect(DefaultChannelPipeline.java:1366)
at io.netty.channel.AbstractChannelHandlerContext.invokeConnect(AbstractChannelHandlerContext.java:545)
at io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChannelHandlerContext.java:530)
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.connect(CombinedChannelDuplexHandler.java:497)
at io.netty.channel.ChannelOutboundHandlerAdapter.connect(ChannelOutboundHandlerAdapter.java:47)
at io.netty.channel.CombinedChannelDuplexHandler.connect(CombinedChannelDuplexHandler.java:298)
at io.netty.channel.AbstractChannelHandlerContext.invokeConnect(AbstractChannelHandlerContext.java:545)
at io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChannelHandlerContext.java:530)
at io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChannelHandlerContext.java:512)
at io.netty.channel.DefaultChannelPipeline.connect(DefaultChannelPipeline.java:1024)
at io.netty.channel.AbstractChannel.connect(AbstractChannel.java:259)
at io.netty.bootstrap.Bootstrap$3.run(Bootstrap.java:252)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:335)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
The expected to call... is just a warning message and you can ignore it. This may disappear in the next version of workflow-cps-plugin. More information about it can be found here.
About the error - Try first to follow the instructions here HAP-1241.

Jenkins Pipeline - Upload to Artifactory: Failed to deploy file / Parent must be a folder

I have a Jenkins job which generate a zip file I want to updload to Artifactory. I have an issue setting the version of the artifact to be uploaded.
By convention, I use the timestamp has version. I want to upload file to my/group/timestamp/file.zip. The url of the file would be http://ArtifactoryAdress/foo/my/group/timestamp/file.zip
Here is my pipeline code
def serverArtifactory = Artifactory.server 'NameArtificatory'
def uploadSpec = """{
"files": [
{
"pattern": "file.zip",
"target": "my/group/${timestamp}/"
}
]
}"""
serverArtifactory.upload(uploadSpec)
I get the following error from Jenkins Job
java.lang.RuntimeException: java.io.IOException: Failed to deploy
file. Status code: 400 Response message: Artifactory returned the
following errors:
Parent my/group/timestampValue must be a folder Status code: 400
I looked around buildInfo but was not able to find how to set a version.
By the way, I am also agree with a solution without the timestamp but only group name.
Finally, this error is clear and simple.
As mentioned, a file with path my/group/timestampValue already exists. You have to delete it on Artifactory.
Don't forget it's still groovy use ${}. I used below code and it's work
def uploadSpec = """{
"files": [
{
"pattern": "**/target/*.war",
"target": "local-release/${APP_REPO}/${version.trim()}/${timestamp}.zip"
}
]}"""
server.upload(uploadSpec)
#Edit. And I just thought about it. Print please your ${timestamp}. Maybe it's contains characters with spaces, or something like this which Artifactory not allowed in directory name. Try trim your timestamp.trim()

Resources