How to get an Azure pipeline for Go to work - azure

The default .yaml file provided by the ADO pipeline fails. There's been an issue open for over a year on it and the problem still exists.
I tried this .yaml file from learn.microsoft but it fails with the error below. Does someone have a .yaml file that works for a Go pipeline in Azure DevOps?
trigger:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- task: GoTool#0
inputs:
version: '1.13.5'
- task: Go#0
inputs:
command: 'get'
arguments: '-d'
workingDirectory: '$(System.DefaultWorkingDirectory)'
- task: Go#0
inputs:
command: 'build'
workingDirectory: '$(System.DefaultWorkingDirectory)'
- task: CopyFiles#2
inputs:
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts#1
inputs:
artifactName: drop
Here's the error:
##[section]Starting: Go
==============================================================================
Task : Go
Description : Get, build, or test a Go application, or run a custom Go command
Version : 0.210.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/go
==============================================================================
[command]/opt/hostedtoolcache/go/1.13.5/x64/bin/go get -d
go get .: path /home/vsts/work/1/s is not a package in module rooted at /home/vsts/work/1/s
##[error]The Go task failed with an error: Error: The process '/opt/hostedtoolcache/go/1.13.5/x64/bin/go' failed with exit code 1
##[section]Finishing: Go

Just try this :
trigger:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- task: GoTool#0
inputs:
version: '1.13.5'
- task: Go#0
inputs:
command: 'get'
arguments: '-v all'
workingDirectory: '$(System.DefaultWorkingDirectory)'
- task: Go#0
inputs:
command: 'build'
workingDirectory: '$(System.DefaultWorkingDirectory)'
- task: CopyFiles#2
inputs:
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts#1
inputs:
artifactName: drop

Related

Azure DevOps Failed to update App Service configuration details

I am trying to deploy a WebApp in Azure DevOps and I am getting this error:
[warning]Failed to update App Service configuration details. Error: Error: Failed to update App service 'webapp' configuration. Error: BadRequest - Required parameter AccessKey is missing.
I can't figure out why this is happening, it was working originally and the error came about the other day. Nothing has changed with the WebApp code, no new settings were added. The artifact goes into place and the website works but I get this error, then on another run, the pipeline will fail, so I only have one successful run, then I have to go and delete the web app to have another successful run.
Here is my YAML Code:
trigger:
branches:
include:
- master
pr: none
pool:
vmImage: windows-latest
resources:
repositories:
- repository: Website
name: VALUE/Website
path:
- include: /Website
type: git
ref: VALUE
variables:
System.Debug: false
azureSubscription: VALUE
RG: rg_example
Location: UK South
containername: private
appconnectionname: VALUE
stages:
- stage: build_website_files
displayName: Building Main Website Files
jobs:
- job: job1
displayName: Create And Publish Artifact
steps:
- checkout: Website
- task: CmdLine#2
inputs:
script: 'mkdir Website'
workingDirectory: $(Build.ArtifactStagingDirectory)
- task: CmdLine#2
inputs:
script: 'echo $(Build.ArtifactStagingDirectory)/Website'
- task: DotNetCoreCLI#2
displayName: dotnet restore
inputs:
command: restore
projects: Website.csproj
- task: NodeTool#0
displayName: Install Node .js
inputs:
versionSpec: 14.17.3
force32bit: false
checkLatest: false
- script: |
npm install -g #angular/cli#12.1.3
npm install
ng build --prod
displayName: npm install and build
- task: DotNetCoreCLI#2
displayName: dotnet build
inputs:
projects: Website.csproj
arguments: '--configuration Release'
- task: DotNetCoreCLI#2
displayName: dotnet restore unit tests
inputs:
command: restore
projects: UnitTests/UnitTests.csproj
- task: DotNetCoreCLI#2
displayName: dotnet Test
inputs:
command: test
projects: UnitTests/UnitTests.csproj
arguments: '--configuration Release'
- task: DotNetCoreCLI#2
displayName: dotnet publish
inputs:
command: publish
projects: Website.csproj
arguments: --configuration Release --output $(Build.ArtifactStagingDirectory)/Website
zipAfterPublish: true
modifyOutputPath: false
- task: PublishPipelineArtifact#1
displayName: Publish Pipeline Artifact
inputs:
targetPath: $(Build.ArtifactStagingDirectory)/Website
artifact: Website
publishLocation: pipeline
- stage: put_website_files_into_place
displayName: website_files_into_place
dependsOn: build_website_files
jobs:
- job: job2
displayName: Create Web App
#dependsOn: job1
steps:
- download: none
- task: DownloadPipelineArtifact#2
displayName: Download Build Artifacts
inputs:
patterns: '**/*.zip'
path: $(Build.ArtifactStagingDirectory)/Website/
- task: AzureWebApp#1
displayName: 'Azure Web App Deploy: value'
inputs:
package: $(Build.ArtifactStagingDirectory)/**/*.zip
azureSubscription: $(azureSubscription)
ConnectedServiceName: $(appconnectionname)
appName: value
ResourceGroupName: $(RG)

Use powershell script to customize azure devOps pipeline?

I have an azure function app that is running on Azure. I am now trying to configure the application based on a powershell script. This powershell script is being used to create azure resources (Ex: KeyVault, ApplicationInsights...) that will be then used by the function app. I created the powershell script and my question here is how can I add the powershell script in the yaml file which is responsible to deploy the application. The powershell script is located in the repository under the name functionapp.ps1 . The idea here is to run the powershell script once the build is finished so in the deploy stage. What I did so far is the following:
stages:
- stage: Build
displayName: Build stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: DotNetCoreCLI#2
displayName: Build
inputs:
command: 'build'
projects: |
$(workingDirectory)/*.csproj
arguments: --output $(System.DefaultWorkingDirectory)/publish_output --configuration Release
- task: ArchiveFiles#2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/publish_output'
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true
- publish: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
artifact: drop
- stage: Deploy
displayName: Deploy stage
dependsOn: Build
condition: succeeded()
jobs:
- deployment: Deploy
displayName: Deploy
environment: 'development'
pool:
vmImage: $(vmImageName)
strategy:
runOnce:
deploy:
steps:
- task: CmdLine#2
inputs:
script: |
echo '$(System.DefaultWorkingDirectory)'
dir
- task: PowerShell#2
inputs:
targetType: 'filePath'
filePath: $(System.DefaultWorkingDirectory)/functionapp.ps1
- task: AzureFunctionApp#1
displayName: 'Azure functions app deploy'
inputs:
azureSubscription: '$(azureSubscription)'
appType: functionApp
appName: $(functionAppName)
package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
When the stages are being run and it arrives to this task I get the following error:
##[error]Invalid file path 'D:\a\1\s\functionapp.ps1'. A path to a .ps1 file is required.
I tried using the command line task to check the default working directory and I got the following result: D:\a\1\s
I still don't know what I am missing here and why I am getting this error. Can someone please give me a concrete solution to this problem ?
I ended up having the same error. Can someone please tell me what is the issue here ?

Yaml Azure Devops TerraformInstaller is ambiguous

Here i am trying to create aks using terraform, using azure-devops to deploy the resource to azure.
pipeline job has failed within a sec.
below is the pipeline code.
trigger:
- main
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: TerraformValidate
jobs:
- job: TerraformValidateJob
continueOnError: false
steps:
- task: PublishPipelineArtifact#1
displayName: Publish Artifacts
inputs:
targetPath: '$(System.DefaultWorkingDirectory)/terraform-manifests'
artifact: 'terraform-manifests-out'
publishLocation: 'pipeline'
- task: TerraformInstaller#0
displayName: Terraform Install
inputs:
terraformVersion: 'latest'
- task: TerraformCLI#0
displayName: Terraform Init
inputs:
command: 'init'
workingDirectory: '$(System.DefaultWorkingDirectory)/terraform-manifests'
backendType: 'azurerm'
backendServiceArm: ''
backendAzureRmResourceGroupName: ''
backendAzureRmStorageAccountName: ''
backendAzureRmContainerName: ''
backendAzureRmKey: 'aks-base.tfstate'
allowTelemetryCollection: false
- task: TerraformCLI#0
displayName: Terraform Validate
inputs:
command: 'validate'
workingDirectory: '$(System.DefaultWorkingDirectory)/terraform-manifests'
allowTelemetryCollection: false
getting below error :
I have installed both the extensions:
After installing these two extensions at the same time, I can reproduce the same issue.
The root cause of the issue is that terraform install task exists in both extensions at the same time.
Their simplified version of YAML task names are all TerraformInstaller#0.
To solve this issue, you can uninstall one of the two extensions.
Or you can specify the full name.
For example:
- task: ms-devlabs.custom-terraform-tasks.custom-terraform-installer-task.TerraformInstaller#0
OR
- task: charleszipp.azure-pipelines-tasks-terraform.azure-pipelines-tasks-terraform-installer.TerraformInstaller#0

WARN unable to find package.json for plottable

When running a build for storybook via an Azure devops pipeline I get the above mentioned error.
I've tried to completely remove this package(plottable) from my project but I keep getting this error and it causes my webpack build to get stuck.
This error doesn't occur locally.
My pipeline:
trigger:
batch: true
branches:
include:
- master
stages:
- stage: develop_build_deploy_stage
pool:
name: Default
demands:
- msbuild
- visualstudio
jobs:
- job: develop_build_deploy_job
steps:
- checkout: self
clean: true
persistCredentials: true
- task: NodeTool#0
displayName: Install Node
inputs:
versionSpec: '12.x'
- task: PowerShell#2
displayName: 'Install Dependencies'
inputs:
targetType: 'inline'
script: |
npm install
- task: PowerShell#2
displayName: 'Increment version'
inputs:
targetType: 'inline'
script: |
git checkout master
git pull origin master
git config --global user.email "d#gmail.com"
git config --global user.name "Build Agent"
npm version patch -m "Increment Version [skip ci]" --force
git push
- task: PowerShell#2
displayName: 'Build Project'
inputs:
targetType: 'inline'
script: |
npm run build-storybook
npm run build
- task: CopyFiles#2
displayName: 'Copy storybook-static Files'
inputs:
sourceFolder: '$(Build.SourcesDirectory)/storybook-static'
contents: '**'
targetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts#1
displayName: 'Publish storybook-static Files to ArtifactStagingDirectory'
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: Storybook
- task: S3Upload#1
displayName: 'Upload storybook-static to S3'
inputs:
awsCredentials: 'my-s3'
regionName: 'us-east-1'
bucketName: 'my-s3-bucket'
sourceFolder: $(Build.ArtifactStagingDirectory)
- task: Npm#1
displayName: 'Publish to Feed'
inputs:
command: 'publish'
publishRegistry: 'useFeed'
publishFeed: '#####'
How would I go about resolving this problem?
I still don't know what caused this to be the case but for some reason the changes I had made on my branch weren't being picked up and an import that I had removed wasn't removed on the branch that was being built on.
So in the end it was trying to import a package which I had removed as a dependency.

azure devops build and deploy to app service

I have create an empty project on dev.azure.com
I have cloned the repository on my local computer.
I have run this command in the main folder:
$ dotnet new mvc
I have create this azure-pipelines.yml file:
trigger:
- master
pool:
vmImage: 'windows-latest'
steps:
- task: DotNetCoreCLI#2
inputs:
command: 'restore'
feedsToUse: 'select'
- task: DotNetCoreCLI#2
inputs:
command: 'build'
- task: DotNetCoreCLI#2
inputs:
command: 'publish'
publishWebProjects: true
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'artifact2'
I have add, commit and pushed files on dev.azure.com (on master branch)
I have this warning message:
##[warning]Directory 'd:\a\1\a' is empty. Nothing will be added to build artifact 'artifact2'.
I have create a release pipeline but i get an error:
##[error]Error: No package found with specified pattern: D:\a\r1\a\**\*.zip<br/>Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.
I do not understand what is wrong in my azure-pipelines.yml for artifact production...
Thanks
It seems that there is an issue where the published dlls are placed. Try the yaml below, that I have explicitly set the output directory for the published dlls and zipped the files after publish(that would probably be your next issue). I have also explicitly set in which folder to look for the published folder in order to publish the artifact.
trigger:
- master
pool:
vmImage: 'windows-latest'
steps:
- task: DotNetCoreCLI#2
inputs:
command: 'restore'
feedsToUse: 'select'
- task: DotNetCoreCLI#2
inputs:
command: 'build'
- task: DotNetCoreCLI#2
inputs:
command: 'publish'
publishWebProjects: true
modifyOutputPath: true
arguments: '--configuration $(BuildConfiguration) --output "$(build.artifactstagingdirectory)"'
zipAfterPublish: true
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'artifact2'

Resources