You probably want to have one PAT (Personal Access Token) for Azure DevOps in Jenkins Credentials and use it not only for getting source code from GIT, but also for getting NuGet packages for build, right?
So, you need the withCredentials construct with an environment variable VSS_NUGET_EXTERNAL_FEED_ENDPOINTS to be used like this:
Perhaps, your project has a database-first approach. So, you need an instance of your database for debugging and testing of code.
Nowadays teams can be spread over different regions, having no ability to share a single database instance (which would also be a bad practice because of dependency introduction and drift acceleration).
If your production database is not much evolving in its schema and has a moderate size, such database is a good candidate to be handled as an artefact.
Database artefacts are just right for:
Reproducing of bugs by deploying a certain version of a database.
Testing migrations by redeploying a version multiple times.
The good case for making an artefact from a production database is when its schema is managed by some centralized software (not one that’s going to be developed) and you have to just adapt to database changes.
The thing that can surprise a developer during deployment of a database in his / her local environment is SqlPackage error like:
Error SQL72014: .Net SqlClient Data Provider: Msg 15401, Level 16, State 1, Line 1 Windows NT user or group 'DOMAIN\ReportJobs' not found. Check the name again.
The command CREATE USER [DOMAIN\...] WITHOUT LOGIN; somewhy (even on Linux version of SQL Server) expects Windows NT user or group…
So, don’t hesitate to fix a production database with commands like:
ALTER USER [DOMAIN\ReportJobs] WITH NAME = [ReportJobs]
Create feed, PAT and authorize
Database artefact is going to be universal package. You need a feed in your project (create it in Azure DevOps Artifacts).
You need to create your Azure DevOps Personal Access Token (PAT) for accessing the feed. Scope Packaging(Read & write) would be enough. Copy the token value from DevOps, then paste it into CLI command:
vsts login --token token
How to create an artefact from a production database?
A local folder named artifacts/artifact-name/ in the root of your project is going to be used, so artifacts/ should be in .gitignore.
The tool extracts schema of the database and exports data of some tables from a production database to the files in artifacts/artifact-name/.
Replace artifact-name, server-address, database-name and table names with actual values:
I recommend to extract “schema only” and use bcp tool for tables. If you opt to “schema and data” having a foreign keys in your database, probably, you have no choice except to export all the data, which can be of a huge amount.
You can upload a package version with the command:
A few days ago I visited Global DevOps Bootcamp. During a registration through a meetup platform, I was quite inattentive and therefore I didn’t read the event program.
When I arrived at the event and found people watching some introductory video, I set down with them and then started to notice, that everyone has a backpack or laptop, but I was the only person with a small bag, containing my glasses, wallet and smartphone. That was becoming suspicious …
Finally, it turned out to be a hackathon! I joined to team-04 as an assistant.
Working from a smartphone, you know, also fun. And helps. I was googling a lot. Also, I found out that my experience in Azure and Azure DevOps wasn’t so bad, I could give relevant advice.
We weren’t the best team, but we got a new experience! Finally, we stumbled upon finding malicious code in dependencies in challenge 6 of 8.
Participation in hackathon doesn’t require from you extreme mental tension. It’s just fun for those, who want to learn something in gaming style.
Now I know what is Global DevOps Bootcamp and I’ll visit it next year, but that time with a laptop! 😉
Now, imagine you found some DSC resource module, for instance cChoco (in PowerShell Gallery, on GitHub), and you need to know what properties its resources have. Super helpful may be command Get-DscResource, applied like: