Skip to content

Instantly share code, notes, and snippets.

@daveneeley
Last active July 1, 2019 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daveneeley/6ad2870a19a239a2b59c90e3dc85d3e8 to your computer and use it in GitHub Desktop.
Save daveneeley/6ad2870a19a239a2b59c90e3dc85d3e8 to your computer and use it in GitHub Desktop.
jfrog-cli parallel download failure under ant on windows server

This gist sets up a problem reproduction with jfrog-cli on Windows Server 2012. See jfrog/jfrog-cli#407

  • Set up java and ant with scoop.sh or chocolatey
  • Download build.xml, installers.json, and documentation.json files to an empty directory
  • set environment variable ARTIFACTORY_URL to your artifactory instance
  • set environment variable ARTIFACTORY_API_KEY to your api key
  • run /path/to/ant from the directory containing the downloaded files
<?xml version="1.0" encoding="UTF-8"?>
<project name="ant-bootstrap" basedir="." default="test">
<property name="ANT_CONTRIB_VERSION" value="1.0b3"/>
<property name="JFROG_CLI_VERSION" value="1.16.2"/>
<macrodef name="jfrog-cli">
<attribute name="taskname" default="jfrog-cli"/>
<attribute name="resultproperty" default="jfrog-cli.result.last"/>
<element name="jfrog-args" implicit="true"/>
<sequential>
<if>
<isset property="@{resultproperty}"/>
<then>
<echo level="debug">previous @{resultproperty} was ${@{resultproperty}}</echo>
<var name="@{resultproperty}" unset="true"/>
</then>
</if>
<exec taskname="@{taskname}" executable="bin/jfrog" failonerror="true" resultproperty="@{resultproperty}">
<jfrog-args/>
</exec>
</sequential>
</macrodef>
<target name="download">
<mkdir dir="bin"/>
<get src="https://sourceforge.net/projects/ant-contrib/files/ant-contrib/${ANT_CONTRIB_VERSION}/ant-contrib-${ANT_CONTRIB_VERSION}-bin.tar.gz" dest="bin/ant-contrib-${ANT_CONTRIB_VERSION}-bin.tar.gz"/>
<untar src="bin/ant-contrib-${ANT_CONTRIB_VERSION}-bin.tar.gz" dest="bin/" compression="gzip"/>
<get src="https://dl.bintray.com/jfrog/jfrog-cli-go/${JFROG_CLI_VERSION}/jfrog-cli-windows-amd64/jfrog.exe" dest="bin/jfrog.exe"/>
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="bin/ant-contrib/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<property environment="env"/>
</target>
<target name="test" depends="download">
<jfrog-cli taskname="config">
<arg value="rt"/>
<arg value="c"/>
<arg value="test-artifactory-server"/>
<arg value="--url"/>
<arg value="${env.ARTIFACTORY_URL}"/>
<arg value="--apikey"/>
<arg value="${env.ARTIFACTORY_API_KEY}"/>
</jfrog-cli>
<jfrog-cli taskname="use">
<arg value="rt"/>
<arg value="use"/>
<arg value="test-artifactory-server"/>
</jfrog-cli>
</jfrog-cli>
<for param="file" parallel="true" threadCount="3">
<path>
<fileset dir="." includes="*.filespec"/>
</path>
<sequential>
<echo level="info">Downloading artifacts from @{file}</echo>
<jfrog-cli taskname="download-${file}">
<arg value="rt"/>
<arg value="dl"/>
<arg value="--spec-vars" />
<arg value="downloadBase=output" />
<arg value="--spec"/>
<arg value="@{file}"/>
<arg value="--build-number"/>
<arg value="1"/>
<arg value="--build-name"/>
<arg value="mybuild"/>
</jfrog-cli>
</sequential>
</for>
<jfrog-cli taskname="bp">
<arg value="rt"/>
<arg value="bp"/>
<arg value="mybuild"/>
<arg value="1"/>
</jfrog-cli>
</target>
</project>
{
"files": [
{
"aql": {
"items.find": {
"$and": [{
"sha256": {"$eq":"<sha256 of documentation1.txt>"},
"@version": {"$eq":"20190701-208"},
"name": {"$eq":"documentation1.txt"}
}]
}
},
"target": "${downloadBase}/diskspace/",
"flat": "true"
},
"target": "${downloadBase}/diskspace/",
"flat": "true"
},
{
"aql": {
"items.find": {
"$and": [{
"sha256": {"$eq":"<sha256 of documentation2.txt>"},
"@version": {"$eq":"20190701-208"},
"name": {"$eq":"documentation2.txt"}
}]
}
},
"target": "${downloadBase}/diskspace/",
"flat": "true"
},
{
"aql": {
"items.find": {
"$and": [{
"sha256": {"$eq":"<sha256 of documentation3.txt>"},
"@version": {"$eq":"20190701-3206"},
"name": {"$eq":"documentation3.txt"}
}]
}
},
"target": "${downloadBase}/diskspace/",
"flat": "true"
},
{
"aql": {
"items.find": {
"$and": [{
"sha256": {"$eq":"<sha256 of documentation4.txt>"},
"@version": {"$eq":"20190701-3206"},
"name": {"$eq":"documentation4.txt"}
}]
}
},
"target": "${downloadBase}/diskspace/",
"flat": "true"
}
]
}
{
"files": [
{
"aql": {
"items.find": {
"$and": [{
"sha256": {"$eq":"<sha256 of installer1>"},
"@version": {"$eq":"20190701-208"},
"name": {"$eq":installer1.run"}
}]
}
},
"target": "${downloadBase}/installers/",
"flat": "true"
},
{
"aql": {
"items.find": {
"$and": [{
"sha256": {"$eq":"<sha256 of installer2>"},
"@version": {"$eq":"20190701-208"},
"name": {"$eq":"installer2.run"}
}]
}
},
"target": "${downloadBase}/installers/",
"flat": "true"
},
{
"aql": {
"items.find": {
"$and": [{
"sha256": {"$eq":"<sha256 of installer3>"},
"@version": {"$eq":"20190701-3206"},
"name": {"$eq":"installer3.run"}
}]
}
},
"target": "${downloadBase}/installers/",
"flat": "true"
},
{
"aql": {
"items.find": {
"$and": [{
"sha256": {"$eq":"<sha256 of installer4>"},
"@version": {"$eq":"20190701-3206"},
"name": {"$eq":"installer4.run"}
}]
}
},
"target": "${downloadBase}/installers/",
"flat": "true"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment