diff --git a/pipelines/templates/install-go-from-aquaconfig.yml b/pipelines/templates/install-go-from-aquaconfig.yml new file mode 100644 index 00000000..02afe006 --- /dev/null +++ b/pipelines/templates/install-go-from-aquaconfig.yml @@ -0,0 +1,40 @@ +--- +parameters: + # - name: GO_VERSION # set dynamically in the task + # type: string + # default: 1.x + - name: GOPATH + type: string + default: $(Agent.HomeDirectory)/go + - name: workingDirectory + type: string + default: $(Build.SourcesDirectory) +steps: + - bash: | + # Search for the aqua.yaml file + if [[ -f "aqua.yaml" ]]; then + file="aqua.yaml" + elif [[ -f "aqua/aqua.yaml" ]]; then + file="aqua/aqua.yaml" + elif [[ -f ".aqua/aqua.yaml" ]]; then + file=".aqua/aqua.yaml" + else + echo "Error: aqua.yaml file not found." + echo "##vso[task.logissue type=warning]unable to find aqua config, behavior with tools might unpredictable" + fi + echo "found aqua.yaml at: $file" + GO_VERSION=$(grep -oP 'golang/go@go\\K[\\d\\.]+' "${file}") + echo "##vso[task.setvariable variable=GO_VERSION;isreadonly=true;isoutput=true;]${GO_VERSION}" + echo "##vso[task.setvariable variable=GO_VERSION;isreadonly=true;]${GO_VERSION}" + echo "👉 use go version: ${GO_VERSION}" + displayName: set-go-version + name: getgoversion + workingDirectory: ${{ parameters.workingDirectory }} + # condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT')) # won't work on windows + + - task: GoTool@0 + displayName: install-go + # condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT')) + inputs: + version: $(getgoversion.GO_VERSION) + goPath: $(GOPATH)