<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nidu Sihani on Medium]]></title>
        <description><![CDATA[Stories by Nidu Sihani on Medium]]></description>
        <link>https://medium.com/@sihaninidu3?source=rss-5a2eea810cdb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*jkw8tbJRkdQbVWK2.jpg</url>
            <title>Stories by Nidu Sihani on Medium</title>
            <link>https://medium.com/@sihaninidu3?source=rss-5a2eea810cdb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 19:03:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sihaninidu3/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Implementing Single Sign On (SSO) using Azure Active Directory]]></title>
            <link>https://medium.com/@sihaninidu3/implementing-single-sign-on-sso-using-azure-active-directory-687d505fd80f?source=rss-5a2eea810cdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/687d505fd80f</guid>
            <dc:creator><![CDATA[Nidu Sihani]]></dc:creator>
            <pubDate>Mon, 20 Jan 2025 08:41:24 GMT</pubDate>
            <atom:updated>2025-01-20T08:41:24.816Z</atom:updated>
            <content:encoded><![CDATA[<p>To access any secured page in a web application, the user needs to authenticate and if the user want to access multiple web applications, then the user has to login for each of those applications individually. Logging in multiple times can be eliminated with Single Sign On, i.e., user has to login only once and can access web multiple applications (<a href="https://www.codeproject.com/Articles/1140228/Implementation-of-Single-Sign-On-SSO-in-ASP-NET-MV">https://www.codeproject.com/Articles/1140228/Implementation-of-Single-Sign-On-SSO-in-ASP-NET-MV</a>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*r8NL3GY8McetgqsNa4u1ww.png" /></figure><p>We can use the Azure Active Directory Admin Center to enable single sign-on (SSO) for an enterprise application that we have added to our Azure Active Directory (Azure AD) tenant. After configuring SSO, users can sign in by using their Azure AD credentials.</p><p>To configure SSO</p><h3>Prerequisites</h3><p>To configure SSO, you need:</p><ul><li>An Azure AD user account. If you don’t already have one, you can <a href="https://azure.microsoft.com/free/?WT.mc_id=A261C142F">Create an account for free</a>.</li><li>One of the following roles: Global Administrator, Cloud Application Administrator, Application Administrator, or owner of the service principal.</li><li>Completion of the steps in <a href="https://docs.microsoft.com/en-us/azure/active-directory/manage-apps/add-application-portal-assign-users">Quickstart: Create and assign a user account</a>.</li></ul><h3>Enable single sign-on</h3><p>To enable SSO for an application:</p><ol><li>Go to the <a href="https://aad.portal.azure.com/">Azure Active Directory Admin Center</a> and sign in using one of the roles listed in the prerequisites.</li><li>In the left menu, select <strong>Enterprise applications</strong>. The <strong>All applications</strong> pane opens and displays a list of the applications in your Azure AD tenant. Search for and select the application that you want to use. For example, <strong>Azure AD SAML Toolkit 1</strong>.</li><li>In the <strong>Manage</strong> section of the left menu, select <strong>Single sign-on</strong> to open the <strong>Single sign-on</strong> pane for editing.</li><li>Select <strong>SAML</strong> to open the SSO configuration page. After the application is configured, users can sign in to it by using their credentials from the Azure AD tenant.</li><li>The process of configuring an application to use Azure AD for SAML-based SSO varies depending on the application. For any of the enterprise applications in the gallery, use the link to find information about the steps needed to configure the application. The steps for the <strong>Azure AD SAML Toolkit</strong> are listed in this quickstart.</li><li>In the <strong>Set up Azure AD SAML Toolkit 1</strong> section, record the values of the <strong>Login URL</strong>, <strong>Azure AD Identifier</strong>, and <strong>Logout URL</strong> properties to be used later.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q_CYrYE1axQ95SqMIaevWQ.png" /></figure><h3>Configure single sign-on in the tenant</h3><p>You add sign-in and reply URL values, and you download a certificate to begin the configuration of SSO in Azure AD.</p><p>To configure SSO in Azure AD:</p><ol><li>In the Azure portal, select <strong>Edit</strong> in the <strong>Basic SAML Configuration</strong> section on the <strong>Set up single sign-on</strong> pane.</li><li>For <strong>Reply URL (Assertion Consumer Service URL)</strong>, enter <a href="https://samltoolkit.azurewebsites.net/SAML/Consume.">https://samltoolkit.azurewebsites.net/SAML/Consume.</a></li><li>For <strong>Sign on URL</strong>, enter <a href="https://samltoolkit.azurewebsites.net/">https://samltoolkit.azurewebsites.net/.</a></li><li>Select <strong>Save</strong>.</li><li>In the <strong>SAML Signing Certificate</strong> section, select <strong>Download</strong> for <strong>Certificate (Raw)</strong> to download the SAML signing certificate and save it to be used later.</li></ol><h3>Configure single sign-on in the application</h3><p>Using single sign-on in the application requires you to register the user account with the application and to add the SAML configuration values that you previously recorded.</p><h3>Register the user account</h3><p>To register a user account with the application:</p><ol><li>Open a new browser window and browse to the sign-in URL for the application. For the <strong>Azure AD SAML Toolkit</strong> application, the address is <a href="https://samltoolkit.azurewebsites.net./">https://samltoolkit.azurewebsites.net.</a></li><li>Select <strong>Register</strong> in the upper right corner of the page.</li><li>For <strong>Email</strong>, enter the email address of the user that will access the application. For example, in a previous quickstart, the user account was created that uses the address of contosouser1@contoso.com. Be sure to change contoso.com to the domain of your tenant.</li><li>Enter a <strong>Password</strong> and confirm it.</li><li>Select <strong>Register</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3km07TXvZH2Hyeg52lWnYg.png" /></figure><h3>Configure SAML settings</h3><p>To configure SAML setting for the application:</p><ol><li>Signed in with the credentials of the user account that you created, select <strong>SAML Configuration</strong> at the upper-left corner of the page.</li><li>Select <strong>Create</strong> in the middle of the page.</li><li>For <strong>Login URL</strong>, <strong>Azure AD Identifier</strong>, and <strong>Logout URL</strong>, enter the values that you recorded earlier.</li><li>Select <strong>Choose file</strong> to upload the certificate that you previously downloaded.</li><li>Select <strong>Create</strong>.</li><li>Copy the values of the <strong>SP Initiated Login URL</strong> and the <strong>Assertion Consumer Service (ACS) URL</strong> to be used later.</li></ol><h3>Update single sign-on values</h3><p>Use the values that you recorded for <strong>SP Initiated Login URL</strong> and <strong>Assertion Consumer Service (ACS) URL</strong> to update the single sign-on values in your tenant.</p><p>To update the single sign-on values:</p><ol><li>In the Azure portal, select <strong>Edit</strong> in the <strong>Basic SAML Configuration</strong> section on the <strong>Set up single sign-on</strong> pane.</li><li>For <strong>Reply URL (Assertion Consumer Service URL)</strong>, enter the <strong>Assertion Consumer Service (ACS) URL</strong> value that you previously recorded.</li><li>For <strong>Sign on URL</strong>, enter the <strong>SP Initiated Login URL</strong> value that you previously recorded.</li><li>Select <strong>Save</strong>.</li></ol><h3>Test single sign-on</h3><p>You can test the single sign-on configuration from the <strong>Set up single sign-on</strong> pane.</p><p>To test SSO:</p><ol><li>In the <strong>Test single sign-on with Azure AD SAML Toolkit 1</strong> section, on the <strong>Set up single sign-on</strong> pane, select <strong>Test</strong>.</li><li>Sign in to the application using the Azure AD credentials of the user account that you assigned to the application</li></ol><p>(Source — <a href="https://docs.microsoft.com/en-us/azure/active-directory/manage-apps/add-application-portal-setup-sso">https://docs.microsoft.com/en-us/azure/active-directory/manage-apps/add-application-portal-setup-sso</a>)</p><h3>Configure the following common attributes of an enterprise application:</h3><ul><li><strong>Enabled for users to sign in?</strong> — Determines whether users assigned to the application can sign in.</li><li><strong>User assignment required?</strong> — Determines whether users who aren’t assigned to the application can sign in.</li><li><strong>Visible to users?</strong> — Determines whether users assigned to an application can see it in My Apps and Microsoft 365 app launcher. (See the waffle menu in the upper-left corner of a Microsoft 365 website.)</li><li><strong>Logo</strong> — Determines the logo that represents the application.</li><li><strong>Notes</strong> — Provides a place to add notes that apply to the application.</li></ul><p>It is recommended that you use a non-production environment to test the steps in this quickstart.</p><h3>Prerequisites</h3><p>To configure the properties of an enterprise application, you need:</p><ul><li>An Azure AD user account. If you don’t already have one, you can <a href="https://azure.microsoft.com/free/?WT.mc_id=A261C142F">Create an account for free</a>.</li><li>One of the following roles: Global Administrator, Cloud Application Administrator, Application Administrator, or owner of the service principal.</li><li>Completion of the steps in <a href="https://docs.microsoft.com/en-us/azure/active-directory/manage-apps/add-application-portal">Quickstart: Add an enterprise application</a>.</li></ul><h3>Configure application properties</h3><p>Application properties control how the application is represented and how the application is accessed.</p><p>To edit the application properties:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eiyQ69Wu4BjuTPgOZkbAWw.png" /></figure><ul><li>Go to the <a href="https://aad.portal.azure.com/">Azure Active Directory Admin Center</a> and sign in using one of the roles listed in the prerequisites.</li><li>In the left menu, select <strong>Enterprise applications</strong>. The <strong>All applications</strong> pane opens and displays a list of the applications in your Azure AD tenant. Search for and select the application that you want to use. For example, <strong>Azure AD SAML Toolkit 1</strong>.</li><li>In the <strong>Manage</strong> section, select <strong>Properties</strong> to open the <strong>Properties</strong> pane for editing.</li><li>Select <strong>Yes</strong> or <strong>No</strong> to decide whether the application is enabled for users to sign in.</li><li>Select <strong>Yes</strong> or <strong>No</strong> to decide whether only user accounts that have been assigned to the application can sign in.</li><li>Select <strong>Yes</strong> or <strong>No</strong> to decide whether users assigned to an application can see it in My Apps and Microsoft 365 portals.</li></ul><p>Use the below code to get an access token by authenticating a user in Azure AD</p><h3>Setting up Azure AD</h3><p>Create a user like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*3Qk9jD35AdAHmL7cEXNqsg.png" /></figure><p>where, <em>ldapvpldemo</em> is the Azure AD tenant.</p><p>We’ll also need to give that user a “permanent” password, so let’s show the password on creation (or reset it afterwards) then let’s go to an <em>InPrivate browsing</em> window and navigate to <a href="https://login.microsoftonline.com/">https://login.microsoftonline.com/</a>. We can then login as the user (e.g. <a href="/service/mailto:test@ldapvpldemo.onmicrosoft.com">test@ldapvpldemo.onmicrosoft.com</a>) with the said password. We’ll be prompted to change it (e.g. <em>My$uperComplexPassw0rd</em>).</p><p>Let’s create the client app. In <em>App Registrations</em>, let’s add an app with:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*dfyhYQ43d3b1IG6w6EVQkw.png" /></figure><p>It would probably work as a Web app / API but a Native App seems more fitting.</p><p>We’ll need the Application ID of that application which we can find by looking at the properties of the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*X_Hb5fjLA94VYdLRIbhuXQ.png" /></figure><p>We then need to create the service app:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*W14mGaj2UWcavQaQkaQSIQ.png" /></figure><p>We’ll need the App ID URI of the service:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*PehbxDpOtSwHrCULRs3XfQ.png" /></figure><p>That URI can be changed, either way we need the final value.</p><p>We will need to give permission to the client app to access the service app. For that we need to go back to the client app, go to the <em>Required Permissions</em> menu and add a permission. From there, in the search box we can just start to write the name of the service app (e.g. <em>MyLegacyService</em>) and it should appear where we can select it. We then click the <em>Access MyLegacyService</em> box.</p><p>Finally, we need to grant the permissions to users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*s9veGb5e7PC2gOPUmqg8gA.png" /></figure><p>With all that, we’re ready to authenticate.</p><h3>ADAL</h3><p>This sample is in C# / .NET but since ADAL is available on multiple platform (e.g. Java), this should be easy to port.</p><p>We’ll create a Console Application project. We need the full .NET Framework as the .NET core version of ADAL doesn’t have the <em>UserPasswordCredential</em> class we’re gona be using.</p><p>We need to install the NuGet package <a href="https://www.nuget.org/packages/Microsoft.IdentityModel.Clients.ActiveDirectory/">Microsoft.IdentityModel.Clients.ActiveDirectory</a> in the project.</p><p>private static async Task AdalAuthenticationAsync()<br> {<br> // Constants<br> var tenant = “LdapVplDemo.onmicrosoft.com”;<br> var serviceUri = “https://LdapVplDemo.onmicrosoft.com/d0f883f6-1c32-4a14-a436-0a995a19c39b&quot;;<br> var clientID = “b9faf13d-9258–4142–9a5a-bb9f2f335c2d”;<br> var userName = $”test@{tenant}”;<br> var password = “My$uperComplexPassw0rd1”;</p><p>// Ceremony<br> var authority = “https://login.microsoftonline.com/&quot; + tenant;<br> var authContext = new AuthenticationContext(authority);<br> var credentials = new UserPasswordCredential(userName, password);<br> var authResult = await authContext.AcquireTokenAsync(serviceUri, clientID, credentials);<br> }</p><p>We have to make sure we’ve copied the constants in the constant section.</p><p><strong>UPDATE (06–09–2017): The name of the constants match the ADAL SDK but doesn’t always match what we see on the portal screens. Here are the constants mapping. The <em>tenant</em> is the name of your AAD tenant appended by <em>.onmicrosoft.com</em>. The <em>serviceUri</em> is the <em>App ID URI</em> we collected above (red box). The <em>clientID</em> is the <em>Application ID</em> we’ve collected above (red box). Finally, user name and password belong to the actual user we want to authenticate.</strong></p><p>This should work and <em>authResult</em> should contain a valid <em>access token</em> that we could use as a bearer token in different scenarios.</p><p>If we pass a wrong password or wrong user name, we should obtain an error as expected.</p><h3>HTTP POST</h3><p>We can use <a href="http://www.telerik.com/fiddler">Fiddler</a> or other HTTP sniffing tool to see what ADAL did for us. It is easy enough to replicate.</p><p>private static async Task HttpAuthenticationAsync()<br> {<br> // Constants<br> var tenant = “LdapVplDemo.onmicrosoft.com”;<br> var serviceUri = “<a href="https://ldapvpldemo.onmicrosoft.com/d0f883f6-1c32-4a14-a436-0a995a19c39b">https://LdapVplDemo.onmicrosoft.com/d0f883f6-1c32-4a14-a436-0a995a19c39b</a>&quot;;<br> var clientID = “b9faf13d-9258–4142–9a5a-bb9f2f335c2d”;<br> var userName = $”test@{tenant}”;<br> var password = “My$uperComplexPassw0rd”;</p><p>using (var webClient = new WebClient())<br> {<br> var requestParameters = new NameValueCollection();</p><p>requestParameters.Add(“resource”, serviceUri);<br> requestParameters.Add(“client_id”, clientID);<br> requestParameters.Add(“grant_type”, “password”);<br> requestParameters.Add(“username”, userName);<br> requestParameters.Add(“password”, password);<br> requestParameters.Add(“scope”, “openid”);</p><p>var url = $”<a href="https://login.microsoftonline.com/%7Btenant%7D/oauth2/token">https://login.microsoftonline.com/{tenant}/oauth2/token</a>&quot;;<br> var responsebytes = await webClient.UploadValuesTaskAsync(url, “POST”, requestParameters);<br> var responsebody = Encoding.UTF8.GetString(responsebytes);<br> }<br> }</p><p>Basically, we have an HTTP post where all the previous argument are passed in the POST body.</p><p>If we pass a wrong password or wrong user name, we should obtain an error as expected. Interestingly, the HTTP code is 400 (i.e. bad request) instead of some unauthorized variant.</p><p>(Source — <a href="https://vincentlauzon.com/2017/01/29/authenticating-to-azure-ad-non-interactively/">https://vincentlauzon.com/2017/01/29/authenticating-to-azure-ad-non-interactively/</a>)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=687d505fd80f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a CI/CD Pipleline for a .NET Project]]></title>
            <link>https://medium.com/@sihaninidu3/creating-a-ci-cd-pipleline-for-a-net-project-3ecde7374344?source=rss-5a2eea810cdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ecde7374344</guid>
            <dc:creator><![CDATA[Nidu Sihani]]></dc:creator>
            <pubDate>Mon, 29 Jan 2024 11:05:51 GMT</pubDate>
            <atom:updated>2024-01-29T11:05:51.507Z</atom:updated>
            <content:encoded><![CDATA[<h3>Creating a CI/CD Pipeline for a .NET Project</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*eceqvmjORdJYkV4eY9JCFQ.png" /></figure><h3>Steps to setup Jenkins server locally</h3><ol><li><a href="https://www.jenkins.io/download">Download Jenkins Generic Java package (.war)</a></li><li>Open up a terminal in the download directory</li><li>Run java java -jar jenkins.war — enable-future-java — httpPort=8080</li><li>Browse to <a href="http://localhost:8080/">http://localhost:8080</a></li><li>Paste the initial password from the console</li><li>Follow the instructions to complete the installation</li></ol><h3>Steps to integrate the .Net project with Jenkins</h3><ul><li>Follow <a href="https://www.swtestacademy.com/jenkins-dotnet-integration/">https://www.swtestacademy.com/jenkins-dotnet-integration/</a> to create new item for .Net pipeline and integrate with TFS (Team Foundation Server) in Azure DevOps Server</li><li>To integrate with Bitbucket <a href="https://plugins.jenkins.io/atlassian-bitbucket-server-integration/">https://plugins.jenkins.io/atlassian-bitbucket-server-integration/</a></li><li>Go to Jenkins Dashboard → Configuration → Change the port from 8080 to preferred port</li><li>Go to Manage Jenkins → Global Tool Configuration → MSBuild and add the information as below and save (MSBuild path as vs\MSBuild\Current\Bin\MSBuild.exe)</li><li>Install Nuget from the link <a href="https://www.nuget.org/downloads">https://www.nuget.org/downloads</a> and add the .exe in a folder C:\Nuget</li><li>Go to Dashboard → Project → Configure → Build Environment</li><li>In Add Build Step → Select ‘’Execute Windows Batch Command”</li><li>In the Command section add the command C:\Nuget\nuget.exe restore project path</li><li>Add Build Step → Select ‘’Build a Visual Studio Project or Solution using MSBuild”</li><li>Select MSBuild for <strong>Build a Visual Studio project or solution using MSBuild </strong>and the path of the .sln file of the project and Save</li></ul><h3>Additional Resources</h3><p>Video Link to setup MSBuild — <a href="https://www.youtube.com/watch?v=uC7vajbnZS4">https://www.youtube.com/watch?v=uC7vajbnZS4</a></p><p>Other sources — <a href="https://www.c-sharpcorner.com/article/continuous-deployment-with-jenkins-and-net/">https://www.c-sharpcorner.com/article/continuous-deployment-with-jenkins-and-net/</a></p><h3>Integrating Bitbucket with Jenkins</h3><ul><li>Install the Bitbucket Plugin</li><li>Create and configure a job</li><li>Add a webhook in bitbucket</li><li>Test and verify</li></ul><h3>Install the Bitbucket Plugin</h3><p>Manage Jenkins → Manage Plugins → Available Tab → Search Bitbucket Plugin → Install</p><h3>Create and configure a job (Pipeline)</h3><p>Manage Jenkins → New Item → Create a Pipeline Project</p><p>In configure</p><p>Under <strong>Pipeline</strong>, choose Pipeline Script from SCM → Copy the reporistory URL from Bitbucket repository (go to repository → select clone and copy the URL) and paste in the Repository URL section</p><p>Add credentials if it is a private repository</p><p>Under <strong>Build Triggers</strong>, Choose ‘Build when a change is pushed to Bitbucket’</p><p>Create a file in the project folder with the name given in the Script Path under Pipeline section</p><h3>Create and configure a job (MultiBranch Pipeline)</h3><p>Manage Jenkins → New Item → Create a MuliBranch Pipeline Project</p><p>Under <strong>Branch Sources</strong> add the Bitbucket source with the credentials</p><p>To add a branch select <strong>Filter by name </strong>in filters and add a branch</p><p>Under <strong>Build Configuration </strong>select By JenkinsFile and give the name of the jenkins file</p><p>Select Bitbucket webhook trigger in <strong>Scan Multibranch Pipeline Triggers </strong>and choose when to trigger the builds</p><h3>JenkinsFile Contents</h3><p>Environment URLs</p><pre>environment {<br>  REPO_URL = &quot;bitbuket repo url&quot;<br>  MSBuild = &quot;C:/vs/MSBuild/Current/bin/MSBuild.exe&quot;<br>}</pre><p>Clone the project from bitbucket</p><pre>stage(&#39;Clone&#39;) {<br> steps {<br>   git branch: &#39;main&#39;, credentialsId: &#39;nidu&#39;, url: REPO_URL<br>  }<br>}</pre><p>Restore the nuget packages</p><pre>stage(&#39;Restore packages&#39;) {<br>  steps {<br>    bat &quot;nuget.exe restore&quot;<br>  }<br>}</pre><p>Clean the project using MSBuild</p><pre>stage(&#39;Clean&#39;) {<br>  steps {<br>    bat &quot;$MSBuild testjenkinsapp.sln /target:clean;Build&quot;<br>  }<br>}</pre><p>Build the project using MSBuild</p><pre>stage(&#39;Build&#39;) {<br>  steps {<br>    bat &quot;$MSBuild testjenkinsapp.sln /p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:SkipInvalidConfigurations=true /t:build /p:Configuration=Release /p:Platform=\&quot;Any CPU\&quot; /p:DeleteExistingFiles=True /p:publishUrl=c:\\inetpub\\wwwroot&quot;<br>  }<br>}</pre><h4>Script for JenkinsFile</h4><pre>pipeline {<br>    agent any<br><br>    environment {<br>      REPO_URL = &quot;bitbucket repo url&quot;<br>      MSBuild = &quot;C:/vs/MSBuild/Current/bin/MSBuild.exe&quot;<br>    }<br>    <br>    stages {<br>        stage(&#39;Clone&#39;) {<br>            steps {<br>                git branch: &#39;main&#39;, credentialsId: &#39;nidu&#39;, url: REPO_URL<br>            }<br>        }<br>        stage(&#39;Restore packages&#39;) {<br>            steps {<br>                bat &quot;nuget.exe restore&quot;<br>            }<br>        }<br>        stage(&#39;Clean&#39;) {<br>            steps {<br>                bat &quot;$MSBuild testjenkinsapp.sln /target:clean;Build&quot;<br>            }<br>        }<br>        stage(&#39;Build&#39;) {<br>            steps {<br>                bat &quot;$MSBuild testjenkinsapp.sln /p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:SkipInvalidConfigurations=true /t:build /p:Configuration=Release /p:Platform=\&quot;Any CPU\&quot; /p:DeleteExistingFiles=True /p:publishUrl=c:\\inetpub\\wwwroot&quot;<br>            }<br>        }<br>    }<br>}</pre><h3>Add a Webhook in Bitbucket</h3><p>Go to Bitbucket repository → Select Repository Settings → Under Workflow Select Webhooks → Add new Webhook</p><p>Under URL, add the Jenkins URL/bitbucket-hook and select the triggers to start the build in jenkins</p><h3>Test and Verify</h3><p>Add a new file or make a change in the Bitbucket repository and check in the jenkins project to see the build</p><p>The change should be displayed in the new build</p><h3>Additional Resources</h3><p><a href="https://www.youtube.com/watch?v=nNaR5Q_pIa4">https://www.youtube.com/watch?v=nNaR5Q_pIa4</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ecde7374344" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to download files using Selenium WebDriver and Firefox]]></title>
            <link>https://medium.com/@sihaninidu3/how-to-download-files-using-selenium-webdriver-and-firefox-9b6dbbd71a3e?source=rss-5a2eea810cdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b6dbbd71a3e</guid>
            <category><![CDATA[selenium-webdriver]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[firefox]]></category>
            <dc:creator><![CDATA[Nidu Sihani]]></dc:creator>
            <pubDate>Thu, 09 Jul 2020 12:42:56 GMT</pubDate>
            <atom:updated>2020-07-09T13:55:29.755Z</atom:updated>
            <content:encoded><![CDATA[<p>This tutorial explains how to automate file downloading using selenium webdriver, geckodriver, java and firefox.</p><h4><strong>Why we use GeckoDriver?</strong></h4><p>GeckoDriver is a proxy which communicates with the Gecko-based browsers such as Firefox. Therefore geckodriver links your selenium test with Firefox.</p><h4><strong>Steps</strong></h4><p>01. First install java jdk (I have used java 8).</p><p>02. Install <a href="https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads">Microsoft Visual C++ Redistributable</a>.</p><p>03. Download <a href="https://github.com/mozilla/geckodriver/releases">geckodriver</a> from this link <a href="https://github.com/mozilla/geckodriver/releases">geckodriver-v0.26.0-win64</a> and add the path to environment variables.</p><p>04. Add the selenium IDE for firefox using this link <a href="https://addons.mozilla.org/en-US/firefox/addon/selenium-ide/">https://addons.mozilla.org/en-US/firefox/addon/selenium-ide/</a></p><p>05. Firefox version should be above 60, to support the geckodriver version 26.0.</p><h4><strong>Code to download files</strong></h4><p>Add the geckodriver path</p><pre>String geckodriverpath = &quot;add your geckodriver path&quot;;<br>System.setProperty(&quot;webdriver.gecko.driver&quot;, geckodriverpath + &quot;/geckodriver.exe&quot;);<br>        </pre><p>Set the firefox profile. Change the MIME type of downloading file as required</p><pre>FirefoxProfile profile = new FirefoxProfile();</pre><pre>//list of MIME types to save to disk without asking what to use to open the file<br>profile.setPreference(&quot;browser.helperApps.neverAsk.saveToDisk&quot;, &quot;application/pdf&quot;);</pre><pre>// for PDFs disable the built-in PDF viewer<br>profile.setPreference(&quot;pdfjs.disabled&quot;, true);  <br>FirefoxOptions option=new FirefoxOptions();<br>option.setProfile(profile);<br>WebDriver driver = new FirefoxDriver(option);</pre><p>Go to the URL where you want to download the file from</p><pre>driver.get(&quot;Your URL&quot;);<br>Thread.sleep(5000);</pre><p>Find the pdf element using the name and click the element (you can use xpath to locate the element)</p><pre>driver.findElement(By.linkText(&quot;File name&quot;)).click(); <br>Thread.sleep(5000);</pre><p>If you want to move the file to a desired location, use the below code</p><pre>File downloaded_file = new File(deafultdownloadpath + &quot;/downloaded_file_name.filetype&quot;);<br>File newfile = new File(path_to_move_the_file +  &quot;/new_file_name.filetype&quot;);</pre><pre>if(!newfile.exists()){<br>  downloaded_file.renameTo(newfile);<br>  downloaded_file.delete();<br>}</pre><p>Finally end the webdriver session</p><pre>driver.quit();</pre><p>Full Code</p><pre>import java.io.IOException;<br>import org.openqa.selenium.*;<br>import org.openqa.selenium.firefox.*;<br>import org.openqa.selenium.firefox.FirefoxOptions;</pre><pre>public class TestAutomation {<br>    <br>  public static void main(String[] args) throws IOException, InterruptedException{</pre><pre>   String geckodriverpath = &quot;add your geckodriver path&quot;;<br>   System.setProperty(&quot;webdriver.gecko.driver&quot;, geckodriverpath +     &quot;/geckodriver.exe&quot;);<br></pre><pre>  FirefoxProfile profile = new FirefoxProfile();</pre><pre>  //MIME types to save to disk without asking what to use to open the file<br>  profile.setPreference(&quot;browser.helperApps.neverAsk.saveToDisk&quot;, &quot;application/pdf&quot;);</pre><pre>// for PDFs disable the built-in PDF viewer<br>  profile.setPreference(&quot;pdfjs.disabled&quot;, true);  <br>  FirefoxOptions option=new FirefoxOptions();<br>  option.setProfile(profile);</pre><pre>  WebDriver driver = new FirefoxDriver(option);</pre><pre>  driver.get(&quot;Your URL&quot;);<br>  Thread.sleep(5000);</pre><pre>  driver.findElement(By.linkText(&quot;File name&quot;)).click(); <br>  Thread.sleep(5000);</pre><pre>File downloaded_file = new File(deafultdownloadpath +  &quot;/downloaded_file_name.filetype&quot;);<br>  File newfile = new File(path_to_move_the_file +   &quot;/new_file_name.filetype&quot;);</pre><pre> if(!newfile.exists()){<br>    downloaded_file.renameTo(newfile);<br>    downloaded_file.delete();<br>  }<br>  driver.quit();</pre><pre>  }<br>}</pre><p>For the file types other than PDFs add the below code to click the “Save As” prompt.</p><pre>Robot robot= new Robot();<br>robot.keyPress(KeyEvent.VK_DOWN);<br>Thread.sleep(2000); <br>robot.keyPress(KeyEvent.VK_ENTER);<br>Thread.sleep(2000); <br>robot.keyRelease(KeyEvent.VK_ENTER);</pre><p>And add the below imports</p><pre>import java.awt.AWTException;<br>import java.awt.Robot;<br>import java.awt.event.KeyEvent;</pre><p>Thank You!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b6dbbd71a3e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>