UPDATED POST
I have written a script to create a CICD pipeline:
trigger:
- feature/pipeline
stages:
- stage: Build
displayName: 'Build and Test'
jobs:
- job: GoBuildJob
pool:
name: "Default"
demands:
- Agent.Name -equals Ubuntu-ESXI_VM_Build
steps:
- task: GoTool@0
inputs:
version: '1.20'
displayName: 'Installing Go'
- script: |
go mod init son-pipeline
go mod tidy
displayName: 'Initialize and Tidy Dependencies'
- script: go build -o $(Build.BinariesDirectory)/myproject
displayName: 'Building Go Project'
workingDirectory: '$(System.DefaultWorkingDirectory)/myproject'
- script: go test -v ./...
displayName: 'Run Unit Tests'
- script: |
cd $(Build.SourcesDirectory)/myproject
npm install
npm run build
displayName: 'Build Go project'
# Copy the Go binary to the staging directory
- task: CopyFiles@2
inputs:
SourceFolder: '$(Build.BinariesDirectory)'
Contents: 'myproject'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
displayName: 'Copy Built Binary to Staging Directory'
# Copy the package.json file to the staging directory
- task: CopyFiles@2
inputs:
SourceFolder: '$(Build.SourcesDirectory)/myproject' # Path to your project directory
Contents: 'package.json'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
displayName: 'Copy package.json to Staging Directory'
# Authenticate with the npm registry
# - task: npmAuthenticate@0
# inputs:
# workingFile: 'myproject/.npmrc' # Path to the .npmrc file
# # Publish the npm package to Azure Artifacts
# - script: |
# cd $(Build.ArtifactStagingDirectory)
# npm publish --registry=<ORG>/IP_CAL_SON/_packaging/SON-FEED/npm/registry/
# displayName: 'Publish npm Package to Azure Artifacts'
- task: Npm@1
inputs:
command: 'publish'
workingDir: '$(Build.SourcesDirectory)/myproject'
publishRegistry: 'useFeed'
publishFeed: '<FEEDid>'
- stage: Deploy
displayName: 'Deploy to Production'
jobs:
- job: DeployToProduction
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/feature/pipeline'))
pool:
name: "Default"
demands:
- Agent.Name -equals Ubuntu-ESXI_VM_Build
steps:
- script: echo "Deploying to production environment"
displayName: 'Deploy to Production - Placeholder'
Now what I want to do is I want to use Azure Artifacts for storing binaries. My target machine is Linux VM 24.04. Also how to write the CD part for this? I am new to this. I have looked in the official documentation but can't understand most things.
UPDATE
I have updated the code and I have followed this: https://learn.microsoft.com/en-us/azure/devops/artifacts/npm/npmrc?view=azure-devops&tabs=windows%2Cclassic
But at last I am getting SSL certificate error.
UPDATE-2
The logs are:
Starting: Npm
==============================================================================
Task : npm
Description : Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Azure Artifacts.
Version : 1.180.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/package/npm
==============================================================================
/home/cicd/.nvm/versions/node/v23.9.0/bin/npm --version
11.2.0
SYSTEMVSSCONNECTION exists true
SYSTEMVSSCONNECTION exists true
SYSTEMVSSCONNECTION exists true
SYSTEMVSSCONNECTION exists true
/home/cicd/.nvm/versions/node/v23.9.0/bin/npm config list
; "user" config from /home/cicd/myagent/_work/22/npm/2618.npmrc
//<ORG-link>/<FEEDid>/_packaging/b4025a17-a917-7a1f-b006-efe86260fa90/npm/registry/:_authToken = (protected)
registry = "<ORG-link>/***/_packaging/***/npm/registry/"
; "env" config from environment
userconfig = "/home/cicd/myagent/_work/22/npm/2618.npmrc"
; node bin location = /home/cicd/.nvm/versions/node/v23.9.0/bin/node
; node version = v23.9.0
; npm local prefix = /home/cicd/myagent/_work/22/s/myproject
; npm version = 11.2.0
; cwd = /home/cicd/myagent/_work/22/s/myproject
; HOME = /home/cicd
; Run `npm config ls -l` to show all defaults.
/home/cicd/.nvm/versions/node/v23.9.0/bin/npm publish
npm notice
npm notice 📦 [email protected]
npm notice Tarball Contents
npm notice 1.8MB main
npm notice 78B main.go
npm notice 229B package.json
npm notice Tarball Details
npm notice name: myproject
npm notice version: 1.0.0
npm notice filename: myproject-1.0.0.tgz
npm notice package size: 1.1 MB
npm notice unpacked size: 1.8 MB
npm notice shasum: dfa3f492f0625e5291d1313abb9d26719e4044b6
npm notice integrity: sha512-i5aLWxQ7Z55K3[...]oSmGoGXa7KfDw==
npm notice total files: 3
npm notice
npm notice Publishing to https://<ORG-link>/***/_packaging/***/npm/registry/ with tag latest and default access
npm error code UNABLE_TO_VERIFY_LEAF_SIGNATURE
npm error errno UNABLE_TO_VERIFY_LEAF_SIGNATURE
npm error request to https://<ORG-link>/***/_packaging/***/npm/registry/myproject failed, reason: unable to verify the first certificate
npm error A complete log of this run can be found in: /home/cicd/.npm/_logs/2025-03-12T07_13_23_246Z-debug-0.log
##[warning]Couldn't find a debug log in the cache or working directory
##[error]Error: Npm failed with return code: 1
Finishing: Npm
UPDATE-3
package.json
{
"name": "myproject",
"version": "1.0.0",
"description": "Hello go",
"main": "main",
"scripts": {
"build": "go build -o main"
},
"keywords": [],
"author": "Pritam",
"license": "ISC",
"type": "commonjs"
}
UPDATE-4
Logs of failed pipeline:
2025-03-12T07:13:21.7923275Z ##[section]Starting: Npm
2025-03-12T07:13:21.7926746Z ==============================================================================
2025-03-12T07:13:21.7926837Z Task : npm
2025-03-12T07:13:21.7926890Z Description : Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Azure Artifacts.
2025-03-12T07:13:21.7927005Z Version : 1.180.0
2025-03-12T07:13:21.7927052Z Author : Microsoft Corporation
2025-03-12T07:13:21.7927105Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/package/npm
2025-03-12T07:13:21.7927183Z ==============================================================================
2025-03-12T07:13:22.1261581Z [command]/home/cicd/.nvm/versions/node/v23.9.0/bin/npm --version
2025-03-12T07:13:22.2267972Z 11.2.0
2025-03-12T07:13:22.2325310Z SYSTEMVSSCONNECTION exists true
2025-03-12T07:13:22.7707096Z SYSTEMVSSCONNECTION exists true
2025-03-12T07:13:22.8022360Z SYSTEMVSSCONNECTION exists true
2025-03-12T07:13:22.8480602Z SYSTEMVSSCONNECTION exists true
2025-03-12T07:13:23.0770633Z [command]/home/cicd/.nvm/versions/node/v23.9.0/bin/npm config list
2025-03-12T07:13:23.1921628Z ; "user" config from /home/cicd/myagent/_work/22/npm/2618.npmrc
2025-03-12T07:13:23.1921768Z
2025-03-12T07:13:23.1922297Z <org-link>/<project-id>/_packaging/<feed-id>/npm/registry/:_authToken = (protected)
2025-03-12T07:13:23.1922557Z registry = "https://<org-link>/***/_packaging/***/npm/registry/"
2025-03-12T07:13:23.1922652Z
2025-03-12T07:13:23.1922748Z ; "env" config from environment
2025-03-12T07:13:23.1922800Z
2025-03-12T07:13:23.1922923Z userconfig = "/home/cicd/myagent/_work/22/npm/2618.npmrc"
2025-03-12T07:13:23.1922990Z
2025-03-12T07:13:23.1923128Z ; node bin location = /home/cicd/.nvm/versions/node/v23.9.0/bin/node
2025-03-12T07:13:23.1923272Z ; node version = v23.9.0
2025-03-12T07:13:23.1923397Z ; npm local prefix = /home/cicd/myagent/_work/22/s/myproject
2025-03-12T07:13:23.1923539Z ; npm version = 11.2.0
2025-03-12T07:13:23.1923654Z ; cwd = /home/cicd/myagent/_work/22/s/myproject
2025-03-12T07:13:23.1923769Z ; HOME = /home/cicd
2025-03-12T07:13:23.1923952Z ; Run `npm config ls -l` to show all defaults.
2025-03-12T07:13:23.1929653Z [command]/home/cicd/.nvm/versions/node/v23.9.0/bin/npm publish
2025-03-12T07:15:43.9402674Z npm notice
2025-03-12T07:15:43.9403412Z npm notice 📦 [email protected]
2025-03-12T07:15:43.9403560Z npm notice Tarball Contents
2025-03-12T07:15:43.9408438Z npm notice 1.8MB main
2025-03-12T07:15:43.9408862Z npm notice 78B main.go
2025-03-12T07:15:43.9408996Z npm notice 229B package.json
2025-03-12T07:15:43.9409128Z npm notice Tarball Details
2025-03-12T07:15:43.9409341Z npm notice name: myproject
2025-03-12T07:15:43.9411646Z npm notice version: 1.0.0
2025-03-12T07:15:43.9411928Z npm notice filename: myproject-1.0.0.tgz
2025-03-12T07:15:43.9412067Z npm notice package size: 1.1 MB
2025-03-12T07:15:43.9412194Z npm notice unpacked size: 1.8 MB
2025-03-12T07:15:43.9412326Z npm notice shasum: dfa3f492f0625e5291d1313abb9d26719e4044b6
2025-03-12T07:15:43.9412567Z npm notice integrity: sha512-i5aLWxQ7Z55K3[...]oSmGoGXa7KfDw==
2025-03-12T07:15:43.9412697Z npm notice total files: 3
2025-03-12T07:15:43.9412805Z npm notice
2025-03-12T07:15:43.9412975Z npm notice Publishing to https://<org-link>/***/_packaging/***/npm/registry/ with tag latest and default access
2025-03-12T07:15:43.9413176Z npm error code UNABLE_TO_VERIFY_LEAF_SIGNATURE
2025-03-12T07:15:43.9413312Z npm error errno UNABLE_TO_VERIFY_LEAF_SIGNATURE
2025-03-12T07:15:43.9413517Z npm error request to https://<org-link>/***/_packaging/***/npm/registry/myproject failed, reason: unable to verify the first certificate
2025-03-12T07:15:43.9414276Z npm error A complete log of this run can be found in: /home/cicd/.npm/_logs/2025-03-12T07_13_23_246Z-debug-0.log
2025-03-12T07:15:43.9710955Z ##[warning]Couldn't find a debug log in the cache or working directory
2025-03-12T07:15:43.9718662Z ##[error]Error: Npm failed with return code: 1
2025-03-12T07:15:43.9720658Z ##[section]Finishing: Npm
