Example #1
0
        /// <summary>
        /// Provides a Web Client for Jenkins REST API.
        /// </summary>
        /// <returns>A <see cref="IJenkinsRestClient"/> instance.</returns>
        public IJenkinsRestClient GetClient()
        {
            try
            {
                this.restClientLock.EnterUpgradeableReadLock();

                if (this.restClient == null)
                {
                    try
                    {
                        this.restClientLock.EnterWriteLock();

                        this.webClient   = new JenkinsWebClient();
                        this.restManager = new RestManager(this.webClient, this.userName, this.apiToken);
                        this.restClient  = new JenkinsRestClient(this.restManager);
                    }
                    finally
                    {
                        this.restClientLock.ExitWriteLock();
                    }
                }

                return(this.restClient);
            }
            finally
            {
                this.restClientLock.ExitUpgradeableReadLock();
            }
        }
Example #2
0
        public RestManager(IJenkinsWebClient webClient)
        {
            if (webClient == null)
            {
                throw new ArgumentNullException("webClient");
            }

            this.client = webClient;
        }
Example #3
0
 public RestManager(IJenkinsWebClient webClient, string userName, string apiToken)
     : this(webClient)
 {
     this.userName = userName;
     this.apiToken = apiToken;
 }