azure - Create a CD script using ADO server - Stack Overflow

admin2025-04-17  0

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: ;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 and authenticated registries like Azure Artifacts.
Version      : 1.180.0
Author       : Microsoft Corporation
Help         : 
==============================================================================
/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 
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1744884633a272463.html

最新回复(0)