zoukankan      html  css  js  c++  java
  • jenkins结合windows 2019 server系统的wcl子系统ubuntu通过rsync传送代码到windows中

    需求:代码需要通过jenkins发布到windows中,如果通过人工去上传,效率太低,直接使用jenkins发布会大大提升效率
    难点是把jenkins(linux) 中拉取的代码,编译后传输到windows中
    现在windows有了wcl系统的概率:即在windows中下载安装linux子系统,这个子系统可以和windows共享ip,磁盘等资源,在这个系统中启动rsync服务端即可实现文件的传输



    1.进入c:/windows/system32/windowsPowerShell/v1.0目录,以管理员身份启动powershell.exe程序
    运行以下命令开启wcl功能,需要重启windows系统
    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux



    2.下载ubuntu系统
     https://docs.microsoft.com/en-us/windows/wsl/install-manual
    下载ubutnu18.04,默认下载到C:UsersAdministrator>目录

    https://aka.ms/wsl-ubuntu-1804

    cd ~
    # 重命名系统名称为zip可解压文件
    PS C:UsersAdministrator> Rename-Item Ubuntu1804.appx Ubuntu1804.zip
    # 解压ubuntu系统
    Expand-Archive Ubuntu1804.zip Ubuntu1804


    解压文件后,可以看到如图的文件目录内容。

    3.安装 Linux 子系统

    打开 ubuntu1804.exe 即可开始进入命令行安装界面:

    提示创建用户

    用户:mediaiouser
    密码:pass

    3.在ubutu中安装rsync服务
    实际ubuntu已经自带了rsync服务,只需要启用即可
    创建配置
    # cp /usr/share/doc/rsync/examples/rsyncd.conf /etc
    # 编辑配置

    vim  /etc/rsyncd.conf
    
    [apache_test.chinasoft.com]
    path = /mnt/c/Users/Administrator/wwwroot/test.chinasoft.com
    uid = mediaiouser # 需要特别强调
    gid = mediaiouser # 一定要注明
    use chroot = false
    read only = false
    transfer logging = yes
    secrets file = /etc/rsyncd.secrets

    # 创建密码文件
    root@eus-media-api02:/# more /etc/rsyncd.secrets
    mediaiouser:mediawinlinuxpass

    # 修改密码文件权限
    # chmod 600  /etc/rsyncd.secrets
    # chown root.root  /etc/rsyncd.secrets

    # 启动rsync服务
    /etc/init.d/rsync start

    # 创建需要rsync接收文件的目录
    mkdir -p /mnt/c/Users/Administrator/wwwroot/test.media.io
    chown -R mediaiouser. Mediaiouser /Users/Administrator

    关于权限的说明:
    1.    ubuntu下的/mnt/c对应c盘
    2.    要用root用户启动rsync服务
    3.    授权rsync推送目标目录为rsyncd.secrets密码文件中指定的用户


    rsync同步时报错:
     [apache@jenkins_server:/usr/local/worksh/jeninks_task]$ ./api02_media_io_go.media.io.sh
     /data/www/vhosts/test.media.io/ 可以发布
    ####################rsync 150.238.16.180 start################################
    sending incremental file list
    rsync: failed to set times on "." (in apache_test.media.io): Operation not permitted (1)
    ./
    aa.html
                 12 100%    0.00kB/s    0:00:00 (xfr#1, to-chk=0/2)
    rsync: mkstemp ".aa.html.34rJd9" (in apache_test.media.io) failed: Operation not permitted (1)

    sent 138 bytes  received 230 bytes  147.20 bytes/sec
    total size is 12  speedup is 0.03
    rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1189) [sender=3.1.3]
    ################### rsync end #######################

    加入这个即可:
    uid = mediaiouser # 需要特别强调
    gid = mediaiouser # 一定要注明


    通过以上的使用可以看出,wcl子系统可以和windows进行资源共享,并且可以在ubuntu中安装linux下的服务,这样就有可更多可能

  • 相关阅读:
    golang-grpc-Unimplemented-desc
    redis使用get key中文变成十六进制编码
    golang-generate-1pixel-image
    telnet-redis-quit
    redis hset hmset过期时间
    cookie mapping 原理理解
    excel 表格粘贴到word 显示不完整
    golang-test-tool-gotests
    go build Multiple main.go file
    golang-build-error
  • 原文地址:https://www.cnblogs.com/reblue520/p/13693429.html
Copyright © 2011-2022 走看看