Quantcast
Channel: How to log into Azure DevOps Artifact feed without token - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by Merlin Liang - MSFT for How to log into Azure DevOps Artifact feed without token

$
0
0

How to log into Azure DevOps Artifact feed without token

Just as what you tried, using $(System.AccessToken) should work fine. Just share my steps and some key points which you should pay attention to.

Configuration:

Here is part of my build.gradle file, and I applied the $(System.AccessToken) to publish package to my feed:

publishing {    publications {        myPublication(MavenPublication) {            groupId 'com.microsoft.core'            artifactId 'mock='            version "${version}"            artifact "build/libs/mock-${version}.jar"        }    }    // Repositories *to* which Gradle can publish artifacts    repositories {        maven {            url 'https://pkgs.dev.azure.com/{org name}/_packaging/{project name}/{feed name}/v1'            credentials {               username "Azure DevOps Services"               //password System.getenv("AZURE_ARTIFACTS_ENV_ACCESS_TOKEN") != null ? System.getenv("AZURE_ARTIFACTS_ENV_ACCESS_TOKEN") : vstsMavenAccessToken               password System.getenv("SYSTEM_ACCESSTOKEN")            }        }    }}

The part of YAML definition:

- task: Gradle@2  displayName: Gradle Publish  inputs:    workingDirectory: ''    gradleWrapperFile: 'gradlew'    gradleOptions: '-Xmx3072m'    javaHomeOption: 'JDKVersion'    jdkVersionOption: '1.8'    jdkArchitectureOption: 'x64'    publishJUnitResults: true    tasks: 'publish'  condition: always()  env:    SYSTEM_ACCESSTOKEN: $(System.AccessToken)

You can see my publish log and it published successfully:

enter image description here


Except the above script configuration, you also make configuration on your feed setting. Because the pipeline actual using Collection/project service account to access and perform actions in feed.

Please go feed setting, search and add Project Collection Build Service ({org name}) and {Porject name} Build Service ({org name}) into this permission setting. And assign them Owner role.

Now, re-build your pipeline and you will see it could succeed to access feed.


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>