Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 将az工件通用下载的输出分配给变量_Bash_Jenkins_Artifactory_Azure Cli - Fatal编程技术网

Bash 将az工件通用下载的输出分配给变量

Bash 将az工件通用下载的输出分配给变量,bash,jenkins,artifactory,azure-cli,Bash,Jenkins,Artifactory,Azure Cli,我有个问题。是否可以将通用下载的输出分配给变量? 我有一份Jenkins的工作,在shell中有这样的脚本: az artifacts universal download \ --organization "sampleorganization" \ --project "sampleproject" \ --scope project \ --feed "sample-artifacts

我有个问题。是否可以将通用下载的输出分配给变量? 我有一份Jenkins的工作,在shell中有这样的脚本:

    az artifacts universal download \
      --organization "sampleorganization" \
      --project "sampleproject" \
      --scope project \
      --feed "sample-artifacts" \
      --name $PACKAGE \
      --version $VERSION \
      --debug \
      --path .
{
  "name": "test_name",
  ....
}
name=$(az ...... --query name -o tsv)
$name = $(az ...... --query name -o tsv)
然后,我希望使用以下命令将文件传输到artifactory:

curl -v -u $ARTIFACTORY_USER:$ARTIFACTORY_PASS -X PUT https://artifactory.com/my/test/repo/my_test_file_{VERSION}
我运行了这个作业,但注意到我传递给了artifactory空文件。它创建了我的{test}文件{VERSION},但它有0 mb。据我所知,我只是用curl创建了一个空文件。所以我想把az下载的输出传递给artifactory repo。可能吗?我该怎么做

我知道我需要将文件输出分配给变量并将其传递给curl,如下所示:

$MyVariableToPass=az工件通用下载输出

然后将这个变量传递给curl

可能吗?如何在Jenkins之间传递触发shell作业的文件到artifactory? 而且我现在没有使用任何插件


请提供帮助。

可能的解决方案是使用VM作为Jenkins的代理,然后在VM内安装Azure CLI。您可以在该节点中运行该任务。例如,要使用CLI命令的值设置变量,输出如下所示:

    az artifacts universal download \
      --organization "sampleorganization" \
      --project "sampleproject" \
      --scope project \
      --feed "sample-artifacts" \
      --name $PACKAGE \
      --version $VERSION \
      --debug \
      --path .
{
  "name": "test_name",
  ....
}
name=$(az ...... --query name -o tsv)
$name = $(az ...... --query name -o tsv)
然后您可以如下设置变量:

    az artifacts universal download \
      --organization "sampleorganization" \
      --project "sampleproject" \
      --scope project \
      --feed "sample-artifacts" \
      --name $PACKAGE \
      --version $VERSION \
      --debug \
      --path .
{
  "name": "test_name",
  ....
}
name=$(az ...... --query name -o tsv)
$name = $(az ...... --query name -o tsv)
这是在Linux系统中实现的。如果它在Windows中,您可以这样设置:

    az artifacts universal download \
      --organization "sampleorganization" \
      --project "sampleproject" \
      --scope project \
      --feed "sample-artifacts" \
      --name $PACKAGE \
      --version $VERSION \
      --debug \
      --path .
{
  "name": "test_name",
  ....
}
name=$(az ...... --query name -o tsv)
$name = $(az ...... --query name -o tsv)

我知道,下载文件的命令不会输出文件的内容。因此,如果要将文件内容设置为变量,则不合适。

此问题有任何更新吗?它能解决你的问题吗?如果它适合你,请接受它。