Unsupported OS - I am trying to run Docker push Buildinfo in Windows machine but its get failed for Unsupported OS - docker

node("DevHub && WinServer2019"){
cleanWs()
stage ("in windows docker") {
withDockerRegistry(credentialsId: "ABC_Technical_User", url: "https://abc-swc-build-toolchains-docker-dev") {
dockerImage = docker.image("abc-swc-build-toolchains-docker-dev/ci-snapshot/mt4/windows_vc100:image-13-77d3d3b")
dockerImage.pull()
String rtDocker = ''
def server = Artifactory.newServer url: 'https://abc/artifactory/', credentialsId: 'ABC_Technical_User'
def buildInfo = Artifactory.newBuildInfo()
// Step 2: Create an Artifactory Docker instance:
def bdDocker = Artifactory.docker server: server
buildInfo localBuildInfo = bdDocker.pull 'abc-swc-build-toolchains-docker-dev/ci-snapshot/mt4/windows_vc100:base-image-13-77d3d3b', 'abc-swc-build-toolchains-docker-dev'
// Step 4: Publish the build-info to Artifactory:
buildInfo.append localBuildInfo
echo "buildInfo : ${buildInfo}"
server.publishBuildInfo buildInfo
}
}
}
I am getting below error
INFO: Pulling image: abc-swc-build-toolchains-docker-dev/ci-snapshot/mt4/windows_vc100:base-image-13-77d3d3b
**java.lang.RuntimeException: Unsupported OS**
at com.github.dockerjava.netty.NettyDockerCmdExecFactory$UnixDomainSocketInitializer.init(NettyDockerCmdExecFactory.java:147)
at com.github.dockerjava.netty.NettyDockerCmdExecFactory.init(NettyDockerCmdExecFactory.java:116)
at com.github.dockerjava.core.DockerClientImpl.withDockerCmdExecFactory(DockerClientImpl.java:193)
at com.github.dockerjava.core.DockerClientBuilder.build(DockerClientBuilder.java:45)
at org.jfrog.build.extractor.docker.DockerJavaWrapper.getDockerClient(DockerJavaWrapper.java:77)
at org.jfrog.build.extractor.docker.DockerJavaWrapper.pullImage(DockerJavaWrapper.java:150)
at org.jfrog.build.extractor.docker.extractor.DockerPull.execute(DockerPull.java:76)
at org.jfrog.build.extractor.packageManager.PackageManagerExtractor.executeAndSaveBuildInfo(PackageManagerExtractor.java:33)
at org.jfrog.build.extractor.docker.extractor.DockerPull.main(DockerPull.java:61)
java.lang.RuntimeException: docker build failed
Can someone help me on this?

Would it be possible for you to test the scenario with the latest Jenkins Artifactory plugin and Java 11? I remember a similar issue reported in the past due to a lower Java version/old plugin as well. Upgrading the plugin to the latest version along with the respective Java version mentioned, should help in resolving the issue.

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"
)
}
}
}
}

github packages: peer not authenticated

I have gradle configuration for github packages similar to this:
repositories {
mavenCentral()
maven {
name = 'GitHubPackages'
url = uri('https://maven.pkg.github.com/whatever/whatever')
credentials {
username = System.getenv("GITHUB_PKG_USER")
password = System.getenv("GITHUB_PKG_TOKEN")
}
}
}
And some library which I read from that repo. I've noticed our jenkins build sometimes failed with:
> Could not resolve all files for configuration ':compileClasspath'.
> Could not download library-name.jar
> Could not get resource 'https://maven.pkg.github.com/correct-path-to-jar.jar'.
> Could not GET 'https://github-registry-files.githubusercontent.com/275167411/e47ffc80-8d5d-11eb-81c7-80fd7fa422bd?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAVCODYLSA52GIFG5T%2F20210330%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210330T154314Z&X-Amz-Expires=300&X-Amz-SignedHeaders=host&X-Amz-Signature=67765f831023f46bf93d2a9354e2cd38913d87481281975dadd7e7d26a63b953'.
> peer not authenticated
And then after rebuild it just works. Linked xml looks this way:
<Error>
<Code>AccessDenied</Code>
<Message>Request has expired</Message>
<X-Amz-Expires>300</X-Amz-Expires>
<Expires>2021-03-30T15:48:14Z</Expires>
<ServerTime>2021-03-31T10:31:25Z</ServerTime>
<RequestId>D2AF221VHNYTPTA3</RequestId>
<HostId>JEzBk1i9ZfzhyU3ab7TMtHozZ5l6BQvjPD+BzWlbMJEToTgC1UuGeMUMoBtUSjnvu3mlpkTDN9s=</HostId>
</Error>
Any ideas what is it about ?
gradle - 6.6.1
java - 11
In my case I was receiving the same error with maven and openjdk-11 when running in Travis-CI. The error does not happen when running with oracle jdk 8, so I ended up switching to run maven with oracle jdk 8. It might be a side-effect of JDK switcher in travis CI, or something else.

Fail Jenkins build when zero artifacts uploaded into artifactory

I need my Jenkins build to fail in case zero artifacts are uploaded into the artifactory.
I have included failNoOp into my upload spec but it seems it's not working in my Jenkinsfile. Here is my code:
def server = Artifactory.newServer url: env.ArtifactoryServerTEST, credentialsId:'ArtifactoryUATServerKey'
server.bypassProxy = true
def uploadSpec = """{
"files": [
{
"pattern": "final_artifacts/*.gz",
"target": "test/"
}
]
}"""
server.upload spec: uploadSpec, failNoOp: true
This needs to fail my build if none of the artifacts are uploaded into the artifactory, but it is giving me this error:
java.lang.IllegalArgumentException: Only the following arguments are
allowed, [spec, buildInfo]
I'm using Artifactory OSS Version 6.2.0. anyone can help me on this?
As #yahavi mentioned, I could fix this problem by upgrade the artifactory plugin. I updated to the latest, so as at now current latest version is 3.3.2.

Jenkins pipeline for JFrog Artifactory fails to publish BuildInfo

I have Jenkinsfile written in groovy as follows:
env.MVN_Goals = MVN_Goals
node {
// Get Artifactory server instance, defined in the Artifactory Plugin administration page.
def server = Artifactory.newServer url: 'http://localhost:8085/artifactory', username: 'admin', password: 'password'
// Create an Artifactory Maven instance.
def rtMaven = Artifactory.newMavenBuild()
stage ('Clone sources'){
git url: 'D:/Sample GIT_Maven Repo'
}
stage 'Artifactory configuration'
rtMaven.deployer releaseRepo:'libs-release-local', snapshotRepo:'libs-snapshot-local', server: server
rtMaven.resolver releaseRepo:'libs-release', snapshotRepo:'libs-snapshot', server: server
def buildInfo = Artifactory.newBuildInfo()
stage('Maven_Build'){
if (isUnix()) {
sh "D:/apache-maven-3.3.9/bin/mvn -B -Dmaven ${MVN_Goals}"
}
else{
bat "D:/apache-maven-3.3.9/bin/mvn -B -Dmaven ${MVN_Goals}"
}
step([$class: 'ArtifactArchiver', artifacts: '**/target/*.jar', fingerprint: true])
}
stage ('Publish build info'){
server.publishBuildInfo buildInfo
}
}
I tried configuring the Artifactory in Jenkins by adding the Artifactory plugin for Jenkins. When I tried to test the connection, I am getting an error as There is either an incompatible or no instance of Artifactory at the provided URL. The same error is occurring when i tried to build my job in Jenkins. Is there a way to resolve it?
Artifactory plugin version - 2.9.1
Artifactory Version - 4.15.0
def buildInfo = Artifactory.newBuildInfo() is within that particular stage.
Modify that as
env.MVN_Goals = MVN_Goals
node {
// Get Artifactory server instance,
// defined in the Artifactory Plugin administration page.
def server = Artifactory.newServer url: 'http://localhost:8085/artifactory', username: 'admin', password: 'password'
// Create an Artifactory Maven instance.
def rtMaven = Artifactory.newMavenBuild()
def buildInfo = Artifactory.newBuildInfo()
stage ('Clone sources'){
git url: 'D:/Sample GIT_Maven Repo'
}

Jenkins + Gradle + Artifactory: Couldn't read generated build info

I'm trying to push my artifacts to Artifactory with Jenkins Pipeline, which call Gradle tool.
I am following the examples published on GitHub:
Example1
Example2
My Jenkins Pipeline script:
stage('Perform Gradle Release') {
//ssh-agent required to perform GIT push (when tagging the branch on release)
sshagent([git_credential]) {
sh "./gradlew clean release unSnapshotVersion -Prelease.useAutomaticVersion=true -Prelease.releaseVersion=${release_version} -Prelease.newVersion=${development_version}"
}
// Create an Artifactory server instance
def server = Artifactory.server('my-artifactory')
// Create and set an Artifactory Gradle Build instance:
def rtGradle = Artifactory.newGradleBuild()
rtGradle.resolver server: server, repo: 'libs-release'
rtGradle.deployer server: server, repo: 'libs-release-local'
//Use Gradle Wrapper
rtGradle.useWrapper = true
//Creates buildinfo
def buildInfo = Artifactory.newBuildInfo()
buildInfo.env.capture = true
buildInfo.env.filter.addInclude("*")
// Run Gradle:
rtGradle.run rootDir: "./", buildFile: 'build.gradle', tasks: 'clean artifactoryPublish', buildInfo: buildInfo
// Publish the build-info to Artifactory:
server.publishBuildInfo buildInfo
}
My Gradle file is very light, I'm just using the plugin Gradle Release Plugin to perform gradle release.
When executing the pipeline, it fails with this message:
:artifactoryPublish
BUILD SUCCESSFUL
Total time: 17.451 secs
ERROR: Couldn't read generated build info at : /tmp/generated.build.info4898776990575217114.json
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
hudson.model.Run$RunnerAbortedException
at org.jfrog.hudson.pipeline.Utils.getGeneratedBuildInfo(Utils.java:188)
at org.jfrog.hudson.pipeline.steps.ArtifactoryGradleBuild$Execution.run(ArtifactoryGradleBuild.java:127)
at org.jfrog.hudson.pipeline.steps.ArtifactoryGradleBuild$Execution.run(ArtifactoryGradleBuild.java:96)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousStepExecution.start(AbstractSynchronousStepExecution.java:40)
...
Finished: FAILURE
When I check on the server, there is no such file /tmp/generated.build.info4898776990575217114.json (the user has of course permission to write to /tmp).
Thanks for your help.
[EDIT] It is weird, but I found some files named "buildInfo2408849984051060030.properties", containing the informations. The name is not the same, neither the format, and these files are stores on my Jenkins machine, not my slave executing the pipeline.
Thanks #tamir-hadad, it has indeed been fixed on 2.8.2.

Resources