jenkins+xcode+git+svn+nginx+https自签名

转载自:jenkins+xcode+svn+nginx+https自签名

1.主要实现功能

  • 动态拉取git最新代码,将ipa上传到SVN上
  • 生成ipa文件
  • 生成plist文件
  • 生成dsYM文件
  • ipa、plist自动上传本地nginx服务器
  • 邮件反馈,生成下载链接、链接二维码、自动安装
  • nginx服务器安装与配置
  • https证书自签名

2.环境安装

homebrew安装【用来傻瓜式安装Jenkins 、nginx等等】

Mac下Homebrew的安装与使用

ruby -e "$(curl -fsSL [https://raw.githubusercontent.com/Homebrew/install/master/install])"

Jenkins安装

brew install jenkins

jenkins (启动)httpProt端口号是8888,你可以修改成任意的🤔

jenkins --httpPort=8888
  • http://localhost:8080(浏览器输入默认 8080)
  • /Users/apple(电脑用户名)/.jenkins(brew安装jenkins位置
  • ${WORKSPACE} 值为 /Users/apple(电脑用户名)/.jenkins/jobs/qiniuTest(job名称)/workspace/)

nginx安装

brew install nginx
  • Nginx默认的是8080端口,因为我们还要安装tomcat服务,所以修改nginx的端口为9000,顺便可以设置一下“开启目录浏览功能”。
    在本地目录下面,找到【nginx.conf】这个文件
    也可以用vim修改其内容
    sudo vim /usr/local/etc/nginx/nginx.conf

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
   worker_connections  1024;
}


http {
   autoindex on; #开启目录浏览功能
   autoindex_exact_size off; #文件大小从kb开始
   autoindex_localtime on; #显示文件修改时间为服务时间
   charset utf-8,gbk;
   include       mime.types;
   default_type  application/octet-stream;

   #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
   #                  '$status $body_bytes_sent "$http_referer" '
   #                  '"$http_user_agent" "$http_x_forwarded_for"';

   #access_log  logs/access.log  main;

   sendfile        on;
   #tcp_nopush     on;

   #keepalive_timeout  0;
   keepalive_timeout  65;

   #gzip  on;

   server {
       listen       8889;
       server_name  localhost;

       #charset koi8-r;

       #access_log  logs/host.access.log  main;

       location / {
           root   html;
           index  index.html index.htm;
           autoindex on; #开启目录浏览功能
           autoindex_exact_size off; #文件大小从kb开始
           autoindex_localtime on; #显示文件修改时间为服务时间
       }

       #error_page  404              /404.html;

       # redirect server error pages to the static page /50x.html
       #
       error_page   500 502 503 504  /50x.html;
       location = /50x.html {
           root   html;
       }

       # proxy the PHP scripts to Apache listening on 127.0.0.1:80
       #
       #location ~ \.php$ {
       #    proxy_pass   http://127.0.0.1;
       #}

       # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
       #
       #location ~ \.php$ {
       #    root           html;
       #    fastcgi_pass   127.0.0.1:9000;
       #    fastcgi_index  index.php;
       #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
       #    include        fastcgi_params;
       #}

       # deny access to .htaccess files, if Apache's document root
       # concurs with nginx's one
       #
       #location ~ /\.ht {
       #    deny  all;
       #}
   }


   # another virtual host using mix of IP-, name-, and port-based configuration
   #
   #server {
   #    listen       8000;
   #    listen       somename:8080;
   #    server_name  somename  alias  another.alias;

   #    location / {
   #        root   html;
   #        index  index.html index.htm;
   #    }
   #}


   # HTTPS server
   #
   #server {
   #    listen       443 ssl;
   #    server_name  localhost;

   #    ssl_certificate      cert.pem;
   #    ssl_certificate_key  cert.key;

   #    ssl_session_cache    shared:SSL:1m;
   #    ssl_session_timeout  5m;

   #    ssl_ciphers  HIGH:!aNULL:!MD5;
   #    ssl_prefer_server_ciphers  on;

   #    location / {
   #        root   html;
   #        index  index.html index.htm;
   #    }
   #}
   include servers/*;
}

  • 每次修改nginx.conf配置以后都要执行以下命令检查配置文件是否正确
nginx -t

当出现以下提示则表示正确:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful

给予管理员权限:

sudo chown root:wheel /usr/local/opt/nginx/bin/nginx
sudo chmod u+s /usr/local/opt/nginx/bin/nginx

加入launchctl启动控制

mkdir -p ~/Library/LaunchAgents
cp /usr/local/opt/nginx/homebrew.mxcl.nginx.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist

启动 nginx

sudo nginx #打开 nginx
nginx -s reload|reopen|stop|quit #重新加载配置|重启|停止|退出 nginx
nginx -t #测试配置是否有语法错误

https自签名证书

  • 生成服务器的私钥
openssl genrsa -out server.key 1024
  • 生成签署申请(注意除Common Name以外可以为空,Common Name必须为服务器的ip或域名)
openssl req -new -key server.key -out server.csr 
  • 生成CA私钥
openssl genrsa -out ca.key 1024 
  • 利用CA的私钥产生CA的自签署证书
openssl req -new -x509 -days 365 -key ca.key -out ca.crt 
  • 在当前目录创建demoCA,里面创建文件index.txt和serial,serial内容为01,index.txt为空,以及文件夹newcerts
#openssl ca -in server.csr -out server.crt -cert ca.crt -keyfile ca.key 
#下面这行才能生成crt证书
sudo openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
  • 这样,生成了的文件中有 server.crt,server.key, ca.key, ca.crt

【把上面的证书拷贝到nginx的目录下,并且编辑nginx.conf文件】

 
#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    autoindex on; #开启目录浏览功能
    autoindex_exact_size off; #文件大小从kb开始
    autoindex_localtime on; #显示文件修改时间为服务时间
    charset utf-8,gbk;
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       8889;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
            autoindex on; #开启目录浏览功能
            autoindex_exact_size off; #文件大小从kb开始
            autoindex_localtime on; #显示文件修改时间为服务时间
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    server {
        listen       443 ssl;
        #server_name  localhost;

       ssl_certificate      /usr/local/etc/nginx/server.crt;
       ssl_certificate_key  /usr/local/etc/nginx/server.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    }
    include servers/*;
}

  • 拷贝ca.crt到服务器目录下以备用户信任安装
    /usr/local/var/www #可以在该目录下新建一文件夹,放入ca.crt文件
  • 访问https 信任自签名证书

#查看证书是否配置成功
nginx -t
#重新加载nginx
nginx -s reload

比较遗憾的是自签名HTTPS证书iPhone会提示无法连接到xxxx,所以要做手机直接安装访问需要正式机构签名证书,一个取巧的方式是使用github创建一个仓库,让后把plist放到GitHub仓库上,使用访问原始数据的方式访问plist,这样就能正常访问并安装ipa了,不过这会有泄露信息的风险

  • 到这里服务器的工作已经搭建完毕

将打好的安装包放到服务器下就可以用Safari访问并安装ipa包了

5分钟快速构建苹果IPA免费发布服务器

mac下git push避免每次都输入用户名和密码的配置

参考链接:http://www.linuxdiyf.com/linux/18389.html

链接2:https://git-scm.com/book/zh/v2/Git-%E5%B7%A5%E5%85%B7-%E5%87%AD%E8%AF%81%E5%AD%98%E5%82%A8#_credential_caching

我选择的是明文存放在磁盘中,不过期的

1.创建并且写入.git-credentials文件,vim编辑他,写入下面一条

image

2.比如用户名为tom,密码为tompassword,就这样写

https://tom:tompassword@github.com

image

3.保存后在终端下执行 git config --global credential.helper store

这样就可以了

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 217,509评论 6 504
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,806评论 3 394
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 163,875评论 0 354
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,441评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,488评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,365评论 1 302
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,190评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,062评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,500评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,706评论 3 335
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,834评论 1 347
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,559评论 5 345
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,167评论 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,779评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,912评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,958评论 2 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,779评论 2 354

推荐阅读更多精彩内容