标签: azure-pipelines

从 PowerShell 发布 PipelineArtifact

有没有办法从 PowerShell 脚本发布 Pipeline Artefact ?

我想避免创建额外的管道任务来发布文件。

代替:

      - task: PublishPipelineArtifact@1
        displayName: 'publish azuredeploy.parameters.json'
        inputs:
          targetPath: $(System.DefaultWorkingDirectory)/work
          artifactName: azuredeploy parameters
Run Code Online (Sandbox Code Playgroud)

我宁愿做这样的事情:

      - task: PowerShell@2
        displayName: 'replace ARM parameters'
        inputs:
          targetType: inline
          pwsh: true
          script: |
              # input
              $manifest = ReadObject "work/manifest.json"

              # process
              ReplaceArmTemplateParameters $manifest.modules

              # output
              PublishPipelineArtefact -targetPath "work/manifest.json" -artefactName "azuredeploy-parameters"


Run Code Online (Sandbox Code Playgroud)

也许构建代理提供了一个可以在PowerShell@2任务中使用的 API,例如:Agent.Plugins.PipelineArtifact.PublishPipelineArtifactTask::PipelineArtifactTaskPluginBaseV1

有任何想法吗?

(ps:这个问题好像有点过时了)

powershell azure-devops azure-pipelines

1
推荐指数
1
解决办法
1917
查看次数

分支中的 Azure .yaml 管道文件策略

我有一个 git 分支策略如下:

分支机构:

experimental-feature integrates to develop

develop integrates to master
Run Code Online (Sandbox Code Playgroud)

在每个分支中,我都有一个名为 azure-pipelines.yaml 的文件,其中包含管道构建的规则,每个规则在每个分支中都不同,因为每个文件都有一个与trigger分支名称匹配的属性名称。

IE:master 分支有一个 azure-pipelines.yml,它有一个名为“master”的触发器属性,因为对于 master 分支上的每个更改,都会触发管道。开发和实验功能也是如此。到目前为止,一切都很好。

develop现在,我不明白为什么当我从git创建拉取请求时,master无法识别每个azure-pipeline.yaml(开发和主控)之间的更改。这很好,因为azure-pipeline.yml开发中的内容总是会覆盖master azure-pipeline.yaml,而我不希望这样。

experimental-feature但是,当我通过拉取请求集成时, gitdevelop的更改确实会识别我不想要的文件之间的更改。

有人可以在这里启发我吗?我在微软文档中也找不到它是如何工作的。

.net git azure azure-devops azure-pipelines

1
推荐指数
1
解决办法
2083
查看次数

如何使用 Azure DevOps Pipeline 打开/关闭 Azure AppService 的“仅限 Https”?

我的网站有一个 Azure 发布管道。对于该发布管道中的任务之一,我需要禁用 HTTPS ONLY 选项(它可在 Azure 门户中的 SSL/TLS Blade 下使用,检查下图)。执行该任务后,我想再次打开“HTTPS ONLY”。

有没有一种简单的方法可以做到这一点?

在此输入图像描述

PS:我已经审查过这个问题 ,但我不想使用 ARM 模板

https azure azure-devops azure-pipelines azure-appservice

1
推荐指数
1
解决办法
1153
查看次数

构建和发布工件任务问题

PublishBuildArtifacts@1
https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/publish-build-artifacts?view=azure-devops
问题:
(1)指定artifactName的结果是什么?从文档中尚不清楚。我在大多数示例中都看到了这一点,它成为 $(Build.ArtifactStagingDirectory) 路径中的子文件夹。如果我有额外的任务来构建包含多个项目的解决方案的不同部分,我可以指定另一个例如。'drop2' 还是这个“drop”很特别?

(2) 如果使用私有 nuget feed,为什么还必须包含 nuget.config 文件来引用该包?私人源是通过 azure 项目设置中的服务连接设置的。看来你应该可以离开了

feedsToUse: 'config'
nugetConfigPath: 'Nuget.config'
Run Code Online (Sandbox Code Playgroud)

(3) 如果我在一个解决方案中有多个项目 - 例如。.net core Web 应用程序以及多个针对 .net standard 2.x 的类库以及 .net core 控制台应用程序,何时使用以下任一任务更好:
VSBuild@1 或 DotNetCoreCLI@2
最终结果构建的重点是我在输出
drop 和 Dropsrvc 中有两个子文件夹,这正是我所需要的。Dropsvc 将我的服务项目保存在 zip 文件中

我想将 .net core Web 应用程序发布为发布管道中的可复制文件夹。我已经完成了这项工作,主要是通过重新利用我在 .net 框架项目中所做的另一个构建来进行反复试验,但现在我想知道我是否应该使用 DotNetCoreCLI 任务?

这是我的 yaml 文件。如何替代VS

# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build …
Run Code Online (Sandbox Code Playgroud)

azure-pipelines

1
推荐指数
1
解决办法
7927
查看次数

使用 Helm 3 将 Azure DevOps Pipeline 部署到 Kubernetes:没有此类文件或目录

我有一个 Asp.net Core 项目,我正在尝试使用 Helm 3 创建用于 Kubernetes 部署的 Azure DevOps Pipeline。

该项目的结构是:

服务器图表服务器 Chart.yaml 控制器等。

当前的构建管道会构建 docker 映像,并将其上传到 Azure 容器注册表。

错误发生在 HelmDeploy 任务 'package' => ChartPath:

在此输入图像描述

这是部署的管道阶段:

  - stage: 'Deploy'
  displayName: 'Deploy the container'
  dependsOn: Build
  jobs:
  - deployment: Deploy
    displayName: Deploy
    pool:
      vmImage: 'ubuntu-latest'
    environment: 'staging'
    strategy:    
      runOnce:
        deploy:
          steps:        
          - task: HelmInstaller@0
            inputs:
              helmVersion: 'latest'
              installKubectl: true
          
          - task: HelmDeploy@0
            inputs:
              command: 'package'
              chartPath: Server/charts/server

          - task: HelmDeploy@0
            inputs:
              connectionType: 'Kubernetes Service Connection'
              kubernetesServiceConnection: 'Staging-592588480'
              namespace: 'staging' …
Run Code Online (Sandbox Code Playgroud)

azure-devops azure-pipelines kubernetes-helm

1
推荐指数
1
解决办法
2713
查看次数

如何在 Azure DevOps 中使部分成功的阶段变为失败?

我正在发布管道上运行纽曼测试,但是当测试出错时,它只是将该阶段标记为部分成功,但我想让它无法触发自动重新部署触发器。这可能吗?

在此输入图像描述

azure azure-devops azure-pipelines

1
推荐指数
1
解决办法
6507
查看次数

当failOnStderr: true时,Azure脚本任务会出现bash错误,这并不是没有这个标志

我有有线行为\n当任务中未设置failOnStderr: true 时一切正常,但是
\n当我使用failOnStderr: true 调用这样的脚本任务时:

\n
- script:  |\n     echo \'Start invoking Fastfile\'\n     fastlane release --verbose projectName:${{parameters.projectName}} appIdentifier:${{parameters.appIdentifier}} versionNumber:${{parameters.versionNumber}} buildNumber:${{parameters.buildNumber}} plistFileFtpBasePath:${{parameters.plistFileFtpBasePath}} ArtifactsDirectory:$(System.ArtifactsDirectory)\n     echo \'Done invoking Fastfile\'\n    failOnStderr: true \n    workingDirectory: \'$(System.ArtifactsDirectory)/ios_artifacts\'\n    displayName: \'create keychain invoke fastlane\'\n
Run Code Online (Sandbox Code Playgroud)\n

我收到此错误:

\n
2020-09-30T07:54:45.8179430Z INFO [2020-09-30 07:54:45.81]: [32mfastlane.tools finished successfully \xc3\xb0\xc5\xb8\xc5\xbd\xe2\x80\xb0[0m\n2020-09-30T07:54:45.8917310Z Done invoking Fastfile\n2020-09-30T07:54:45.8948720Z \n2020-09-30T07:54:45.9020160Z ##[error]Bash wrote one or more lines to the standard error stream.\n2020-09-30T07:54:45.9033610Z ##[error]/Users/runner/hostedtoolcache/Ruby/2.7.1/x64/lib/ruby/gems/2.7.0/gems/fastlane-2.161.0/fastlane_core/lib/fastlane_core/ui/interface.rb:141: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to …
Run Code Online (Sandbox Code Playgroud)

azure azure-devops azure-pipelines azure-devops-pipelines

1
推荐指数
1
解决办法
1万
查看次数

在 Azure DevOps-Pipeline 中找不到上一步中的文件

在管道中我有两个不同的步骤。第一个生成一些文件,第二个应该将这些文件作为输入。

该管道的 Yaml 如下:

name: myscript
stages:
- stage: Tes/t
displayName: owasp-test
jobs:

- job: owasp_test
  displayName: run beasic checks for site
  pool:
    name: default
    demands: Agent.OS -equals Windows_NT

  steps:

  - task: DotNetCoreCLI@2
    inputs:
      command: 'build'
      projects: '**/*.sln'
  - task: dependency-check-build-task@5
    inputs:
      projectName: 'DependencyCheck'
      scanPath: '**/*.dll'
      format: 'JUNIT'
  - task: PublishTestResults@2
    inputs:
      testResultsFormat: 'JUnit'
      testResultsFiles: '**/*-junit.xml'
Run Code Online (Sandbox Code Playgroud)

返回dependency-check-build-task一个 XML 文件:

File upload succeed.
Upload 'P:\Azure-Pipelines-Agent\_work\2\TestResults\dependency-check\dependency-check-junit.xml' to file container: '#/11589616/dependency-check'
Associated artifact 53031 with build 21497
Run Code Online (Sandbox Code Playgroud)

以下步骤 ( PublishTestResults) …

azure-devops azure-pipelines

1
推荐指数
1
解决办法
1026
查看次数

DevOps 管道 Replace() 函数未按预期工作

我正在尝试在 DevOps 管道中使用替换函数,如https://learn.microsoft.com/en-us/azure/devops/pipelines/process/expressions?view=azure-devops#replace中所述

对于以下 yml,我期望输出为This Should be Steak but it is Steak,但实际输出为This Should be Steak but it is Beef

variables:
  foo: 'beef'
  bar: $[replace('$(foo)', 'beef', 'steak')]

pool:
  vmImage: 'ubuntu-latest'
steps:
- script: echo This should be steak but it is $(bar)
Run Code Online (Sandbox Code Playgroud)

我也尝试过这会产生相同的输出

variables:
  foo: 'beef'

pool:
  vmImage: 'ubuntu-latest'
steps:
- script: echo This should be steak but it is ${{ replace('$(foo)', 'beef', 'steak') }}
Run Code Online (Sandbox Code Playgroud)

yaml azure-devops azure-pipelines

1
推荐指数
1
解决办法
6726
查看次数

从 api 将参数传递给 devops 构建管道

我无法理解我需要做什么...但我有一个构建管道...下面是我用于测试的基本脚本。
我希望能够通过 api 和 powershell 添加/更新参数。我不确定这是否是实现此目的的最佳方法,但当我手动添加参数时,它似乎运行良好。当我传递参数时,它不会粘住。任何帮助将不胜感激......即使我应该在其他地方发布我的查询。谢谢

  1. 管道脚本

     variables:
        patchgroup: test
    
     jobs: 
     - template: patch-template.yml  
    
       parameters:    
         patchgroup: $(patchgroup)    
         sqlservers:      
           - sqlserver: name: ""
    
    Run Code Online (Sandbox Code Playgroud)
  2. 补丁模板文件

    parameters:
      sqlservers: {}
      patchgroup: ''
    
    jobs:
    - ${{ each sqlserver in parameters.sqlservers }}:
      - template: patch-tasks.yml
        parameters:
          sqlserver: ${{ sqlserver.name }}
          patchgroup: ${{ parameters.patchgroup }}
    
    Run Code Online (Sandbox Code Playgroud)
  3. 补丁任务参数:sqlserver: '' patchgroup: ''

     jobs:
       - job: 
         displayName: '${{ parameters.sqlserver }}--set-up-stuff'
         steps:
         - task: PowerShell@2
           inputs:
             targetType: 'inline'
             script: |
               Write-Host "Patchgroup '${{ parameters.patchgroup }}'"
               Write-Host "sqlserver '${{ parameters.sqlserver }}'"
    
    Run Code Online (Sandbox Code Playgroud)
  4. powershell脚本

     $defurl …
    Run Code Online (Sandbox Code Playgroud)

api powershell build devops azure-pipelines

1
推荐指数
1
解决办法
2609
查看次数