Русский English Tags View Sergey Zolotaryov's profile on LinkedIn Sign-in
Configuring Bower authentication in Jenkins
Permanent link 20-05-2019 anydoby java

Recently I was building a little monolythic (yeah, it's so nice to go back monolythic again) web app using Springboot and Polymer and got juite frustrated that our company's Artifactory is protected even for readonly access and even for public repositories.

Npm worked fine in our pre-configured Jenkins, because it had a /home/jenkins/.npmrc setup with authentication credentials (hashed of course). Unfortunately this hash does not quite work for Bower. It needs another hashed form (it's some artifactory thing of course). Here's the solution I found that works reasonably secure for Bower.

In your jenkinsfile you declare something like this before your stages:


environment {
  BOWER_CREDS = credentials('your-artifactory-credentials-id')
  bower_registry = "https://${env.BOWER_CREDS_USR}:${env.BOWER_CREDS_PSW}@artifactory.mycompany.net/artifactory/api/bower/releases"
}

Of course someone (or you if you know the artifactory NPA user/password) has to create Jenkins credentials with the correct id.

Bower will pick up environment variable bower_registry and perform a login when necessary. The rest of bower properties you can commit to your git repository if needed in a .bowerrc file.

Stay safe.

Add a comment

Previous article How to convert JPG's to a single PDF in Linux without losing quality