繁体   English   中英

试图运行一个测试套件,但 Jenkins 没有下载最新的代码

[英]Trying to run a test suite but Jenkins not pulling down the latest code

我正在使用 Jenkins 运行一个测试套件,并且我已经配置了一个工作来做到这一点。 我有一个正在执行所有步骤的管道脚本,但似乎通过在 LIVE 上添加一个新按钮在 LIVE 上的最新版本中,我的测试运行了一个没有该按钮的代码版本,它似乎是不拉最新的代码。 我在脚本中做错了什么?

我曾尝试从 Bitbucket 中提取最新代码,但没有成功并通过执行“docker-compose build --build-arg BRANCH=${branch} apache”来构建分支

node {
   stage('Pull latest Docker repo') { 
      git credentialsId: 'xyz',
          url: 'git@bitbucket.org:domain/myportal-docker.git'
   }
   stage('Install app') {
      sh 'docker-compose down'
      sh 'docker-compose build --no-cache mysql'
      if (params.buildapp == true){
        sh 'docker-compose build --build-arg BRANCH=${branch} apache'
      }
      sh 'docker-compose up -d'
   }
   stage('Set up Selenium') {
      try {
        sh 'docker rm selenium -f'
      }
      catch(exc) {
        echo 'No selenium container running'
      }
      sh 'docker pull selenium/standalone-chrome'
      sh 'docker run -d -p 4444:4444 --name=selenium --net=host -v /dev/shm:/dev/shm selenium/standalone-chrome:3.141.59-dubnium'
   }
   stage('Load tests') { 
      dir("../") {}
      git credentialsId: 'xyz',
          url: 'git@bitbucket.org:domain/my-tests.git'
   }
   stage('Run tests') {
      sh 'composer install'
      sh 'vendor/bin/codecept --debug run --steps tests/jenkins'
   }
}

测试运行良好,但不知何故它们没有在最新代码上运行,它们针对 master 分支运行,但它没有最新代码。 此外,我有一个按需工作,我想尝试一下,一旦有一些信息,也许你们中的一些人就可以解决这个问题。

params.buildapp 是假的,所以它没有构建 apache 容器。 只有在构建此容器时才会从您的存储库中提取代码。

可能与您的 Dockerfile 有关

您需要确保使用ADD ./yourcodefolder关闭文件

@teddym6 现在看起来像这样,我的 Dockerfile:

来自 webdevops/php-apache:7.1

ARG WWW_ROOT ARG APP_DIR ARG APP_ROOT=${WWW_ROOT}/${APP_DIR} ARG 分支

ENV WEB_DOCUMENT_ROOT=${APP_ROOT}/htdocs

RUN mkdir /root/.ssh/ ADD ./.ssh/ /root/.ssh/ RUN chmod -R 0600 /root/.ssh/* RUN echo "Using branch ${BRANCH} for code" RUN git clone --branch ${BRANCH} --depth 1 git@bitbucket.org:domain/myportal-docker.git ${APP_ROOT}

工作目录 ${APP_ROOT}

运行 mkdir -p 运行时 htdocs/assets 运行 chmod -R a+w 运行时 htdocs/assets

工作目录 /usr/src/app

复制 app/local.php ${APP_ROOT}/config/local.php

添加 。 /usr/src/app 工作目录 /usr/src/app

这个家伙还有其他想法吗?

由于我尝试了上述所有方法,但没有任何效果。 测试运行良好,但不是最新的代码。

正如我在第一篇文章中所说,我知道是因为我们在第一页上有一个新按钮,而我运行测试的版本中没有这个按钮。

回到这个因为它让我头疼,所以控制台输出看起来像这样:

  Started by timer
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/jobs/Autotest/workspace
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Pull latest Docker repo)
[Pipeline] git
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url git@bitbucket.org:domain/myportal-docker.git
 # timeout=10
Fetching upstream changes from git@bitbucket.org:domain/myportal-docker.git
 > git --version # timeout=10
using GIT_SSH to set credentials Jenkins Portal Tests Repo
 > git fetch --tags --progress git@bitbucket.org:domain/myportal-docker.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 20cdc207dc87e736983d6b28b5a81853c7c37f70 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 20cdc207dc87e736983d6b28b5a81853c7c37f70
 > git branch -a -v --no-abbrev # timeout=10
 > git branch -D master # timeout=10
 > git checkout -b master 20cdc207dc87e736983d6b28b5a81853c7c37f70
Commit message: "Got rid of the WORKDIR"
 > git rev-list --no-walk 20cdc207dc87e736983d6b28b5a81853c7c37f70 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Install app)
[Pipeline] sh
[workspace] Running shell script
+ docker-compose down
Stopping workspace_apache_1 ... 
Stopping workspace_mysql_1  ... 
[2A[2K
Stopping workspace_apache_1 ... [32mdone[0m
[2B[1A[2K
Stopping workspace_mysql_1  ... [32mdone[0m
[1BRemoving workspace_apache_1 ... 
Removing workspace_mysql_1  ... 
[1A[2K
Removing workspace_mysql_1  ... [32mdone[0m
[1B[2A[2K
Removing workspace_apache_1 ... [32mdone[0m
[2BRemoving network workspace_frontend
Removing network workspace_backend
[Pipeline] sh
[workspace] Running shell script
+ docker-compose build --no-cache mysql
Building mysql
Step 1/2 : FROM mysql:5.7.24
 ---> ba7a93aae2a8
Step 2/2 : ADD mysql.cnf /etc/mysql/mysql.conf.d/mysql.cnf
 ---> cd3843490228
Successfully built cd3843490228
Successfully tagged workspace_mysql:latest
[Pipeline] echo
Will deploy from feature/docker-enablement
[Pipeline] echo
BuildApp Param false
[Pipeline] sh
[workspace] Running shell script
+ docker-compose up -d
Creating network "workspace_frontend" with the default driver
Creating network "workspace_backend" with the default driver
Creating workspace_mysql_1 ... 
Creating workspace_mysql_1
[1A[2K
Creating workspace_mysql_1 ... [32mdone[0m
[1BCreating workspace_apache_1 ... 
Creating workspace_apache_1
[1A[2K
Creating workspace_apache_1 ... [32mdone[0m
[1B[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Set up Selenium)
[Pipeline] sh
[workspace] Running shell script
+ docker rm selenium -f
selenium
[Pipeline] sh
[workspace] Running shell script
+ docker pull selenium/standalone-chrome
Using default tag: latest
latest: Pulling from selenium/standalone-chrome
Digest: sha256:c478febf26729b7cc27e2fac7d10fa79cf2519b5ab83f9cf82705248258b6495
Status: Image is up to date for selenium/standalone-chrome:latest
[Pipeline] sh
[workspace] Running shell script
+ docker run -d -p 4444:4444 --name=selenium --net=host -v /dev/shm:/dev/shm selenium/standalone-chrome:3.141.59-dubnium
WARNING: Published ports are discarded when using host network mode
952481c15140f1b9fe797cbee495268d7fd191c4ec07194297e19b27109f829a
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Load tests)
[Pipeline] dir
Running in /var/lib/jenkins/jobs/Autotest
[Pipeline] {
[Pipeline] }
[Pipeline] // dir
[Pipeline] git
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url git@bitbucket.org:domain/myportal-docker.git
 # timeout=10
Fetching upstream changes from git@bitbucket.org:domain/myportal-docker.git
 > git --version # timeout=10
using GIT_SSH to set credentials Jenkins Portal Tests Repo
 > git fetch --tags --progress git@bitbucket.org:domain/myportal-docker.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision a5ddc6742c13e3b8c37e7ebda625fd8d89b1386a (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f a5ddc6742c13e3b8c37e7ebda625fd8d89b1386a
 > git branch -a -v --no-abbrev # timeout=10
 > git branch -D master # timeout=10
 > git checkout -b master a5ddc6742c13e3b8c37e7ebda625fd8d89b1386a
Commit message: "Commented out the forum request button test"
 > git rev-list --no-walk a5ddc6742c13e3b8c37e7ebda625fd8d89b1386a # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Run tests)
[Pipeline] sh
[workspace] Running shell script
+ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
[Pipeline] sh
[workspace] Running shell script
+ vendor/bin/codecept --debug run --steps tests/jenkins
Codeception PHP Testing Framework v2.5.2
Powered by PHPUnit 6.5.13 by Sebastian Bergmann and contributors.
Running with seed:

综上所述,测试运行正常,但正如该线程所说,不是在最新的代码上。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM