---
# System prepended metadata

title: Jenkins Groovy for  Net.Core+Docker

---

Jenkins Groovy for  Net.Core+Docker
===


<pre>
<code>
pipeline{
	agent any
	stages{
		stage('gitpull'){
						steps{
								git branch: 'master', url: 'https://bitbucket.org/vsn80395/dockertestjenkins.git'
							 }
					    }
		stage('restore'){
						steps{
								bat'dotnet restore JenkinsTestDocker.sln'
							 }
						}
		stage('build'){
						steps{
								bat'dotnet build JenkinsTestDocker.sln --configuration release'
							 }
						}
		stage('ubitTest'){
						steps{
								echo 'hellp'
							 }
						}
		stage('publish'){
						steps{
								bat'dotnet publish JenkinsTestDocker.sln'
							 }
						}
		stage('docker-rm container')
		                {
		                steps{
		                       bat 'docker stop x2x22-test'
						       bat 'docker rm x2x22-test'
						      } 
		                }   
		stage('docker-rm image')
		                {
		                steps{
						       bat 'docker rmi x2x23'
						      }		            
		                }																
		stage('docker-build')
		                {
		                steps{
						       bat 'docker build -t x2x23 ./JenkinsTestDocker'
						      }	                    
		                }
		stage('docker-run')
		                {
		                steps{
						       bat 'docker run -idt --name=x2x22-test -p=8899:80 x2x23'
						      }	                    
		                }                
		  }
		}
</code>
</pre> 

1. 先pull git

2. restore還原nuget套件

3. build編譯組件

4. ubitTest 單元測試

5. publish 發布專案

6. docker-rm container 移除容器

7. docker-rm image 移除image

8. docker-build build image

9. docker-run 執行容器


p.s這邊沒有 publish release 因為使用docker 架設


基本要有Credentials 

Credentials 是用來輸入bitbackut的帳密
