小编lvt*_*llo的帖子

如何在Jenkins管道中的withCredentials中使用多个凭据

我在声明式jenkins管道中有以下步骤:我resources/使用libraryResource 创建来自我的文件夹的脚本.此脚本包含我的autobuild用户和某些admintest用户的凭据.

stage('Build1') {
                steps {
                    node{
                        def script = libraryResource 'tests/test.sh'
                        writeFile file: 'script.sh', text: script
                        sh 'chmod +x script.sh'
                        withCredentials([usernamePassword(credentialsId: xxx, usernameVariable: 'AUTOBUILD_USER', passwordVariable: 'AUTOBUILD_PASSWD')]){
                            sh './script.sh "
                        }

                    }

                }   
Run Code Online (Sandbox Code Playgroud)

这很好用.我可以使用我的autobuild用户.现在我正在寻找最好的方法,我也可以包括我的admintest用户的crendentials .我是否必须用第二withCredentials部分"嵌套"它还是可以再添加一个usernamePassword"数组"?

credentials jenkins jenkins-pipeline

41
推荐指数
2
解决办法
2万
查看次数

如何使用Jenkins管道在Docker容器中安装Jenkins工作区

我在码头工人中使用Jenkins.该/var/jenkins_home安装在/var/jenkins-data我的主机上.我的Jenkins可以执行docker命令(套接字的安装),我已经安装了git插件和管道插件.

现在我有一个命名的管道作业test和以下管道:

pipeline {
    agent any
    stages {
        stage('Clone') {
            steps {
                git branch: 'master', url: 'https://github.com/lvthillo/maven-hello-world.git'
            }
        }

        stage('Build in Docker') {
            agent {
                docker {
                    image 'maven:3.5.2'
                    args '-v /var/jenkins_home/workspace/test:/opt/maven -w /opt/maven'
                }
            }

            steps {
                sh 'pwd'
                sh 'mvn -v'
                sh 'mvn clean install'
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我想要实现的是从github克隆我的公共仓库.这有效.在下一步中,我想启动一个docker容器(maven)并打印当前目录,maven版本并执行全新安装.

3个命令的输出是:

[test@2] Running shell script
+ pwd
/var/jenkins_home/workspace/test@2
[Pipeline] sh
[test@2] Running shell script
+ mvn -v
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T07:58:13Z) …
Run Code Online (Sandbox Code Playgroud)

jenkins docker jenkins-pipeline

13
推荐指数
3
解决办法
2万
查看次数

无法更新chromedriver和seleniumrelease

我尝试使用量角器.所以我遵循了一个小教程,我做的第一件事:

npm install -g protractor
Run Code Online (Sandbox Code Playgroud)

这将安装两个命令行工具,量角器和webdriver-manager.但现在我必须更新我的webdriver-manager:

webdriver-manager update
Run Code Online (Sandbox Code Playgroud)

所以我的cmd尝试连接https://chromedriver.storage.googleapis.com/2.14/chromedriver_win32.ziphttps://selenium-release.storage.googleapis.com/2.45/selenium-server-standalone-2.45.0 .jar.但它会给出这个错误:

C:\Program Files (x86)\Jenkins\workspace\testnew>webdriver-manager update
Updating selenium standalone
downloading https://selenium-release.storage.googleapis.com/2.45/selenium-server
-standalone-2.45.0.jar...
Updating chromedriver
downloading https://chromedriver.storage.googleapis.com/2.14/chromedriver_win32.
zip...
Error: Got error Error: getaddrinfo EAI_AGAIN from https://selenium-release.stor
age.googleapis.com/2.45/selenium-server-standalone-2.45.0.jar
Error: Got error Error: getaddrinfo EAI_AGAIN from https://chromedriver.storage.
googleapis.com/2.14/chromedriver_win32.zip
Run Code Online (Sandbox Code Playgroud)

有时它是EAI_AGAIN错误,有时候是ENOTFOUND.但我不明白的是我可以在浏览器中手动下载zip和jar.当我浏览网址时,一切正常.但不是在cmd.有人能帮我吗?PS:网址无法ping

更新:代理设置后我收到此错误:

Error: Got error Error: tunneling socket could not be established, cause=socket
hang up from https://chromedriver.storage.googleapis.com/2.14/chromedriver_win32
.zip
Run Code Online (Sandbox Code Playgroud)

selenium cmd selenium-chromedriver protractor

12
推荐指数
2
解决办法
2万
查看次数

OpenShift V3与OpenShift V2

我正在寻找OpenShift V3和V2之间的主要区别.OpenShift V2是这样工作的吗?:https: //www.openshift.com/walkthrough/how-it-works Docker和Kubernetes在V3中是如何工作的?

有人能给我一个关于OpenShift V2和V3构建的清晰解释

docker openshift-origin kubernetes

11
推荐指数
1
解决办法
2241
查看次数

使用docker-compose创建命名的docker卷?

我使用的是docker 1.11.2版本。我能够创建命名的docker卷:

docker volume create --name my-jenkins-volume
Run Code Online (Sandbox Code Playgroud)

比我能够通过以下-v选项将我的容器与named-volume连接:

docker run -d -u jenkins --name jenkins -p 50000:50000 -p 443:8443 -v my-jenkins-volume:/var/jenkins_home
Run Code Online (Sandbox Code Playgroud)

是否可以在docker-compose中创建此命名卷?

docker docker-compose

11
推荐指数
4
解决办法
1万
查看次数

在Ubuntu上创建用户postgres

所以我在Ubuntu上安装了postgresql9.3.现在我必须创建一个新用户.所以超级用户postgres一切皆有可能.但我需要为每个新数据库提供一个新用户.

所以我做了什么:

sudo -u postgres psql
CREATE USER python with PASSWORD 'python';
CREATE DATABASE dbpython;
GRANT ALL PRIVILEGES ON DATABASE dbpython to python;
Run Code Online (Sandbox Code Playgroud)

我还修改了/etc/postgresql/9.1/main/pg_hba.conf文件,并将本地frompeer的身份验证设置更改为md5.

在我重新启动postgres后,我想使用我的新用户:

ubuntu@ip-172-31-33-139:~$ su python 
No passwd entry for user 'python'
Run Code Online (Sandbox Code Playgroud)

ubuntu@ip-172-31-33-139:~$ sudo service postgresql restart
 * Restarting PostgreSQL 9.3 database server                             [ OK ]
ubuntu@ip-172-31-33-139:~$ psql -d dbpython -U python
Password for user python:
psql (9.3.6)
Type "help" for help.

dbpython=>
Run Code Online (Sandbox Code Playgroud)

为什么这样工作而且su python不是?重要说明:我没有在我的Ubuntu中创建一个新的python用户,我希望这对postgres上的每个新用户都没有必要.

sql postgresql ubuntu

10
推荐指数
1
解决办法
1万
查看次数

Gulp将无法在Jenkins工作

我已经全局安装了gulp(npm install gulp -g).但我认为这不起作用.当我在我的本地程序上进行gulp测试时,它工作正常.但是当我从github(在Jenkins上)对我的(相同)程序进行gulp测试时,它会出现以下错误.它不会识别gulp命令.有人能帮我吗?感谢Jenkins的错误:

[EnvInject] - Loading node environment variables.
Building in workspace C:\Program Files (x86)\Jenkins\workspace\project1
 > C:\Program Files (x86)\Git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > C:\Program Files (x86)\Git\bin\git.exe config remote.origin.url https://github.com/Jelle7/project1.git # timeout=10
Fetching upstream changes from https://github.com/Jelle7/project1.git
 > C:\Program Files (x86)\Git\bin\git.exe --version # timeout=10
 > C:\Program Files (x86)\Git\bin\git.exe -c core.askpass=true fetch --tags --progress https://github.com/Jelle7/project1.git +refs/heads/*:refs/remotes/origin/*
 > C:\Program Files (x86)\Git\bin\git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
 > C:\Program Files (x86)\Git\bin\git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking …
Run Code Online (Sandbox Code Playgroud)

command github jenkins gulp

9
推荐指数
1
解决办法
5107
查看次数

Jenkins上的Android模拟器错误:设备离线

我已经为Jenkins安装了Android Emulator插件.我可以构建和测试Android项目.我的Jenkins在Ubuntu服务器上运行(仅限终端访问).该项目是从Github撤出的.现在我想使用模拟器.这是我的配置:

  • Android操作系统版本:4.4
  • 屏幕密度:160
  • 屏幕分辨率:480x800
  • 目标ABI:armeabi-v7a

我还安装了adb并执行了以下命令:

/opt/android-sdk-linux/tools/android update sdk --no-ui 
Run Code Online (Sandbox Code Playgroud)

但它不起作用:

 > /usr/bin/git rev-list 3440b28279e2e95113ce1c9499d9d881e76f6810 # timeout=10
$ /opt/android-sdk-linux/tools/android list target
[android] Using Android SDK: /opt/android-sdk-linux
$ /opt/android-sdk-linux/platform-tools/adb start-server
* daemon not running. starting it now on port 7767 *
* daemon started successfully *
$ /opt/android-sdk-linux/platform-tools/adb start-server
[android] Starting Android emulator
$ /opt/android-sdk-linux/tools/emulator -ports 7765,7766 -prop persist.sys.language=en -prop persist.sys.country=US -avd hudson_en-US_160_WVGA_android-19_armeabi-v7a -no-snapshot-load -no-snapshot-save -no-window
Failed to Initialize backend EGL display
Could not initialize emulated framebufferemulator: WARNING: Could not …
Run Code Online (Sandbox Code Playgroud)

plugins android emulation adb jenkins

6
推荐指数
1
解决办法
1597
查看次数

无法访问http:// ip:8443上的OpenShift控制台

我在CentOS7上安装了OpenShift版本3.我按照官方文档:https: //docs.openshift.org/latest/admin_guide/install/prerequisites.html#configuring-docker-storage

方法1(Docker):https: //docs.openshift.org/latest/getting_started/administrators.html#installation-methods

我选择在Docker Container中安装OpenShift.我必须做的最后一个命令就是这个:我使用Docker Hub中的图像在Docker容器中启动服务器:

$ docker run -d --name "openshift-origin" --net=host --privileged \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp/openshift:/tmp/openshift \
openshift/origin start
Run Code Online (Sandbox Code Playgroud)

这个命令:

  • 启动OpenShift监听所有接口(0.0.0.0:8443),

  • 启动web控制台监听所有接口(0.0.0.0:8443),

  • 启动一个etcd服务器来存储持久数据,和

  • 推出Kubernetes系统组件.

    $ sudo docker ps
    
    CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS               NAMES
    
    d3f023085328        openshift/origin    "/usr/bin/openshift    2 days ago          Up 2 days                               openshift-origin
    
    Run Code Online (Sandbox Code Playgroud)

现在我能做到:

$ sudo docker exec -it openshift-origin bash
Run Code Online (Sandbox Code Playgroud)

所以我可以在我的容器中访问openshift.我可以创建项目和应用程序,但构建状态始终处于待定状态.我无法访问https://publicip:8443/console.有人可以帮帮我吗?OpenShift页面加载一秒钟(当我要去http:// publicip:8443时),但是我得到一个redirect_url到10.0.0.x:8443.我的master-config看起来像这样:https://github.com/openshift/origin/blob/master/test/old-start-configs/v1.0.0/config/openshift.local.config/master/master-config. yaml.我需要改变什么?

网址: https://10.0.0.x:8443/oauth/authorize?client_id=openshift-web-console&response_type=token&state=%2F&redirect_uri=https%3A%2F%2F10.0.0.x%3A8443%2Fconsole%2Foauth

编辑:

docker run -d …
Run Code Online (Sandbox Code Playgroud)

localhost docker openshift-origin centos7

6
推荐指数
1
解决办法
6238
查看次数

AngularJS的可重用docker镜像

我们有一个AngularJS应用程序.我们为它编写了一个dockerfile,因此它可以在每个系统上重用.dockerfile不是最佳实践,它可能是一些奇怪的构建(在同一个文件中构建和托管),但它只是为了在每个开发人员的每台PC上本地运行我们的angularjs应用程序而创建.

Dockerfile:
FROM nginx:1.10

... Steps to install nodejs-legacy + npm

RUN npm install -g gulp
RUN npm install
RUN gulp build  

.. steps to move dist folder
Run Code Online (Sandbox Code Playgroud)

我们构建我们的图像docker build -t myapp:latest . 每个开发人员都能够运行我们的应用程序docker run -d -p 80:80 myapp:latest

但现在我们正在开发其他后端.所以我们在DEV中有一个后端,UAT中的后端,...所以我们需要使用不同的URL/config/xx.json

{
  ...
  "service_base": "https://backend.test.xxx/",
  ...
}
Run Code Online (Sandbox Code Playgroud)

我们不希望每次都更改该URL,重建图像并启动它.我们也不想声明可以在那里使用的一些URL(dev,uat,prod,..).我们希望gulp build使用环境变量而不是硬编码的URL 来执行我们的流程.

所以我们可以像这样启动容器:

docker run -d -p 80:80 --env URL=https://mybackendurl.com app:latest
Run Code Online (Sandbox Code Playgroud)

是否有人有这种问题的经验?所以我们在json中需要一个env变量并构建它,如果可能的话,稍后再添加URL.

json environment-variables angularjs docker dockerfile

6
推荐指数
1
解决办法
873
查看次数