conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.29k stars 985 forks source link

Failed to set the timestamp of artifacts.properties to 0 #4037

Closed VincentPT closed 5 years ago

VincentPT commented 5 years ago

I have followed conan sample to configure build my C++ project on Jenkins but it met a trouble.

"java.io.IOException: Failed to set the timestamp of ...artifacts.properties to 0" I think the problem is the plugin try to set an invalid timestamp(0) to a file.

System information: OS: Windows 10 pro, x64 Jenkins 2.138.3 Artifactory 6.5.1 Conan version 1.9.2 Python 3.7 jdk1.8.0_191 jre1.8.0_191

Here is issue details: Jenkins pipeline script

//Adjust your artifactory instance name/repository and your source code repository
def artifactory_name = "artifactory"
def artifactory_repo = "conan-local"
def repo_url = 'https://github.com/memsharded/example-boost-poco.git'
def repo_branch = 'master'

node {
    def server = Artifactory.server artifactory_name
    def client = Artifactory.newConanClient()

    stage("Get project"){
        git branch: repo_branch, url: repo_url
    }

    stage("Get dependencies and publish build info"){
        dir ('build') {
          def b = client.run(command: "install ..")
          server.publishBuildInfo b
        }
    }

    stage("Build/Test project"){
        dir ('build') {
          sh "cmake ../ && cmake --build ."
        }
    }
}

and here is execution result.

Started by user Vincent Pham
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in D:\Program Files (x86)\Jenkins\workspace\conan-sample
[Pipeline] {
[Pipeline] getArtifactoryServer
[Pipeline] initConanClient
[conan-sample] $ cmd.exe /C "conan config set '"log.trace_file=""D:\Program Files (x86)\Jenkins\workspace\conan-sample@tmp\conan.tmp1349675751210500070\conan_log.log"""' && exit %%ERRORLEVEL%%"
WARN: Remotes registry file missing, creating default one in D:\Program Files (x86)\Jenkins\workspace\conan-sample@tmp\conan.tmp1349675751210500070\.conan\registry.json
[Pipeline] stage
[Pipeline] { (Get project)
[Pipeline] git
Cloning the remote Git repository
Cloning repository https://github.com/memsharded/example-boost-poco.git
 > git.exe init D:\Program Files (x86)\Jenkins\workspace\conan-sample # timeout=10
Fetching upstream changes from https://github.com/memsharded/example-boost-poco.git
 > git.exe --version # timeout=10
 > git.exe fetch --tags --progress https://github.com/memsharded/example-boost-poco.git +refs/heads/*:refs/remotes/origin/*
 > git.exe config remote.origin.url https://github.com/memsharded/example-boost-poco.git # timeout=10
 > git.exe config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git.exe config remote.origin.url https://github.com/memsharded/example-boost-poco.git # timeout=10
Fetching upstream changes from https://github.com/memsharded/example-boost-poco.git
 > git.exe fetch --tags --progress https://github.com/memsharded/example-boost-poco.git +refs/heads/*:refs/remotes/origin/*
 > git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
 > git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision 0571e3765d2de87dbe9f1f3a10f9ce0232e84666 (refs/remotes/origin/master)
 > git.exe config core.sparsecheckout # timeout=10
 > git.exe checkout -f 0571e3765d2de87dbe9f1f3a10f9ce0232e84666
 > git.exe branch -a -v --no-abbrev # timeout=10
 > git.exe checkout -b master 0571e3765d2de87dbe9f1f3a10f9ce0232e84666
Commit message: "updated versions"
First time build. Skipping changelog.
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Get dependencies and publish build info)
[Pipeline] dir
Running in D:\Program Files (x86)\Jenkins\workspace\conan-sample\build
[Pipeline] {
[Pipeline] newBuildInfo
[Pipeline] runConanCommand
[Pipeline] }
[Pipeline] // dir
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
java.io.IOException: Failed to set the timestamp of D:\Program Files (x86)\Jenkins\workspace\conan-sample@tmp\conan.tmp1349675751210500070\.conan\artifacts.properties to 0
    at hudson.FilePath$Touch.invoke(FilePath.java:1632)
    at hudson.FilePath$Touch.invoke(FilePath.java:1616)
    at hudson.FilePath.act(FilePath.java:1077)
    at hudson.FilePath.act(FilePath.java:1060)
    at hudson.FilePath.touch(FilePath.java:1614)
    at org.jfrog.hudson.pipeline.steps.conan.RunCommandStep$Execution.persistBuildProperties(RunCommandStep.java:123)
    at org.jfrog.hudson.pipeline.steps.conan.RunCommandStep$Execution.run(RunCommandStep.java:85)
    at org.jfrog.hudson.pipeline.steps.conan.RunCommandStep$Execution.run(RunCommandStep.java:60)
    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(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Finished: FAILURE
lasote commented 5 years ago

Looks like a bug in the plugin, @markgalpin let me know how to proceed/report to the team.

markgalpin commented 5 years ago

Need the version of the jenkins artifactory plugin, and then I can open a JIRA on it. Would be ideal, if @VincentPT hasn't done so already, to update to the latest version (2.16.2) of that plugin and reproduce using the latest version. Thanks!

VincentPT commented 5 years ago

@markgalpin , my Jenkins is already installed Artifactory Plugin 2.16.2.

danimtb commented 5 years ago

I am not sure what is creating the error here. Maybe the path is wrong but don't think so as this is working file with other examples.

java.io.IOException: Failed to set the timestamp of D:\Program Files (x86)\Jenkins\workspace\conan-sample@tmp\conan.tmp1349675751210500070\.conan\artifacts.properties to 0

Maybe collecting the build info after install does not make much sense here or am I missing something?

def b = client.run(command: "install ..")
          server.publishBuildInfo b

Will need some feedback here about the status of this. Was it reported to the ecosystem team @markgalpin ?

What action should be taken @lasote?

markgalpin commented 5 years ago

@danimtb it was reported to @eyalbe4 but may have gotten missed. I pinged him again and will have him update here.

eyalbe4 commented 5 years ago

The exception is thrown from the persistBuildProperties method in the RunCommandStep class in the Jenkins Artifactory Plugin. This is the line which throws the exception (this is a Jenkins API which create the buildProperties file on the current build agent. buildProperties.touch(0); I'm not sure why this exception is thrown, and more interesting, why it doesn't happen for some builds. I suggest we try not to set a zero timestamp on the file, and replace this line with: buildProperties.touch(System.currentTimeMillis()); Here's a download link to a snapshot version of the Artifactory Plugin, which includes this change: https://oss.jfrog.org/oss-snapshot-local/org/jenkins-ci/plugins/artifactory/3.2.x-SNAPSHOT/artifactory-3.2.x-20190303.095407-9.hpi Will you guys be able to try it and let us know if it resolves the issue? Thanks

VincentPT commented 5 years ago

It may be a weird build because this error is not the first error happened. I remembered I must to create temp folder for logs manually because the tool failed to create it.

After that, this error happened and I don't know how to fix it by myself. @eyalbe4 Anyway, What should I do with this file artifactory-3.2.x-20190303.095407-9.hpi?

eyalbe4 commented 5 years ago

@VincentPT,

Could it be that the error happens when the artifacts.properties file already exists in the .conan directory created by the Jenkins job? Can you see if removing the file, before running the build, resolves the issue?

As for your question, artifactory-3.2.x-20190303.095407-9.hpi is a new version of the Jenkina Artifactory Plugin. Here's how you install it:

  1. Backup the /plugins directory.
  2. Delete from the plugins directory all files / dirs with the "artifactory*" naming pattern.
  3. Remove the cache dir under the jenkins home dir (if it exists).
  4. Place the artifactory-3.2.x-20190303.095407-9.hpi file in the plugins dir.
  5. Restart Jenkins and the relevant build agent.
VincentPT commented 5 years ago

@eyalbe4 I can't delete file artifacts.properties because it is created each build times. However, I've installed the plugin follow your instructions, the issue was resolved.

eyalbe4 commented 5 years ago

Awesome news @VincentPT! Thanks! This snapshot version is safe and you can keep using it. The fix will be included in the upcoming patch release of the Jenkins Plugin. We'll let you know when it is available.

jgsogo commented 5 years ago

ping @eyalbe4 , we need to know if the fix is already included in the released version of the plugin in order to close this issue. Thanks!

jgsogo commented 5 years ago

New release v3.4.0 of the Artifactory-Jenkins plugin after these changes were committed to master. The problem should be fixed, if not, please open it again. Thanks everybody for your support and feedback.